chore: migrate Regex Tools to LocalToolBox
This commit is contained in:
@@ -15,6 +15,49 @@ async function waitForReady(page: Page) {
|
||||
});
|
||||
}
|
||||
|
||||
async function attemptRunWhileDisabled(page: Page) {
|
||||
return page.evaluate(() => {
|
||||
const button = document.querySelector<HTMLButtonElement>(".run-button");
|
||||
if (!button) throw new Error("Run button missing");
|
||||
if (!button.disabled) return false;
|
||||
button.click();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
test("uses the shared 90rem content width without a browser body frame", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1800, height: 900 });
|
||||
await page.goto("./");
|
||||
await expect(page.locator(".regex-application")).toBeVisible();
|
||||
|
||||
const layout = await page.evaluate(() => {
|
||||
const shellMain = document.querySelector<HTMLElement>(
|
||||
".toolbox-shell__main",
|
||||
);
|
||||
const application =
|
||||
document.querySelector<HTMLElement>(".regex-application");
|
||||
if (!shellMain || !application)
|
||||
throw new Error("Application shell missing");
|
||||
|
||||
const shellMainStyle = getComputedStyle(shellMain);
|
||||
return {
|
||||
bodyMargin: getComputedStyle(document.body).margin,
|
||||
shellMainWidth: shellMain.getBoundingClientRect().width,
|
||||
shellMainContentWidth:
|
||||
shellMain.clientWidth -
|
||||
Number.parseFloat(shellMainStyle.paddingLeft) -
|
||||
Number.parseFloat(shellMainStyle.paddingRight),
|
||||
applicationWidth: application.getBoundingClientRect().width,
|
||||
};
|
||||
});
|
||||
|
||||
expect(layout.bodyMargin).toBe("0px");
|
||||
expect(layout.shellMainWidth).toBe(1440);
|
||||
expect(layout.applicationWidth).toBe(layout.shellMainContentWidth);
|
||||
});
|
||||
|
||||
test("standalone ECMAScript workbench parses, explains and extracts", async ({
|
||||
page,
|
||||
}) => {
|
||||
@@ -451,18 +494,20 @@ test("rapid pattern and replacement edits cannot run with stale syntax", async (
|
||||
|
||||
await setEditor(page, "editor-regular-expression-pattern", "(?<stale>\\w+)");
|
||||
await setEditor(page, "editor-replacement-template", "$<stale>");
|
||||
await setEditor(page, "editor-replacement-template", "[$<letter>]");
|
||||
await setEditor(page, "editor-test-text", "A B");
|
||||
await setEditor(
|
||||
page,
|
||||
"editor-regular-expression-pattern",
|
||||
"(?<letter>[A-Z])",
|
||||
);
|
||||
await setEditor(page, "editor-replacement-template", "[$<letter>]");
|
||||
await setEditor(page, "editor-test-text", "A B");
|
||||
|
||||
const runButton = page.getByRole("button", { name: "Run", exact: true });
|
||||
await expect(runButton).toBeDisabled();
|
||||
await runButton.evaluate((button: HTMLButtonElement) => button.click());
|
||||
await expect(page.locator(".run-status")).not.toHaveClass(/status-running/u);
|
||||
expect(await attemptRunWhileDisabled(page)).toBe(true);
|
||||
await expect(page.locator(".run-status")).toHaveClass(/status-idle/u);
|
||||
await expect(page.locator(".run-status")).toContainText(
|
||||
"last completed result remains visible",
|
||||
);
|
||||
await expect(page.locator(".extraction-row")).toHaveCount(
|
||||
initialExtractionCount,
|
||||
);
|
||||
@@ -476,9 +521,8 @@ test("rapid pattern and replacement edits cannot run with stale syntax", async (
|
||||
await expect(currentNamedToken.locator("small")).toHaveText("named capture");
|
||||
|
||||
await page.getByRole("checkbox", { name: "Ignore case (i)" }).check();
|
||||
await expect(runButton).toBeDisabled();
|
||||
await runButton.evaluate((button: HTMLButtonElement) => button.click());
|
||||
await expect(page.locator(".run-status")).not.toHaveClass(/status-running/u);
|
||||
expect(await attemptRunWhileDisabled(page)).toBe(true);
|
||||
await expect(page.locator(".run-status")).toHaveClass(/status-idle/u);
|
||||
|
||||
await expect(runButton).toBeEnabled();
|
||||
await runButton.click();
|
||||
|
||||
Reference in New Issue
Block a user