diff --git a/.serena/memories/frontend/testing.md b/.serena/memories/frontend/testing.md index b4215a6fdf..1a6962f7eb 100644 --- a/.serena/memories/frontend/testing.md +++ b/.serena/memories/frontend/testing.md @@ -65,6 +65,8 @@ New frontend test namespaces must be required/listed in `frontend_tests/runner.c Do not add, modify, or run Playwright integration tests under `frontend/playwright` unless explicitly asked. When explicitly asked, run the whole suite with a worker count sized to the machine: `pnpm run test:e2e --workers=N` from `frontend/`, about one worker per two hardware threads, because each keeps two or three busy and holds about 2 GB of browser memory. The config's default of one worker leaves it slow; four take a 16-thread host from 48 minutes to 35 and fit a 64 GB machine beside a watching devenv, while a 32 GB machine takes two, or four with a slim devenv. `--grep "pattern"` narrows the run. Ensure dependencies are installed through `./scripts/setup` if the environment is not prepared. +The suite runs against the release bundle in `frontend/resources/public`, not against the sources: the app under test is that build. Rebuild it with `./scripts/build` from `frontend/` (the CI build-bundle step) whenever the product source state changes — a branch switch that brings different CLJS/CLJC, SCSS, assets or packages, or any product edit. Spec-only edits need no rebuild: Playwright reads `frontend/playwright` at run time. A stale bundle is still served by the config's `webServer` (`scripts/e2e-server.js`) and makes the app fail at boot; that failure says nothing about the specs. + Integration tests fake backend behavior by intercepting network/websocket traffic, so every RPC or websocket the page needs must be mocked. Use existing Page Object Models: - `BasePage.mockRPC` intercepts RPC calls and already prefixes `/api/rpc/command/`; pass command names such as `get-profile`, not full URLs. - Workspace or other websocket-using pages should extend/use `BaseWebSocketPage`, initialize websocket mocks before each test, and mock `/ws/notifications` with the provided helpers. @@ -72,7 +74,7 @@ Integration tests fake backend behavior by intercepting network/websocket traffi Locator priority should follow user-facing semantics: `getByRole`, `getByLabel`, `getByPlaceholder`, `getByText`, then semantic alternatives such as alt/title, with `getByTestId` as the last resort. Name tests from the user's perspective and prefer positive, single-purpose assertions. -Layer rows are the exception: a selected row's hide and lock button titles join its accessible name, so role-plus-name matching breaks on selected rows. Use `WorkspacePage.layerRow`, which anchors on the `layer-row` test id's text, and `selectLayer`, which waits for `aria-checked`. +Layer rows are the exception: a selected row's hide and lock button titles join its accessible name, so role-plus-name matching breaks on selected rows. Use `WorkspacePage.layerRow`/`layerRows` (anchored text on the `layer-row` test id) and `selectRow`/`selectLayer`, which click once and wait for `aria-checked`. ## CI (E2E) diff --git a/frontend/playwright/data/workspace/get-team-variants.json b/frontend/playwright/data/workspace/get-team-variants.json deleted file mode 100644 index 2ac6097bdc..0000000000 --- a/frontend/playwright/data/workspace/get-team-variants.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "~:features": { - "~#set": [ - "variants/v1", - "layout/grid", - "styles/v2", - "fdata/pointer-map", - "fdata/objects-map", - "components/v2", - "fdata/shape-data-type" - ] - }, - "~:permissions": { - "~:type": "~:membership", - "~:is-owner": true, - "~:is-admin": true, - "~:can-edit": true - }, - "~:name": "Default", - "~:modified-at": "~m1713533116375", - "~:id": "~uc7ce0794-0992-8105-8004-38e630f40f6d", - "~:created-at": "~m1713533116375", - "~:is-default": true -} \ No newline at end of file diff --git a/frontend/playwright/ui/pages/WorkspacePage.js b/frontend/playwright/ui/pages/WorkspacePage.js index fdae33d004..361426d195 100644 --- a/frontend/playwright/ui/pages/WorkspacePage.js +++ b/frontend/playwright/ui/pages/WorkspacePage.js @@ -589,17 +589,28 @@ export class WorkspacePage extends BaseWebSocketPage { // append text to the same node. Matching by accessible name is not an // option: a selected row shows its hide and lock buttons, whose titles // join the name. - layerRow(name) { + layerRows(name) { return this.layers .getByTestId("layer-row") - .filter({ hasText: new RegExp(`^${escapeRegExp(name)}$`, "i") }) - .first(); + .filter({ hasText: new RegExp(`^${escapeRegExp(name)}$`, "i") }); + } + + layerRow(name) { + return this.layerRows(name).first(); + } + + // Selecting acts on the selection as it is at that moment: click once and + // assert the state instead of retrying, which would hide a lost click. + // Plain selections only: a plain layer-row click replaces the selection, so + // the assertion means exactly this row is selected. Additive selections + // (mod/shift) keep their own click options and assertions. + async selectRow(row, clickOptions = {}) { + await row.click(clickOptions); + await expect(row).toHaveAttribute("aria-checked", "true"); } async selectLayer(name, clickOptions = {}) { - const row = this.layerRow(name); - await row.click(clickOptions); - await expect(row).toHaveAttribute("aria-checked", "true"); + await this.selectRow(this.layerRow(name), clickOptions); } async getSelectedShapeName() { diff --git a/frontend/playwright/ui/specs/colorpicker.spec.js b/frontend/playwright/ui/specs/colorpicker.spec.js index 6625cb4b8a..40297173a4 100644 --- a/frontend/playwright/ui/specs/colorpicker.spec.js +++ b/frontend/playwright/ui/specs/colorpicker.spec.js @@ -5,189 +5,153 @@ test.beforeEach(async ({ page }) => { await WasmWorkspacePage.init(page); }); -// Fix for https://tree.taiga.io/project/penpot/issue/7549 -test("Bug 7549 - User clicks on color swatch to display the color picker next to it", async ({ +const RECTANGLE_FILE = { + fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374", + pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375", +}; + +// The two fill-picker tests below share one document: `get-file-not-empty.json` +// holds a single "Rectangle" whose fill is `#B1B2B5`, and every case starts +// from the picker of that fill. +async function openRectangleFill(page) { + const workspacePage = new WasmWorkspacePage(page); + await workspacePage.setupEmptyFile(); + await workspacePage.mockRPC( + /get\-file\?/, + "workspace/get-file-not-empty.json", + ); + await workspacePage.mockRPC( + "update-file?id=*", + "workspace/update-file-create-rect.json", + ); + await workspacePage.goToWorkspace(RECTANGLE_FILE); + await workspacePage.clickLeafLayer("Rectangle"); + await page.getByRole("button", { name: "#B1B2B5" }).click(); + return workspacePage; +} + +// Fix for https://tree.taiga.io/project/penpot/issue/7549 and +// https://tree.taiga.io/project/penpot/issue/9900 +test("The canvas color picker opens by its swatch and shows the HSB inputs", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - + await workspacePage.setupEmptyFile(); await workspacePage.goToWorkspace(); await workspacePage.moveButton.click(); - const swatch = workspacePage.page.getByRole("button", { name: "E8E9EA" }); + + const swatch = page.getByRole("button", { name: "E8E9EA" }); const swatchBox = await swatch.boundingBox(); await swatch.click(); - await expect(workspacePage.colorpicker).toBeVisible(); - const pickerBox = await workspacePage.colorpicker.boundingBox(); - const distance = swatchBox.x - (pickerBox.x + pickerBox.width); - expect(distance).toBeLessThan(60); + await test.step("the picker opens next to the swatch", async () => { + await expect(workspacePage.colorpicker).toBeVisible(); + const pickerBox = await workspacePage.colorpicker.boundingBox(); + const distance = swatchBox.x - (pickerBox.x + pickerBox.width); + expect(distance).toBeLessThan(60); + }); + + await test.step("the picker shows the HSB inputs", async () => { + await page.getByLabel("HSBA").click(); + + // The old case called `isVisible()` on labels that do not exist ("H", "S", + // "B(V)" are the icons, not the accessible names) and never awaited them, + // so it asserted nothing. The inputs are labelled by their real names. + await expect(page.getByLabel("Hue")).toBeVisible(); + await expect(page.getByLabel("Saturation")).toBeVisible(); + await expect(page.getByLabel("Brightness (Value)")).toBeVisible(); + }); }); -test("Bug 10756 - Image fill picker accepts SVG files", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-not-empty.json", - ); - await workspacePage.mockRPC( - "update-file?id=*", - "workspace/update-file-create-rect.json", - ); +// Fix for https://tree.taiga.io/project/penpot/issue/10089 and +// https://tree.taiga.io/project/penpot/issue/10756 +test("The fill picker changes alpha and accepts SVG image fills", async ({ + page, +}) => { + await openRectangleFill(page); - await workspacePage.goToWorkspace({ - fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374", - pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375", + // The alpha case asserts the initial 100, so it runs before the case that + // replaces the solid fill with an image. + await test.step("the alpha can be changed", async () => { + const alpha = page.getByRole("spinbutton", { name: "Alpha" }); + await expect(alpha).toHaveValue("100"); + + await page.getByTestId("slider-opacity").click(); + await expect(alpha).toHaveValue("50"); }); - await workspacePage.clickLeafLayer("Rectangle"); - await workspacePage.page - .getByRole("button", { name: "#B1B2B5" }) - .click(); - await workspacePage.page.getByText("Solid").click(); - await workspacePage.page.getByText("Image").click(); - await expect(workspacePage.page.locator("#fill-image-upload")).toHaveAttribute( - "accept", - /(?:^|,)image\/svg\+xml(?:,|$)/, - ); + await test.step("the image fill accepts SVG files", async () => { + await page.getByText("Solid").click(); + await page.getByText("Image").click(); + + await expect(page.locator("#fill-image-upload")).toHaveAttribute( + "accept", + /(?:^|,)image\/svg\+xml(?:,|$)/, + ); + }); }); -test("Create a LINEAR gradient", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-not-empty.json", - ); - await workspacePage.mockRPC( - "update-file?id=*", - "workspace/update-file-create-rect.json", - ); +test("The fill picker creates a linear and a radial gradient", async ({ + page, +}) => { + const workspacePage = await openRectangleFill(page); - await workspacePage.goToWorkspace({ - fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374", - pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375", + const colorpicker = workspacePage.colorpicker; + const removeStop = colorpicker.getByRole("button", { + name: "Remove color", + }); + const addStop = page.getByRole("button", { name: "Add stop" }); + + // Both steps add three stops and remove two on their own gradient; counting + // them is what proves the step did the work instead of inheriting it. + const addAndRemoveStops = async () => { + const stopsBefore = await removeStop.count(); + await addStop.click(); + await addStop.click(); + await addStop.click(); + await removeStop.last().click(); + await removeStop.last().click(); + await expect(removeStop).toHaveCount(stopsBefore + 1); + }; + + const setEdgeStops = async (lastOpacity) => { + await colorpicker + .getByRole("textbox", { name: "Color" }) + .first() + .fill("#fabada"); + await colorpicker.getByTestId("opacity-input").first().fill("100"); + await colorpicker + .getByRole("textbox", { name: "Color" }) + .last() + .fill("#ff0000"); + await colorpicker.getByTestId("opacity-input").last().fill(lastOpacity); + }; + + await test.step("linear gradient", async () => { + await page.getByText("Solid").click(); + await page.getByText("Gradient").click(); + + await addAndRemoveStops(); + await setEdgeStops("40"); + + await expect(page.getByText("Linear gradient")).toBeVisible(); }); - await workspacePage.clickLeafLayer("Rectangle"); + await test.step("radial gradient", async () => { + await colorpicker + .getByRole("combobox") + .filter({ hasText: "Linear" }) + .click(); + await page.getByRole("option", { name: "Radial" }).click(); - const swatch = workspacePage.page.getByRole("button", { name: "#B1B2B5" }); - await swatch.click(); + await addAndRemoveStops(); + await setEdgeStops("100"); - const select = workspacePage.page.getByText("Solid"); - await select.click(); - - const gradOption = workspacePage.page.getByText("Gradient"); - await gradOption.click(); - - const addStopBtn = workspacePage.page.getByRole("button", { - name: "Add stop", + await expect(page.getByText("Radial gradient")).toBeVisible(); + await expect(colorpicker.getByTestId("opacity-input").last()).toHaveValue( + "100", + ); }); - await addStopBtn.click(); - await addStopBtn.click(); - await addStopBtn.click(); - - const removeBtn = workspacePage.colorpicker - .getByRole("button", { name: "Remove color" }) - .last(); - await removeBtn.click(); - await removeBtn.click(); - - const inputColor1 = workspacePage.colorpicker - .getByRole("textbox", { name: "Color" }) - .first(); - await inputColor1.fill("#fabada"); - - const inputOpacity1 = workspacePage.colorpicker - .getByTestId("opacity-input") - .first(); - await inputOpacity1.fill("100"); - - const inputColor2 = workspacePage.colorpicker - .getByRole("textbox", { name: "Color" }) - .last(); - await inputColor2.fill("#ff0000"); - - const inputOpacity2 = workspacePage.colorpicker - .getByTestId("opacity-input") - .last(); - await inputOpacity2.fill("40"); - - await expect(workspacePage.page.getByText("Linear gradient")).toBeVisible(); -}); - -test("Create a RADIAL gradient", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-not-empty.json", - ); - await workspacePage.mockRPC( - "update-file?id=*", - "workspace/update-file-create-rect.json", - ); - - await workspacePage.goToWorkspace({ - fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374", - pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375", - }); - await workspacePage.clickLeafLayer("Rectangle"); - - const swatch = workspacePage.page.getByRole("button", { name: "#B1B2B5" }); - await swatch.click(); - - const select = workspacePage.page.getByText("Solid"); - await select.click(); - - const gradOption = workspacePage.page.getByText("Gradient"); - await gradOption.click(); - - const gradTypeSelect = workspacePage.colorpicker - .getByRole("combobox") - .filter({ hasText: "Linear" }); - await gradTypeSelect.click(); - - const gradRadialOption = workspacePage.page.getByRole("option", { - name: "Radial", - }); - await gradRadialOption.click(); - - const addStopBtn = workspacePage.page.getByRole("button", { - name: "Add stop", - }); - await addStopBtn.click(); - await addStopBtn.click(); - await addStopBtn.click(); - - const removeBtn = workspacePage.colorpicker - .getByRole("button", { name: "Remove color" }) - .last(); - await removeBtn.click(); - await removeBtn.click(); - - const inputColor1 = workspacePage.page - .getByRole("textbox", { name: "Color" }) - .first(); - await inputColor1.fill("#fabada"); - - const inputOpacity1 = workspacePage.colorpicker - .getByTestId("opacity-input") - .first(); - await inputOpacity1.fill("100"); - - const inputColor2 = workspacePage.page - .getByRole("textbox", { name: "Color" }) - .last(); - await inputColor2.fill("#ff0000"); - - const inputOpacity2 = workspacePage.colorpicker - .getByTestId("opacity-input") - .last(); - await inputOpacity2.fill("100"); - - await expect(workspacePage.page.getByText("Radial gradient")).toBeVisible(); }); test("Gradient stops limit", async ({ page }) => { @@ -219,56 +183,6 @@ test("Gradient stops limit", async ({ page }) => { ).toBeDisabled(); }); -// Fix for https://tree.taiga.io/project/penpot/issue/9900 -test("Bug 9900 - Color picker has no inputs for HSB values", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - - await workspacePage.goToWorkspace(); - await workspacePage.moveButton.click(); - const swatch = workspacePage.page.getByRole("button", { name: "E8E9EA" }); - await swatch.click(); - - const HSBA = await workspacePage.page.getByLabel("HSBA"); - await HSBA.click(); - - await workspacePage.page.getByLabel("H", { exact: true }).isVisible(); - await workspacePage.page.getByLabel("S", { exact: true }).isVisible(); - await workspacePage.page.getByLabel("B(V)", { exact: true }).isVisible(); -}); - -test("Bug 10089 - Cannot change alpha", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-not-empty.json", - ); - await workspacePage.mockRPC( - "update-file?id=*", - "workspace/update-file-create-rect.json", - ); - - await workspacePage.goToWorkspace({ - fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374", - pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375", - }); - await workspacePage.clickLeafLayer("Rectangle"); - - const swatch = workspacePage.page.getByRole("button", { name: "#B1B2B5" }); - await swatch.click(); - - const alpha = workspacePage.page.getByRole("spinbutton", { name: "Alpha" }); - await expect(alpha).toHaveValue("100"); - - const alphaSlider = workspacePage.page.getByTestId("slider-opacity"); - await alphaSlider.click(); - - await expect(alpha).toHaveValue("50"); -}); - test("Color picker color list", async ({ page }) => { const workspacePage = new WasmWorkspacePage(page); await workspacePage.setupEmptyFile(); @@ -348,13 +262,17 @@ test("Color picker color list", async ({ page }) => { ).toBeVisible(); //test show and hide color palette - const paletteToggle = workspacePage.page.getByRole('button', { name: 'Toggle color palette' }); + const paletteToggle = workspacePage.page.getByRole("button", { + name: "Toggle color palette", + }); await paletteToggle.click(); - const paletteBar = workspacePage.page.getByRole('region', { name: 'Palette bar' }); + const paletteBar = workspacePage.page.getByRole("region", { + name: "Palette bar", + }); await expect(paletteBar).toBeVisible(); // Check that color palette is open by checking the presence of a color swatch in the palette - const paletteSwatch = paletteBar.getByRole('button', { name: 'first color' }); + const paletteSwatch = paletteBar.getByRole("button", { name: "first color" }); await expect(paletteSwatch).toBeVisible(); // Close the color palette diff --git a/frontend/playwright/ui/specs/export-frames.spec.js b/frontend/playwright/ui/specs/export-frames.spec.js index aa34953a83..c0aaa3ecd6 100644 --- a/frontend/playwright/ui/specs/export-frames.spec.js +++ b/frontend/playwright/ui/specs/export-frames.spec.js @@ -28,8 +28,28 @@ async function setupWorkspaceWithFrames(workspacePage) { }); } +// The "file" entry of the main menu has a stable id, so it does not depend on +// which text on the page happens to contain the word. "Export shapes" always +// renders, and it is the anchor that proves the submenu really opened: without +// it, every assertion about the frames entry would also pass on a closed menu. +async function openFileMenu(page) { + await page.getByRole("button", { name: "Main menu" }).click(); + await page.locator("#file-menu-file").click(); + await expect(page.locator("#file-menu-export-shapes")).toBeVisible(); +} + +async function openExportFramesDialog(page) { + await openFileMenu(page); + await page.locator("#file-menu-export-frames").click(); + await expect(page.getByText("Export as PDF")).toBeVisible(); +} + +const cancelButton = (page) => page.getByRole("button", { name: "Cancel" }); +const exportButton = (page) => + page.getByRole("button", { name: "Export", exact: true }); + test.describe("Export frames to PDF", () => { - test("Export frames menu option is NOT visible when page has no frames", async ({ + test("The file menu hides the PDF export when the page has no frames", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); @@ -37,163 +57,87 @@ test.describe("Export frames to PDF", () => { await workspacePage.goToWorkspace(); - // Open main menu - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); + await openFileMenu(page); - // The "Export frames to PDF" option should NOT be visible when there are no frames - await expect(page.locator("#file-menu-export-frames")).not.toBeVisible(); + // The entry renders only when the page has frames, so it is absent from the + // DOM rather than hidden; the visible anchor above is what makes this + // assertion meaningful. + await expect(page.locator("#file-menu-export-frames")).toHaveCount(0); }); - test("Export frames menu option is visible when there are frames (even if not selected)", async ({ + test("The export frames dialog lists the frames and lets the user deselect them", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); await setupWorkspaceWithFrames(workspacePage); - // Open main menu - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); + const boardOne = workspacePage.layerRows("Board 1"); + const boardTwo = workspacePage.layerRows("Board 2"); - // The "Export frames to PDF" option should be visible when there are frames on the page - await expect(page.locator("#file-menu-export-frames")).toBeVisible(); - }); + // One dialog row per frame; they are the only buttons named after a board. + const dialogRow = (name) => page.getByRole("button", { name }); - test("Export frames modal shows all frames when none are selected", async ({ - page, - }) => { - const workspacePage = new WasmWorkspacePage(page); - await setupWorkspaceWithFrames(workspacePage); + await test.step("the file menu offers the PDF export", async () => { + await openFileMenu(page); - // Don't select any frame - - // Open main menu - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); - - // Click on "Export frames to PDF" - await page.locator("#file-menu-export-frames").click(); - - // The modal title should be correct - await expect(page.getByText("Export as PDF")).toBeVisible(); - - // Both frames should appear in the list - await expect(page.getByRole("button", { name: "Board 1" })).toBeVisible(); - await expect(page.getByRole("button", { name: "Board 2" })).toBeVisible(); - - // The selection counter should show "2 of 2" - await expect(page.getByText("2 of 2 elements selected")).toBeVisible(); - }); - - test("Export frames modal shows only the selected frames", async ({ - page, - }) => { - const workspacePage = new WasmWorkspacePage(page); - await setupWorkspaceWithFrames(workspacePage); - - // Select Frame 1 - await workspacePage.clickLeafLayer("Board 1"); - - // Open main menu - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); - - // Click on "Export frames to PDF" - await page.locator("#file-menu-export-frames").click(); - - // The modal title should be correct - await expect(page.getByText("Export as PDF")).toBeVisible(); - - // Only Frame 1 should appear in the list - // await page.getByRole("button", { name: "Board 1" }), - await expect(page.getByRole("button", { name: "Board 1" })).toBeVisible(); - await expect( - page.getByRole("button", { name: "Board 2" }), - ).not.toBeVisible(); - - // The selection counter should show "1 of 1" - await expect(page.getByText("1 of 1 elements selected")).toBeVisible(); - }); - - test("User can deselect frames in the export modal", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await setupWorkspaceWithFrames(workspacePage); - - // Select Frame 1 - await workspacePage.clickLeafLayer("Board 1"); - - // Add Frame 2 to selection - await page.keyboard.down("Shift"); - await workspacePage.clickLeafLayer("Board 2"); - await page.keyboard.up("Shift"); - - // Open main menu and click export - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); - await page.locator("#file-menu-export-frames").click(); - - // The modal should appear with 2 frames - await expect(page.getByText("2 of 2 elements selected")).toBeVisible(); - - // Click on the checkbox next to Frame 1 to deselect it - await page.getByRole("button", { name: "Board 1" }).click(); - - // Now only 1 frame should be selected - await expect(page.getByText("1 of 2 elements selected")).toBeVisible(); - - // The export button should still be enabled - const exportButton = page.getByRole("button", { - name: "Export", - exact: true, + // Frames exist, so the entry is offered even with nothing selected. + await expect(page.locator("#file-menu-export-frames")).toBeVisible(); + await page.locator("#file-menu-export-frames").click(); + await expect(page.getByText("Export as PDF")).toBeVisible(); }); - await expect(exportButton).toBeEnabled(); - }); - test("Export button is disabled when all frames are deselected", async ({ - page, - }) => { - const workspacePage = new WasmWorkspacePage(page); - await setupWorkspaceWithFrames(workspacePage); + await test.step("no selection lists every frame", async () => { + await expect(dialogRow("Board 1")).toBeVisible(); + await expect(dialogRow("Board 2")).toBeVisible(); + await expect(page.getByText("2 of 2 elements selected")).toBeVisible(); + await expect(exportButton(page)).toBeEnabled(); - // Select Frame 1 - await workspacePage.clickLeafLayer("Board 1"); + await cancelButton(page).click(); + await expect(page.getByText("Export as PDF")).not.toBeVisible(); + }); - // Open main menu and click export - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); - await page.locator("#file-menu-export-frames").click(); + await test.step("a selected frame is the only row", async () => { + await boardOne.click(); + await expect(boardOne).toHaveAttribute("aria-checked", "true"); - // Deselect the frame - await page.getByRole("button", { name: "Board 1" }).click(); + await openExportFramesDialog(page); + await expect(page.getByText("1 of 1 elements selected")).toBeVisible(); + await expect(dialogRow("Board 1")).toBeVisible(); + await expect(dialogRow("Board 2")).toHaveCount(0); - // Now 0 frames are selected - await expect(page.getByText("0 of 1 elements selected")).toBeVisible(); + await cancelButton(page).click(); + await expect(page.getByText("Export as PDF")).not.toBeVisible(); + }); - // // The export button should be disabled - await expect( - page.getByRole("button", { name: "Export", exact: true }), - ).toBeDisabled(); - }); + await test.step("deselecting one frame keeps the export enabled", async () => { + await boardOne.click(); + await boardTwo.click({ modifiers: ["Shift"] }); + await expect(boardOne).toHaveAttribute("aria-checked", "true"); + await expect(boardTwo).toHaveAttribute("aria-checked", "true"); - test("User can cancel the export modal", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await setupWorkspaceWithFrames(workspacePage); + await openExportFramesDialog(page); + await expect(page.getByText("2 of 2 elements selected")).toBeVisible(); - // Select Frame 1 - await workspacePage.clickLeafLayer("Board 1"); + await dialogRow("Board 1").click(); + await expect(page.getByText("1 of 2 elements selected")).toBeVisible(); + await expect(exportButton(page)).toBeEnabled(); - // Open main menu and click export - await page.getByRole("button", { name: "Main menu" }).click(); - await page.getByText("file").last().click(); - await page.locator("#file-menu-export-frames").click(); + await cancelButton(page).click(); + await expect(page.getByText("Export as PDF")).not.toBeVisible(); + }); - // Now only 1 frame should be selected - await expect(page.getByText("1 of 1 elements selected")).toBeVisible(); + await test.step("deselecting every frame disables the export", async () => { + await boardOne.click(); + await expect(boardOne).toHaveAttribute("aria-checked", "true"); + await expect(boardTwo).toHaveAttribute("aria-checked", "false"); - // Click cancel - await page.getByRole("button", { name: "Cancel" }).click(); + await openExportFramesDialog(page); + await dialogRow("Board 1").click(); + await expect(page.getByText("0 of 1 elements selected")).toBeVisible(); + await expect(exportButton(page)).toBeDisabled(); - // The modal should be hidden - await expect(page.getByText("0 of 1 elements selected")).not.toBeVisible(); + await cancelButton(page).click(); + await expect(page.getByText("Export as PDF")).not.toBeVisible(); + }); }); }); diff --git a/frontend/playwright/ui/specs/inspect-layout.spec.js b/frontend/playwright/ui/specs/inspect-layout.spec.js index 1d154d653a..289eae1119 100644 --- a/frontend/playwright/ui/specs/inspect-layout.spec.js +++ b/frontend/playwright/ui/specs/inspect-layout.spec.js @@ -5,12 +5,13 @@ test.beforeEach(async ({ page }) => { await WasmWorkspacePage.init(page); }); -// Fix for https://tree.taiga.io/project/penpot/issue/8593 -test("Bug 8593 - Grid layout three dots button visible on hover in grid editor", async ({ +// Fix for https://tree.taiga.io/project/penpot/issue/8593 and +// https://tree.taiga.io/project/penpot/issue/9042 +test("The grid layout editor shows the track options and its unit dropdown", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); + await workspacePage.setupEmptyFile(); await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-9042.json"); await workspacePage.mockRPC( "get-file-fragment?file-id=*&fragment-id=*", @@ -24,56 +25,42 @@ test("Bug 8593 - Grid layout three dots button visible on hover in grid editor", await workspacePage.clickLeafLayer("Board"); await workspacePage.expectSelectedLayer("Board"); - // Zoom in so tracks are wide enough (>= 110px) for the three-dots button to render. - // Board is 200x200 with 2 columns (100px each); zoom 2x makes them 200px. - await workspacePage.page.keyboard.press("Control+="); - await workspacePage.page.keyboard.press("Control+="); - await workspacePage.page.waitForTimeout(200); + // The options button is only rendered with a track of 110 px or more + // (`medium-size-limit` in grid_layout_editor.cljs) and the board tracks are + // 100 px wide, so two zoom steps take them over the limit. That is the + // condition the assertions below wait for, so no sleep is needed. + await page.keyboard.press("Control+="); + await page.keyboard.press("Control+="); - // Enter grid editing mode - const layoutContainer = workspacePage.page.getByTestId("inspect-layout"); - await layoutContainer.getByRole("button", { name: "Edit grid" }).click(); - await workspacePage.page.waitForTimeout(500); + // "Edit grid" toggles the editor, so it is clicked once for both cases. + await page + .getByTestId("inspect-layout") + .getByRole("button", { name: "Edit grid" }) + .click(); - // The three-dots button should always exist in the DOM when track is large enough. - // Previously it was only rendered when JS hover state was true (broken in WebKit/Safari). - // Now it is always rendered and shown/hidden via CSS :hover. - const gridEditorButton = workspacePage.page.getByTestId("grid-track-options-btn").first(); - await expect(gridEditorButton).toBeAttached(); + await test.step("hovering a track shows its options button", async () => { + // The button lives in the DOM and CSS :hover shows it, which works in every + // browser; before it was only rendered from the JS hover state (broken in + // WebKit). It is hidden with `opacity: 0`, and Playwright's `toBeVisible` + // ignores opacity, so the assertions read the computed value instead. + const gridEditorButton = page.getByTestId("grid-track-options-btn").first(); + await expect(gridEditorButton).toBeAttached(); + await expect(gridEditorButton).toHaveCSS("opacity", "0"); - // Hover over the track wrapper; CSS :hover should make the button visible. - // This approach works in all browsers including WebKit/Safari. - const gridEditorWrapper = workspacePage.page.getByTestId("grid-track-editor-wrapper").first(); - await gridEditorWrapper.hover(); - await expect(gridEditorButton).toBeVisible(); -}); - -// Fix for https://tree.taiga.io/project/penpot/issue/9042 -test("Bug 9042 - Measurement unit dropdowns for columns are cut off in grid layout edit mode", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-9042.json"); - await workspacePage.mockRPC( - "get-file-fragment?file-id=*&fragment-id=*", - "workspace/get-file-fragment-9042.json", - ); - - await workspacePage.goToWorkspace({ - fileId: "af2494d0-39ba-8184-8005-230696f6df5c", - pageId: "af2494d0-39ba-8184-8005-230696f6df5d", + const gridEditorWrapper = page + .getByTestId("grid-track-editor-wrapper") + .first(); + await gridEditorWrapper.hover(); + await expect(gridEditorButton).toHaveCSS("opacity", "1"); }); - await workspacePage.clickLeafLayer("Board"); - await workspacePage.expectSelectedLayer("Board"); - const layoutContainer = workspacePage.page.getByTestId("inspect-layout"); - await layoutContainer.getByRole("button", { name: "Edit grid" }).click(); - const rowsContainer = workspacePage.page.getByTestId("inspect-layout-rows"); - await rowsContainer.click(); + await test.step("the unit dropdown is not cut off", async () => { + const rowsContainer = page.getByTestId("inspect-layout-rows"); + await rowsContainer.click(); - await rowsContainer.getByText("FR").nth(2).click(); - await expect(rowsContainer.getByText("%")).toBeInViewport(); + await rowsContainer.getByText("FR").nth(2).click(); + await expect(rowsContainer.getByText("%")).toBeInViewport(); + }); }); test("[Taiga #9116] Copy CSS background color in the selected format in the INSPECT tab", async ({ @@ -152,7 +139,9 @@ test("[Taiga #10630] [INSPECT] Style assets not being displayed on info tab", as await workspacePage.clickAssets(); await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-library.json"); await workspacePage.openLibrariesModal(); - await workspacePage.librariesModal.getByRole("tab", { name: "Libraries" }).click(); + await workspacePage.librariesModal + .getByRole("tab", { name: "Libraries" }) + .click(); await workspacePage.clickLibrary("Testing library 1"); await workspacePage.closeLibrariesModal(); diff --git a/frontend/playwright/ui/specs/multiseleccion.spec.js b/frontend/playwright/ui/specs/multiseleccion.spec.js index ca0804f45f..d579400252 100644 --- a/frontend/playwright/ui/specs/multiseleccion.spec.js +++ b/frontend/playwright/ui/specs/multiseleccion.spec.js @@ -6,9 +6,11 @@ test.beforeEach(async ({ page }) => { await WasmWorkspacePage.mockConfigFlags(page, ["enable-feature-token-input"]); }); -test("Multiselection - check multiple values in measures", async ({ page }) => { +test("Multiselection shows the mixed value of every sidebar section", async ({ + page, +}) => { const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); + await workspacePage.setupEmptyFile(); await workspacePage.mockRPC( /get\-file\?/, "workspace/get-file-copy-paste.json", @@ -23,182 +25,129 @@ test("Multiselection - check multiple values in measures", async ({ page }) => { pageId: "870f9f10-87b5-8137-8005-934804124661", }); - // Select first shape (single selection first) - await page.getByTestId("layer-item").getByRole("button").first().click(); - await workspacePage.layers.getByTestId("layer-row").nth(0).click(); - - // === CHECK SINGLE SELECTION - ALL MEASURE FIELDS === const measuresSection = workspacePage.rightSidebar.getByRole("region", { name: "shape-measures-section", }); - await expect(measuresSection).toBeVisible(); - - // Width + const fillSection = workspacePage.rightSidebar.getByRole("region", { + name: "Fill section", + }); + const strokeSection = workspacePage.rightSidebar.getByRole("region", { + name: "Stroke section", + }); const widthInput = measuresSection.getByRole("textbox", { name: "Width", exact: true, }); - await expect(widthInput).toHaveValue("360"); - // Height - const heightInput = measuresSection.getByRole("textbox", { - name: "Height", - exact: true, - }); - await expect(heightInput).toHaveValue("53"); + // Rows are checkboxes bound to the selection (`aria-checked`), so reading + // that attribute replaces the 500 ms sleep of `clickLeafLayer`. A plain click + // selects one shape and Shift extends the selection to the range; both are + // asynchronous, so the helpers assert the whole state they need and not only + // the row they clicked: a plain click on an already selected row changes + // nothing visible on that row. + const rows = workspacePage.layers.getByTestId("layer-row"); + const firstRow = rows.nth(0); + const secondRow = rows.nth(1); - // X Position (using "X axis" title) - const xPosInput = measuresSection.getByRole("textbox", { - name: "X axis", - exact: true, - }); - await expect(xPosInput).toHaveValue("1094"); + // The rows flip before the sidebar re-renders for the new selection: the + // options panel is throttled and the selection arrives through a deferred + // render, so a value typed into that stale render is written to every shape + // of the previous selection. After a multi-selection the stale `Width` is + // still "Mixed", so this waits for the multi -> single transition only. A + // change from one single shape to another needs its own wait on the value it + // expects before editing. + const waitForSingleShape = async () => { + await expect(widthInput).not.toHaveAttribute("placeholder", "Mixed"); + }; - // Y Position (using "Y axis" title) - const yPosInput = measuresSection.getByRole("textbox", { - name: "Y axis", - exact: true, - }); - await expect(yPosInput).toHaveValue("856"); + const selectOnly = async (row, other) => { + await row.click(); + await expect(row).toBeChecked(); + await expect(other).not.toBeChecked(); + await waitForSingleShape(); + }; - // === CHECK MULTI-SELECTION - MIXED VALUES === - // Shift+click to add second layer to selection - await workspacePage.layers - .getByTestId("layer-row") - .nth(1) - .click({ modifiers: ["Shift"] }); + const selectBoth = async (first, second) => { + await first.click(); + await expect(first).toBeChecked(); + await expect(second).not.toBeChecked(); + await waitForSingleShape(); - // All measure fields should show "Mixed" placeholder when values differ - await expect(widthInput).toHaveAttribute("placeholder", "Mixed"); - await expect(heightInput).toHaveAttribute("placeholder", "Mixed"); - await expect(xPosInput).toHaveAttribute("placeholder", "Mixed"); - await expect(yPosInput).toHaveAttribute("placeholder", "Mixed"); -}); + await second.click({ modifiers: ["Shift"] }); + await expect(first).toBeChecked(); + await expect(second).toBeChecked(); + }; -test("Multiselection - check fill multiple values", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-copy-paste.json", - ); - await workspacePage.mockRPC( - "get-file-fragment?file-id=*&fragment-id=*", - "workspace/get-file-copy-paste-fragment.json", - ); + await test.step("measures", async () => { + await selectOnly(firstRow, secondRow); - await workspacePage.goToWorkspace({ - fileId: "870f9f10-87b5-8137-8005-934804124660", - pageId: "870f9f10-87b5-8137-8005-934804124661", + const heightInput = measuresSection.getByRole("textbox", { + name: "Height", + exact: true, + }); + const xPosInput = measuresSection.getByRole("textbox", { + name: "X axis", + exact: true, + }); + const yPosInput = measuresSection.getByRole("textbox", { + name: "Y axis", + exact: true, + }); + + await expect(widthInput).toHaveValue("360"); + await expect(heightInput).toHaveValue("53"); + await expect(xPosInput).toHaveValue("1094"); + await expect(yPosInput).toHaveValue("856"); + + // The two shapes differ in every measure, so all four go blank. + await selectBoth(firstRow, secondRow); + await expect(widthInput).toHaveAttribute("placeholder", "Mixed"); + await expect(heightInput).toHaveAttribute("placeholder", "Mixed"); + await expect(xPosInput).toHaveAttribute("placeholder", "Mixed"); + await expect(yPosInput).toHaveAttribute("placeholder", "Mixed"); }); - await page.getByTestId("layer-item").getByRole("button").first().click(); - await workspacePage.layers.getByTestId("layer-row").nth(0).click(); + await test.step("fill", async () => { + await selectOnly(firstRow, secondRow); - // Fill section - const fillSection = workspacePage.rightSidebar.getByRole("region", { - name: "Fill section", - }); - await expect(fillSection).toBeVisible(); + await expect(fillSection).toBeVisible(); + await expect(fillSection.getByText(/Mixed/i)).not.toBeVisible(); - // Single selection - fill color should be visible (not "Mixed") - await expect(fillSection.getByText(/Mixed/i)).not.toBeVisible(); - - // Multi-selection with Shift+click - await workspacePage.layers - .getByTestId("layer-row") - .nth(1) - .click({ modifiers: ["Shift"] }); - - // Should show "Mixed" for fills when shapes have different fill colors - await expect(fillSection.getByText("Mixed")).toBeVisible(); -}); - -test("Multiselection - check stroke multiple values", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-copy-paste.json", - ); - await workspacePage.mockRPC( - "get-file-fragment?file-id=*&fragment-id=*", - "workspace/get-file-copy-paste-fragment.json", - ); - - await workspacePage.goToWorkspace({ - fileId: "870f9f10-87b5-8137-8005-934804124660", - pageId: "870f9f10-87b5-8137-8005-934804124661", + await selectBoth(firstRow, secondRow); + await expect(fillSection.getByText("Mixed")).toBeVisible(); }); - await page.getByTestId("layer-item").getByRole("button").first().click(); - await workspacePage.layers.getByTestId("layer-row").nth(0).click(); + await test.step("stroke", async () => { + await selectOnly(firstRow, secondRow); - // Stroke section - const strokeSection = workspacePage.rightSidebar.getByRole("region", { - name: "Stroke section", - }); - await expect(strokeSection).toBeVisible(); + await expect(strokeSection).toBeVisible(); + await expect(strokeSection.getByText(/Mixed/i)).not.toBeVisible(); - // Single selection - stroke should be visible (not "Mixed") - await expect(strokeSection.getByText(/Mixed/i)).not.toBeVisible(); - - // Multi-selection - await workspacePage.layers - .getByTestId("layer-row") - .nth(1) - .click({ modifiers: ["Shift"] }); - - // Should show "Mixed" for strokes when shapes have different stroke colors - await expect(strokeSection.getByText("Mixed")).toBeVisible(); -}); - -test("Multiselection - check rotation multiple values", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(page); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-copy-paste.json", - ); - await workspacePage.mockRPC( - "get-file-fragment?file-id=*&fragment-id=*", - "workspace/get-file-copy-paste-fragment.json", - ); - - await workspacePage.goToWorkspace({ - fileId: "870f9f10-87b5-8137-8005-934804124660", - pageId: "870f9f10-87b5-8137-8005-934804124661", + await selectBoth(firstRow, secondRow); + await expect(strokeSection.getByText("Mixed")).toBeVisible(); }); - await page.getByTestId("layer-item").getByRole("button").first().click(); - await workspacePage.layers.getByTestId("layer-row").nth(1).click(); + // The rotation step mutates the document, so it runs last: no earlier step + // can see a shape whose rotation changed. + await test.step("rotation", async () => { + await selectOnly(secondRow, firstRow); - // Measures section contains rotation - const measuresSection = workspacePage.rightSidebar.getByRole("region", { - name: "shape-measures-section", + const rotationInput = measuresSection.getByRole("textbox", { + name: "Rotation", + exact: true, + }); + await expect(rotationInput).toBeVisible(); + + await rotationInput.fill("45"); + await page.keyboard.press("Enter"); + await expect(rotationInput).toHaveValue("45"); + + // Only one of the two rotated, so the grouped value differs. + await firstRow.click({ modifiers: ["Shift"] }); + await expect(firstRow).toBeChecked(); + await expect(secondRow).toBeChecked(); + await expect(rotationInput).toHaveAttribute("placeholder", "Mixed"); }); - await expect(measuresSection).toBeVisible(); - - // Rotation field exists - const rotationInput = measuresSection.getByRole("textbox", { - name: "Rotation", - exact: true, - }); - await expect(rotationInput).toBeVisible(); - - // Rotate that shape - await rotationInput.fill("45"); - await page.keyboard.press("Enter"); - await expect(rotationInput).toHaveValue("45"); // Rotation should be 45 - - // Multi-selection - await workspacePage.layers - .getByTestId("layer-row") - .nth(0) - .click({ modifiers: ["Shift"] }); - - // Rotation should show "Mixed" placeholder - await expect(rotationInput).toHaveAttribute("placeholder", "Mixed"); }); test("Multiselection of text and typographies", async ({ page }) => { @@ -249,9 +198,7 @@ test("Multiselection of text and typographies", async ({ page }) => { await plainTextLayer.click(); await expect(textSection).toBeVisible(); - await expect( - textSection.getByText("Mixed assets"), - ).not.toBeVisible(); + await expect(textSection.getByText("Mixed assets")).not.toBeVisible(); // Select two plain text layer with different font family await plainTextLayerTwo.click({ modifiers: ["Control"] }); @@ -273,14 +220,12 @@ test("Multiselection of text and typographies", async ({ page }) => { // Select token typography text layer await tokenTypographyTextLayerOne.click(); await expect(textSection).toBeVisible(); - await expect(textSection.getByLabel('token-typo-one')).toBeVisible(); + await expect(textSection.getByLabel("token-typo-one")).toBeVisible(); // Select two token typography text layer with different token typography await tokenTypographyTextLayerTwo.click({ modifiers: ["Control"] }); await expect(textSection).toBeVisible(); - await expect( - textSection.getByText('Mixed tokens'), - ).toBeVisible(); + await expect(textSection.getByText("Mixed tokens")).toBeVisible(); //Select plain text layer and typography text layer together await plainTextLayer.click(); diff --git a/frontend/playwright/ui/specs/sidebar-scroll.spec.js b/frontend/playwright/ui/specs/sidebar-scroll.spec.js index 1df484adfe..6f2cfe37ff 100644 --- a/frontend/playwright/ui/specs/sidebar-scroll.spec.js +++ b/frontend/playwright/ui/specs/sidebar-scroll.spec.js @@ -3,8 +3,10 @@ import { BaseWebSocketPage } from "../pages/BaseWebSocketPage"; import { WasmWorkspacePage } from "../pages/WasmWorkspacePage"; import { setupTokensFileRender, unfoldTokenType } from "./tokens/helpers"; -// Regression tests for issue #7440: scroll position in the left sidebar -// tabs (Layers / Assets / Tokens) must survive tab switches. +// Regression smoke for issue #7440: the scroll position of a left sidebar tab +// must survive a tab switch, and each tab keeps its own position. The store +// behind it (save per key, forget one key, restore and retry) is covered by +// `ui/sidebar_scroll_test.cljs`, so one test is enough here. // Ported from closed PR #7544 and adapted to the current implementation // (scroll store held in the sidebar + async restore on mount) and to the // current fixtures and page objects. @@ -66,30 +68,6 @@ async function expectScrollRestored(locator, expected) { .toBeGreaterThanOrEqual(expected - POSITION_TOLERANCE); } -test("Sidebar scroll position preserved when switching tabs", async ({ - page, -}) => { - const { tokensSidebar } = await setupTokensFileRender(page); - await unfoldTokenType(tokensSidebar, "color"); - - const containers = await scrollableContainers(page); - expect( - containers.length, - "Tokens tab should have a scrollable container", - ).toBeGreaterThan(0); - const scrollEl = containers[0]; - - await scrollToBottom(scrollEl); - const initialPos = await scrollEl.evaluate((el) => el.scrollTop); - expect(initialPos).toBeGreaterThan(0); - - await page.getByRole("tab", { name: "Assets" }).click(); - await page.getByRole("tab", { name: "Tokens" }).click(); - - const restored = (await scrollableContainers(page))[0]; - await expectScrollRestored(restored, initialPos); -}); - test("Sidebar maintains independent scroll positions per tab", async ({ page, }) => { @@ -106,6 +84,13 @@ test("Sidebar maintains independent scroll positions per tab", async ({ const tokensPos = await tokensContainers[0].evaluate((el) => el.scrollTop); expect(tokensPos).toBeGreaterThan(0); + // A hop through Assets must bring back the Tokens position: this round trip + // was its own test before the merge. + await page.getByRole("tab", { name: "Assets" }).click(); + await page.getByRole("tab", { name: "Tokens" }).click(); + const tokensAfterAssets = (await scrollableContainers(page))[0]; + await expectScrollRestored(tokensAfterAssets, tokensPos); + // Switch to Layers: fresh panel, must start at top (not contaminated // by the Tokens position saved under a different key). await page.getByRole("tab", { name: "Layers" }).click(); @@ -114,8 +99,6 @@ test("Sidebar maintains independent scroll positions per tab", async ({ const layersPos = await layersVisible[0].evaluate((el) => el.scrollTop); expect(layersPos).toBe(0); - // Back to Tokens: its own position must be restored, not Layers'. - // Back to Tokens: its own position must be restored, not Layers'. await page.getByRole("tab", { name: "Tokens" }).click(); const tokensRestored = (await scrollableContainers(page))[0]; diff --git a/frontend/playwright/ui/specs/stroke-to-path.spec.js b/frontend/playwright/ui/specs/stroke-to-path.spec.js index d3647e97d3..5258d512b0 100644 --- a/frontend/playwright/ui/specs/stroke-to-path.spec.js +++ b/frontend/playwright/ui/specs/stroke-to-path.spec.js @@ -10,71 +10,106 @@ test.beforeEach(async ({ page }) => { ]); }); +// Every one of the nine shapes in the fixture carries a stroke, one per +// geometry (rectangle, ellipse, path) and alignment (center, inner, outer). async function setupShapesWithStrokes(page) { const workspace = new WasmWorkspacePage(page); await workspace.setupEmptyFile(); await workspace.mockGetFile("workspace/shapes-with-strokes.json"); - await workspace.mockRPC( - "update-file?id=*", - "workspace/shapes-with-strokes.json", - ); await workspace.goToWorkspace(); await workspace.waitForFirstRender(); return workspace; } -async function strokeToPath(workspace, page, shapeName, expectedStrokeName) { - await workspace.clickLayers(); - await workspace.clickLeafLayer(shapeName, { button: "right" }); +async function strokeToPath(page, workspace, shapeName, strokeName) { + await expect(workspace.layerRow(shapeName)).toBeVisible(); + const rowsBefore = await workspace.layers.getByTestId("layer-row").count(); + + // The menu entry converts the current selection, and + // `show-shape-context-menu` selects the shape before opening the menu. The + // selection assertion attributes the conversion to this row instead of a + // stale selection or a "(stroke)" child. + await workspace.selectLayer(shapeName, { button: "right" }); + await page.getByText("Stroke to path").click(); - await expect( - workspace.layers.getByText(expectedStrokeName), - ).toBeVisible(); - await expect(workspace.layers.getByText(shapeName).first()).toBeVisible(); + await expect(workspace.layerRow(strokeName)).toBeVisible(); + await expect(workspace.layerRow(shapeName)).toBeVisible(); + await expect(workspace.layers.getByTestId("layer-row")).toHaveCount( + rowsBefore + 1, + ); + await expect(page.getByTestId("context-menu")).toBeHidden(); } -test("Stroke to path: rectangle with center stroke", async ({ page }) => { +test("Stroke to path converts each stroked shape into a path", async ({ + page, +}) => { const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "rectangle-center", "rectangle-center (stroke)"); -}); + await workspace.clickLayers(); -test("Stroke to path: rectangle with inner stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "rectangle-inner", "rectangle-inner (stroke)"); -}); + await test.step("rectangle with center stroke", async () => { + await strokeToPath( + page, + workspace, + "rectangle-center", + "rectangle-center (stroke)", + ); + }); -test("Stroke to path: rectangle with outer stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "rectangle-outer", "rectangle-outer (stroke)"); -}); + await test.step("rectangle with inner stroke", async () => { + await strokeToPath( + page, + workspace, + "rectangle-inner", + "rectangle-inner (stroke)", + ); + }); -test("Stroke to path: circle with center stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "ellipse-center", "ellipse-center (stroke)"); -}); + await test.step("rectangle with outer stroke", async () => { + await strokeToPath( + page, + workspace, + "rectangle-outer", + "rectangle-outer (stroke)", + ); + }); -test("Stroke to path: circle with inner stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "ellipse-inner", "ellipse-inner (stroke)"); -}); + await test.step("circle with center stroke", async () => { + await strokeToPath( + page, + workspace, + "ellipse-center", + "ellipse-center (stroke)", + ); + }); -test("Stroke to path: circle with outer stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "ellipse-outer", "ellipse-outer (stroke)"); -}); + await test.step("circle with inner stroke", async () => { + await strokeToPath( + page, + workspace, + "ellipse-inner", + "ellipse-inner (stroke)", + ); + }); -test("Stroke to path: path with center stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "path-center", "path-center (stroke)"); -}); + await test.step("circle with outer stroke", async () => { + await strokeToPath( + page, + workspace, + "ellipse-outer", + "ellipse-outer (stroke)", + ); + }); -test("Stroke to path: path with inner stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "path-inner", "path-inner (stroke)"); -}); + await test.step("path with center stroke", async () => { + await strokeToPath(page, workspace, "path-center", "path-center (stroke)"); + }); -test("Stroke to path: path with outer stroke", async ({ page }) => { - const workspace = await setupShapesWithStrokes(page); - await strokeToPath(workspace, page, "path-outer", "path-outer (stroke)"); + await test.step("path with inner stroke", async () => { + await strokeToPath(page, workspace, "path-inner", "path-inner (stroke)"); + }); + + await test.step("path with outer stroke", async () => { + await strokeToPath(page, workspace, "path-outer", "path-outer (stroke)"); + }); }); diff --git a/frontend/playwright/ui/specs/tokens/apply.spec.js b/frontend/playwright/ui/specs/tokens/apply.spec.js index 6be288b751..20cff94d44 100644 --- a/frontend/playwright/ui/specs/tokens/apply.spec.js +++ b/frontend/playwright/ui/specs/tokens/apply.spec.js @@ -606,226 +606,164 @@ test.describe("Tokens: Apply token", () => { }); }); - test("User applies dimension token to a shape on width and height", async ({ - page, - }) => { + test("User applies dimension tokens to a shape", async ({ page }) => { const { workspacePage, tokensSidebar, tokenContextMenuForToken } = await setupTokensFileRender(page); - // Unfolds dimensions on token panel - await page.getByRole("tab", { name: "Layers" }).click(); + // The Layers/Tokens round trip leaves the token panel unfolded for the + // next step; `unfoldTokenType` only clicks when the section is collapsed. + const selectShape = async (index) => { + await page.getByRole("tab", { name: "Layers" }).click(); + const row = workspacePage.layers.getByTestId("layer-row").nth(index); + await workspacePage.selectRow(row); + await page.getByRole("tab", { name: "Tokens" }).click(); + await unfoldTokenType(tokensSidebar, "dimensions"); + }; - await workspacePage.layers.getByTestId("layer-row").nth(1).click(); + await selectShape(1); - const tokensTabButton = page.getByRole("tab", { name: "Tokens" }); - await tokensTabButton.click(); - - await unfoldTokenType(tokensSidebar, "dimensions"); - - // Apply token to width and height token from token panel - await tokensSidebar.getByRole("button", { name: "dimension.sm" }).click(); - - // Check if measures sections is visible on right sidebar const measuresSection = page.getByRole("region", { name: "shape-measures-section", }); - await expect(measuresSection).toBeVisible(); - // Check if token pill is visible on design tab on right sidebar - const dimensionSMTokenPill = measuresSection.getByRole("button", { - name: "dimension.sm", + // A token-bound numeric input is replaced by a pill that shows the + // resolved value, so the pill text is where the effect of the token is + // observable: switching the token has to change it. + await test.step("width and height", async () => { + await tokensSidebar.getByRole("button", { name: "dimension.sm" }).click(); + + // A plain click applies the token to both measures. + const smPill = measuresSection.getByRole("button", { + name: "dimension.sm", + }); + await expect(smPill).toHaveCount(2); + const smValue = await smPill.nth(1).innerText(); + + await smPill.nth(1).click(); + await measuresSection + .getByRole("option", { name: "dimension.xl" }) + .click(); + + await expect(smPill).toHaveCount(1); + const xlPill = measuresSection.getByRole("button", { + name: "dimension.xl", + }); + await expect(xlPill).toBeVisible(); + await expect.poll(() => xlPill.innerText()).not.toBe(smValue); + + const detach = measuresSection.getByRole("button", { + name: "Detach token", + }); + await detach.nth(1).click(); + await expect(xlPill).not.toBeVisible(); + + // The other measure is still bound to sm; detaching it too leaves the + // shape with no dimension tokens, which is what the next step needs. + await expect(smPill).toHaveCount(1); + await detach.nth(0).click(); + await expect(smPill).not.toBeVisible(); }); - await expect(dimensionSMTokenPill).toHaveCount(2); - await dimensionSMTokenPill.nth(1).click(); - // Change token from dropdown - const dimensionTokenOptionXl = measuresSection.getByRole("option", { - name: "dimension.xl", + await test.step("x position", async () => { + await tokensSidebar + .getByRole("button", { name: "dimension.sm" }) + .click({ button: "right" }); + await tokenContextMenuForToken.getByText("AxisX").click(); + + const smPill = measuresSection.getByRole("button", { + name: "dimension.sm", + }); + await expect(smPill).toBeVisible(); + const smValue = await smPill.innerText(); + + await smPill.click(); + await measuresSection + .getByRole("option", { name: "dimension.xl" }) + .click(); + + await expect(smPill).not.toBeVisible(); + const xlPill = measuresSection.getByRole("button", { + name: "dimension.xl", + }); + await expect(xlPill).toBeVisible(); + await expect.poll(() => xlPill.innerText()).not.toBe(smValue); + + await measuresSection + .getByRole("button", { name: "Detach token" }) + .nth(0) + .click(); + await expect(xlPill).not.toBeVisible(); }); - await expect(dimensionTokenOptionXl).toBeVisible(); - await dimensionTokenOptionXl.click(); - await expect(dimensionSMTokenPill).toHaveCount(1); - const dimensionXLTokenPill = measuresSection.getByRole("button", { - name: "dimension.xl", + await test.step("y position", async () => { + await tokensSidebar + .getByRole("button", { name: "dimension.sm" }) + .click({ button: "right" }); + await tokenContextMenuForToken.getByText("Y", { exact: true }).click(); + + const smPill = measuresSection.getByRole("button", { + name: "dimension.sm", + }); + await expect(smPill).toBeVisible(); + const smValue = await smPill.innerText(); + + await smPill.click(); + await measuresSection + .getByRole("option", { name: "dimension.xl" }) + .click(); + + await expect(smPill).not.toBeVisible(); + const xlPill = measuresSection.getByRole("button", { + name: "dimension.xl", + }); + await expect(xlPill).toBeVisible(); + await expect.poll(() => xlPill.innerText()).not.toBe(smValue); + + await measuresSection + .getByRole("button", { name: "Detach token" }) + .nth(0) + .click(); + await expect(xlPill).not.toBeVisible(); }); - await expect(dimensionXLTokenPill).toBeVisible(); - // Detach token from design tab on right sidebar - const detachButton = measuresSection.getByRole("button", { - name: "Detach token", + await test.step("border radius", async () => { + // The radius case uses the third layer row, a rectangle no earlier step + // has touched. + await selectShape(2); + + const radiusSection = page.getByRole("region", { + name: "Border radius section", + }); + + await tokensSidebar + .getByRole("button", { name: "dimension.xs" }) + .click({ button: "right" }); + await tokenContextMenuForToken.getByText("Border radius").hover(); + await tokenContextMenuForToken.getByText("RadiusAll").click(); + + await expect(radiusSection).toBeVisible(); + const xsPill = radiusSection.getByRole("button", { + name: "dimension.xs", + }); + await expect(xsPill).toBeVisible(); + const xsValue = await xsPill.innerText(); + + await xsPill.click(); + await radiusSection.getByRole("option", { name: "dimension.xl" }).click(); + + await expect(xsPill).not.toBeVisible(); + const xlPill = radiusSection.getByRole("button", { + name: "dimension.xl", + }); + await expect(xlPill).toBeVisible(); + await expect.poll(() => xlPill.innerText()).not.toBe(xsValue); + + await radiusSection + .getByRole("button", { name: "Detach token" }) + .nth(0) + .click(); + await expect(xlPill).not.toBeVisible(); }); - await detachButton.nth(1).click(); - await expect(dimensionXLTokenPill).not.toBeVisible(); - }); - - test("User applies dimension token to a shape on x position", async ({ - page, - }) => { - const { workspacePage, tokensSidebar, tokenContextMenuForToken } = - await setupTokensFileRender(page); - - // Unfolds dimensions on token panel - await page.getByRole("tab", { name: "Layers" }).click(); - - await workspacePage.layers.getByTestId("layer-row").nth(1).click(); - - const tokensTabButton = page.getByRole("tab", { name: "Tokens" }); - await tokensTabButton.click(); - - await unfoldTokenType(tokensSidebar, "dimensions"); - - // Apply token to width and height token from token panel - await tokensSidebar - .getByRole("button", { name: "dimension.sm" }) - .click({ button: "right" }); - await tokenContextMenuForToken.getByText("AxisX").click(); - - // Check if measures sections is visible on right sidebar - const measuresSection = page.getByRole("region", { - name: "shape-measures-section", - }); - await expect(measuresSection).toBeVisible(); - - // Check if token pill is visible on design tab on right sidebar - const dimensionSMTokenPill = measuresSection.getByRole("button", { - name: "dimension.sm", - }); - await expect(dimensionSMTokenPill).toBeVisible(); - await dimensionSMTokenPill.click(); - - // Change token from dropdown - const dimensionTokenOptionXl = measuresSection.getByRole("option", { - name: "dimension.xl", - }); - await expect(dimensionTokenOptionXl).toBeVisible(); - await dimensionTokenOptionXl.click(); - - await expect(dimensionSMTokenPill).not.toBeVisible(); - const dimensionXLTokenPill = measuresSection.getByRole("button", { - name: "dimension.xl", - }); - await expect(dimensionXLTokenPill).toBeVisible(); - - // Detach token from design tab on right sidebar - const detachButton = measuresSection.getByRole("button", { - name: "Detach token", - }); - await detachButton.nth(0).click(); - await expect(dimensionXLTokenPill).not.toBeVisible(); - }); - - test("User applies dimension token to a shape on y position", async ({ - page, - }) => { - const { workspacePage, tokensSidebar, tokenContextMenuForToken } = - await setupTokensFileRender(page); - - // Unfolds dimensions on token panel - await page.getByRole("tab", { name: "Layers" }).click(); - - await workspacePage.layers.getByTestId("layer-row").nth(1).click(); - - const tokensTabButton = page.getByRole("tab", { name: "Tokens" }); - await tokensTabButton.click(); - - await unfoldTokenType(tokensSidebar, "dimensions"); - - // Apply token to width and height token from token panel - await tokensSidebar - .getByRole("button", { name: "dimension.sm" }) - .click({ button: "right" }); - await tokenContextMenuForToken.getByText("Y", { exact: true }).click(); - - // Check if measures sections is visible on right sidebar - const measuresSection = page.getByRole("region", { - name: "shape-measures-section", - }); - await expect(measuresSection).toBeVisible(); - - // Check if token pill is visible on design tab on right sidebar - const dimensionSMTokenPill = measuresSection.getByRole("button", { - name: "dimension.sm", - }); - await expect(dimensionSMTokenPill).toBeVisible(); - await dimensionSMTokenPill.click(); - - // Change token from dropdown - const dimensionTokenOptionXl = measuresSection.getByRole("option", { - name: "dimension.xl", - }); - await expect(dimensionTokenOptionXl).toBeVisible(); - await dimensionTokenOptionXl.click(); - - await expect(dimensionSMTokenPill).not.toBeVisible(); - const dimensionXLTokenPill = measuresSection.getByRole("button", { - name: "dimension.xl", - }); - await expect(dimensionXLTokenPill).toBeVisible(); - - // Detach token from design tab on right sidebar - const detachButton = measuresSection.getByRole("button", { - name: "Detach token", - }); - await detachButton.nth(0).click(); - await expect(dimensionXLTokenPill).not.toBeVisible(); - }); - - test("User applies dimension token to a shape border-radius", async ({ - page, - }) => { - const { workspacePage, tokensSidebar, tokenContextMenuForToken } = - await setupTokensFileRender(page); - - // Unfolds dimensions on token panel - await page.getByRole("tab", { name: "Layers" }).click(); - - await workspacePage.layers.getByTestId("layer-row").nth(2).click(); - - const tokensTabButton = page.getByRole("tab", { name: "Tokens" }); - await tokensTabButton.click(); - - await unfoldTokenType(tokensSidebar, "dimensions"); - - // Apply token to width and height token from token panel - await tokensSidebar - .getByRole("button", { name: "dimension.xs" }) - .click({ button: "right" }); - await tokenContextMenuForToken.getByText("Border radius").hover(); - await tokenContextMenuForToken.getByText("RadiusAll").click(); - - // Check if border radius sections is visible on right sidebar - const borderRadiusSection = page.getByRole("region", { - name: "Border radius section", - }); - await expect(borderRadiusSection).toBeVisible(); - - // Check if token pill is visible on design tab on right sidebar - const dimensionXSTokenPill = borderRadiusSection.getByRole("button", { - name: "dimension.xs", - }); - await expect(dimensionXSTokenPill).toBeVisible(); - await dimensionXSTokenPill.click(); - - // Change token from dropdown - const dimensionTokenOptionXl = borderRadiusSection.getByRole("option", { - name: "dimension.xl", - }); - await expect(dimensionTokenOptionXl).toBeVisible(); - await dimensionTokenOptionXl.click(); - - await expect(dimensionXSTokenPill).not.toBeVisible(); - const dimensionXLTokenPill = borderRadiusSection.getByRole("button", { - name: "dimension.xl", - }); - await expect(dimensionXLTokenPill).toBeVisible(); - - // Detach token from design tab on right sidebar - const detachButton = borderRadiusSection.getByRole("button", { - name: "Detach token", - }); - await detachButton.nth(0).click(); - await expect(dimensionXLTokenPill).not.toBeVisible(); }); test("User applies stroke width token to a shape", async ({ page }) => { diff --git a/frontend/playwright/ui/specs/toolbar.spec.js b/frontend/playwright/ui/specs/toolbar.spec.js index 2bd9cef5c4..16e8851fa2 100644 --- a/frontend/playwright/ui/specs/toolbar.spec.js +++ b/frontend/playwright/ui/specs/toolbar.spec.js @@ -1,88 +1,124 @@ import { test, expect } from "@playwright/test"; import { WasmWorkspacePage } from "../pages/WasmWorkspacePage"; -import WorkspacePage from "../pages/WorkspacePage"; -test.beforeEach(async ({ page }) => { - await WasmWorkspacePage.init(page); -}); +// A finished path stays in edition mode, and the path edition bar replaces the +// drawing toolbar while it is active (`toolbar-hidden-ref` in top_toolbar), so +// the step that leaves a path behind exits it before the next tool is +// reachable. +async function exitPathEdition(page, workspace) { + await page.keyboard.press("Escape"); + await expect(workspace.boardButton).toBeVisible(); +} -const expectLayerNamed = async (workspacePage, name) => { - await expect(workspacePage.layers.getByText(name).last()).toBeVisible(); -}; - -test("User creates a frame with the toolbar frame tool", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); - - await workspacePage.selectToolbarTool(workspacePage, "Board (B)"); - await workspacePage.clickWithDragViewportAt(100, 100, 180, 120); - await expectLayerNamed(workspacePage, "Board"); -}); - -test("User creates a rectangle with the toolbar rect tool", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); - - await workspacePage.selectToolbarTool(workspacePage, "Rectangle (R)"); - await workspacePage.clickWithDragViewportAt(350, 100, 120, 80); - await expectLayerNamed(workspacePage, "Rectangle"); -}); - -test("User creates an ellipse from the shapes flyout", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); - - await workspacePage.selectToolFromFlyout(workspacePage, { - triggerToolName: "Rectangle (R)", - targetToolName: "Ellipse (E)", +// The shape tools run under the WASM renderer: it is the renderer the app +// ships, and the SVG path would let a WASM-only regression in drawing pass. +test.describe("WASM renderer", () => { + test.beforeEach(async ({ page }) => { + await WasmWorkspacePage.init(page); }); - await workspacePage.clickWithDragViewportAt(520, 100, 100, 100); - await expectLayerNamed(workspacePage, "Ellipse"); -}); -test("User creates a text shape with the toolbar text tool", async ({ - page, -}) => { - const workspacePage = new WorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); + test("Each toolbar shape tool creates its shape", async ({ page }) => { + const workspace = new WasmWorkspacePage(page); + await workspace.setupEmptyFile(); + await workspace.goToWorkspace(); + await workspace.waitForFirstRender(); - await workspacePage.selectToolbarTool(workspacePage, "Text (T)"); - await workspacePage.clickAndMove(120, 320, 300, 380); - await workspacePage.waitForSelectedShapeName("Text"); - await workspacePage.page.keyboard.type("toolbar test"); - await workspacePage.page.keyboard.press("Escape"); - await expectLayerNamed(workspacePage, "Text"); -}); + const rows = workspace.layers.getByTestId("layer-row"); -test.skip("User creates a path with the toolbar path tool", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); + await test.step("frame with the toolbar frame tool", async () => { + const before = await rows.count(); - await workspacePage.selectToolbarTool(workspacePage, "Path (P)"); - await workspacePage.clickAndMove(120, 320, 300, 380); - await workspacePage.page.keyboard.press("Enter"); - await expectLayerNamed(workspacePage, "Path"); -}); + await workspace.selectToolbarTool(workspace, "Board (B)"); + await workspace.clickWithDragViewportAt(100, 100, 180, 120); -test("User creates a curve from the path flyout", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.goToWorkspace(); + await expect(workspace.layerRow("Board")).toBeVisible(); + await expect(rows).toHaveCount(before + 1); + }); - await workspacePage.selectToolFromFlyout(workspacePage, { - triggerToolName: "Path (P)", - targetToolName: "Curve (Shift+C)", + await test.step("rectangle with the toolbar rect tool", async () => { + const before = await rows.count(); + + await workspace.selectToolbarTool(workspace, "Rectangle (R)"); + await workspace.clickWithDragViewportAt(350, 100, 120, 80); + + await expect(workspace.layerRow("Rectangle")).toBeVisible(); + await expect(rows).toHaveCount(before + 1); + }); + + await test.step("ellipse from the shapes flyout", async () => { + const before = await rows.count(); + + await workspace.selectToolFromFlyout(workspace, { + triggerToolName: "Rectangle (R)", + targetToolName: "Ellipse (E)", + }); + await workspace.clickWithDragViewportAt(520, 100, 100, 100); + + await expect(workspace.layerRow("Ellipse")).toBeVisible(); + await expect(rows).toHaveCount(before + 1); + }); + + await test.step("path with the toolbar path tool", async () => { + const before = await rows.count(); + + await workspace.selectToolbarTool(workspace, "Path (P)"); + // Each click places one node (`start-path-from-point` and + // `make-drag-stream`), and Enter finishes the path through the + // `:start-editing` binding of the path shortcuts. + await workspace.clickAt(120, 320); + await workspace.clickAt(300, 380); + await page.keyboard.press("Enter"); + + await expect(workspace.layerRow("Path")).toBeVisible(); + await expect(rows).toHaveCount(before + 1); + await exitPathEdition(page, workspace); + }); + + // The curve keeps its tool armed after drawing (`handle-finish-drawing`), + // so it goes last: the next tool click would not take effect. + await test.step("curve from the path flyout", async () => { + const before = await rows.count(); + const pathsBefore = await workspace.layerRows("Path").count(); + + await workspace.selectToolFromFlyout(workspace, { + triggerToolName: "Path (P)", + targetToolName: "Curve (Shift+C)", + }); + await workspace.clickAndMove(520, 320, 620, 380); + await page.keyboard.press("Enter"); + + // The path tool's row already exists; the curve must add one more with + // the same name, so compare against its own baseline. + await expect(workspace.layerRows("Path")).toHaveCount(pathsBefore + 1); + await expect(rows).toHaveCount(before + 1); + }); + }); +}); + +// Text runs under WASM too: `WasmWorkspacePage` enables the v2 text editor, +// and the toolbar gesture (drag, then type) is the same one the SVG run used. +test.describe("Text tool", () => { + test.beforeEach(async ({ page }) => { + await WasmWorkspacePage.init(page); + }); + + test("The text tool creates a text layer", async ({ page }) => { + const workspace = new WasmWorkspacePage(page); + await workspace.setupEmptyFile(); + await workspace.goToWorkspace(); + await workspace.waitForFirstRender(); + + const rows = workspace.layers.getByTestId("layer-row"); + const before = await rows.count(); + + await workspace.selectToolbarTool(workspace, "Text (T)"); + await workspace.clickAndMove(120, 480, 420, 540); + await workspace.waitForSelectedShapeName("Text"); + await page.keyboard.type("toolbar test"); + await page.keyboard.press("Escape"); + + // Typing renames a brand-new text layer after its content. + await expect(workspace.layerRow("toolbar test")).toBeVisible(); + await expect(rows).toHaveCount(before + 1); }); - await workspacePage.clickAndMove(120, 320, 300, 380); - await workspacePage.page.keyboard.press("Enter"); - await expectLayerNamed(workspacePage, "Path"); }); diff --git a/frontend/playwright/ui/specs/variants.spec.js b/frontend/playwright/ui/specs/variants.spec.js index d9dbb687e5..f4d3d55a59 100644 --- a/frontend/playwright/ui/specs/variants.spec.js +++ b/frontend/playwright/ui/specs/variants.spec.js @@ -14,13 +14,11 @@ test.afterEach(async ({ context }) => { await context.clearPermissions(); }); +// One `setupEmptyFile` only: a second call registered `get-team?id=*` again and, +// because the route added last wins, it cancelled the variants team fixture +// that used to sit between the two calls. These tests have always run with the +// default team, so that fixture is gone and the effective mocks stay the same. const setupVariantsFile = async (workspacePage) => { - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - "get-team?id=*", - "workspace/get-team-variants.json", - ); - await workspacePage.setupEmptyFile(); await workspacePage.mockRPC( /get\-file\?/, @@ -37,21 +35,30 @@ const setupVariantsFile = async (workspacePage) => { }); }; +// A shape is only a component once its layer row shows the component icon; this +// is the condition the fixed three seconds used to stand in for. +const waitForComponentIcon = async (workspacePage, name) => { + await expect( + workspacePage.layers + .getByTestId("layer-row") + .filter({ hasText: name }) + .getByTestId("icon-component"), + ).toBeVisible(); +}; + const setupVariantsFileWithVariant = async (workspacePage) => { await setupVariantsFile(workspacePage); - await workspacePage.clickLeafLayer("Rectangle"); + await workspacePage.selectLayer("Rectangle"); await workspacePage.page.keyboard.press("ControlOrMeta+k"); - await workspacePage.page.waitForTimeout(500); + await waitForComponentIcon(workspacePage, "Rectangle"); await workspacePage.page.keyboard.press("ControlOrMeta+k"); - await workspacePage.page.waitForTimeout(500); - // We wait until layer-row starts looking like it an component - await workspacePage.page - .getByTestId("layer-row") - .filter({ hasText: "Rectangle" }) - .getByTestId("icon-component") - .waitFor(); + // The second shortcut turns the main component into a variant container and + // its children into variants; wait for those rows instead of a fixed delay. + const variant = await findVariant(workspacePage, 0); + await expect(variant.variant1).toBeVisible(); + await expect(variant.variant2).toBeVisible(); }; const findVariant = async (workspacePage, index) => { @@ -106,6 +113,17 @@ const findVariantNoWait = (workspacePage, index) => { }; }; +// A container keeps its children rows in the tree only while it is expanded, and +// clicking the toggle of an already expanded container collapses it: a duplicate +// or a paste can inherit the expanded state, so check it before clicking. +const expandContainer = async (container) => { + const toggle = container.getByTestId("toggle-content"); + if ((await toggle.getAttribute("aria-expanded")) !== "true") { + await toggle.click(); + } + await expect(toggle).toHaveAttribute("aria-expanded", "true"); +}; + const validateVariant = async (variant) => { //The variant container exists and is visible await expect(variant.container).toBeVisible(); @@ -137,7 +155,7 @@ test("User creates a variant", async ({ page }) => { await validateVariant(variant); // Extra validators - await variant.container.click(); + await workspacePage.selectRow(variant.container); const variants = await workspacePage.layers .getByTestId("layer-row") @@ -159,17 +177,28 @@ test("User duplicates a variant container", async ({ page }) => { const variant = await findVariant(workspacePage, 0); - // Select the variant container - await variant.container.click(); + // Select the variant container; Ctrl+D duplicates whatever is selected. + await workspacePage.selectRow(variant.container); //Duplicate the variant container await workspacePage.page.keyboard.press("ControlOrMeta+d"); - const variant_original = await findVariant(workspacePage, 1); // On duplicate, the new item is the first + // Assert the second container appears before building the locators, so a slow + // duplication fails here with a count, not with a long wait inside a helper. + const containerRows = workspacePage.layers + .getByTestId("layer-row") + .filter({ hasText: "Rectangle" }) + .filter({ has: page.getByTestId("icon-component") }); + await expect(containerRows).toHaveCount(2); + + // The copy is inserted above the original: index 0 is the duplicate and index + // 1 is the original. + const variant_original = await findVariant(workspacePage, 1); const variant_duplicate = await findVariant(workspacePage, 0); - // Expand the layers - await variant_duplicate.container.getByRole("button").first().click(); + // Expand the layers; the original may have lost its expansion in the meantime. + await expandContainer(variant_duplicate.container); + await expandContainer(variant_original.container); // The variants are valid await validateVariant(variant_original); @@ -187,26 +216,29 @@ test("User copy paste a variant container", async ({ page }) => { const variant = findVariantNoWait(workspacePage, 0); - // Copy the variant container - await workspacePage.clickLeafLayer("Rectangle"); + // Copy the variant container itself. `clickLeafLayer` matches the text as a + // substring and clicks the first match, and this tree also holds the shapes + // named Rectangle inside the variants, so it can select the wrong one. + await workspacePage.selectRow(variant.container); await workspacePage.copy("keyboard"); - // Paste the variant container - await workspacePage.clickAt(400, 400); + // Deselect and place the pointer without clicking: a click here could select a + // shape and send the paste inside it. + await page.keyboard.press("Escape"); + await workspacePage.viewport.hover({ position: { x: 400, y: 400 } }); await workspacePage.paste("keyboard"); const variants = workspacePage.layers.getByText("Rectangle"); await expect(variants).toHaveCount(2); + // As with the duplicate, the pasted container is inserted above the original. const variantDuplicate = findVariantNoWait(workspacePage, 0); const variantOriginal = findVariantNoWait(workspacePage, 1); // Expand the layers await variantDuplicate.container.waitFor(); - await variantDuplicate.container.locator("button").first().click(); + await expandContainer(variantDuplicate.container); - // // The variants are valid - // // await variantOriginal.container.waitFor(); await validateVariant(variantOriginal); await validateVariant(variantDuplicate); }); @@ -217,21 +249,22 @@ test("User cut paste a variant container", async ({ page }) => { const variant = await findVariant(workspacePage, 0); - // Select the variant container - await variant.container.click(); + // Select the variant container; Ctrl+X cuts whatever is selected. + await workspacePage.selectRow(variant.container); //Cut the variant container await workspacePage.cut("keyboard"); - //Paste the variant container - await workspacePage.clickAt(500, 500); + // Deselect and place the pointer in empty canvas without clicking, so the paste + // cannot land inside a shape that the click selected. + await page.keyboard.press("Escape"); + await workspacePage.viewport.hover({ position: { x: 500, y: 500 } }); await workspacePage.paste("keyboard"); - await workspacePage.page.waitForTimeout(500); const variantPasted = await findVariant(workspacePage, 0); // Expand the layers - await workspacePage.clickToggableLayer("Rectangle"); + await expandContainer(variantPasted.container); // The variants are valid await validateVariant(variantPasted); @@ -289,13 +322,14 @@ test("User copy paste a variant", async ({ page }) => { const variant = await findVariant(workspacePage, 0); // Select the variant1 - await variant.variant1.click(); + await workspacePage.selectRow(variant.variant1); // Copy the variant await workspacePage.copy("keyboard"); - // Paste the variant - await workspacePage.clickAt(500, 500); + // Deselect and place the pointer in empty canvas, for the same reason as above. + await page.keyboard.press("Escape"); + await workspacePage.viewport.hover({ position: { x: 500, y: 500 } }); await workspacePage.paste("keyboard"); const copy = await workspacePage.layers @@ -314,13 +348,15 @@ test("User cut paste a variant outside the container", async ({ page }) => { const variant = await findVariant(workspacePage, 0); // Select the variant1 - await variant.variant1.click(); + await workspacePage.selectRow(variant.variant1); //Cut the variant await workspacePage.cut("keyboard"); - //Paste the variant - await workspacePage.clickAt(500, 500); + // Deselect and place the pointer in empty canvas, so the paste does not land + // inside a shape that the click could have selected. + await page.keyboard.press("Escape"); + await workspacePage.viewport.hover({ position: { x: 500, y: 500 } }); await workspacePage.paste("keyboard"); const component = await workspacePage.layers @@ -367,7 +403,7 @@ test("User cut paste a component inside a variant", async ({ page }) => { await workspacePage.cut("keyboard"); //Paste the component inside the variant - await variant.container.click(); + await workspacePage.selectRow(variant.container); await workspacePage.paste("keyboard"); const variant3 = await workspacePage.layers @@ -380,87 +416,58 @@ test("User cut paste a component inside a variant", async ({ page }) => { await expect(variant3).toBeVisible(); }); -test("User cut paste a component with path inside a variant", async ({ - page, -}) => { +test("User takes a component with a path into a variant", async ({ page }) => { const workspacePage = new WasmWorkspacePage(page); await setupVariantsFileWithVariant(workspacePage); const variant = await findVariant(workspacePage, 0); - // Create a component - await workspacePage.selectToolFromFlyout(workspacePage, { - triggerToolName: "Rectangle (R)", - targetToolName: "Ellipse (E)", + const variantNamed = (name) => + workspacePage.layers + .getByTestId("layer-row") + .filter({ has: workspacePage.page.getByText(name) }) + .filter({ has: workspacePage.page.getByTestId("icon-variant") }); + + const createNamedComponent = async () => { + await workspacePage.selectToolFromFlyout(workspacePage, { + triggerToolName: "Rectangle (R)", + targetToolName: "Ellipse (E)", + }); + await workspacePage.clickWithDragViewportAt(500, 500, 20, 20); + await workspacePage.clickLeafLayer("Ellipse"); + await workspacePage.page.keyboard.press("ControlOrMeta+k"); + await waitForComponentIcon(workspacePage, "Ellipse"); + + await workspacePage.layers.getByText("Ellipse").dblclick(); + await workspacePage.page + .getByTestId("layer-item") + .getByRole("textbox") + .pressSequentially("button / hover"); + await workspacePage.page.keyboard.press("Enter"); + await expect( + workspacePage.layers.getByText("button / hover"), + ).toBeVisible(); + }; + + // The drag moves the component away from where it was created, so the second + // one can be drawn at the same coordinates. The row count is what proves each + // step put its own component into the container. + await test.step("drag and drop", async () => { + await createNamedComponent(); + await workspacePage.clickWithDragViewportAt(510, 510, 200, 0); + await expect(variantNamed("button, hover")).toHaveCount(1); }); - await workspacePage.clickWithDragViewportAt(500, 500, 20, 20); - await workspacePage.clickLeafLayer("Ellipse"); - await workspacePage.page.keyboard.press("ControlOrMeta+k"); - await workspacePage.page.waitForTimeout(3000); - // Rename the component - await workspacePage.layers.getByText("Ellipse").dblclick(); - await workspacePage.page - .getByTestId("layer-item") - .getByRole("textbox") - .pressSequentially("button / hover"); - await workspacePage.page.keyboard.press("Enter"); - await workspacePage.page.waitForTimeout(3000); + await test.step("cut and paste", async () => { + const before = await variantNamed("button, hover").count(); - // Cut the component - await workspacePage.cut("keyboard"); + await createNamedComponent(); + await workspacePage.cut("keyboard"); + await workspacePage.selectRow(variant.container); + await workspacePage.paste("keyboard"); - // Paste the component inside the variant - await variant.container.click(); - await workspacePage.paste("keyboard"); - - const variant3 = await workspacePage.layers - .getByTestId("layer-row") - .filter({ has: workspacePage.page.getByText("button, hover") }) - .filter({ has: workspacePage.page.getByTestId("icon-variant") }) - .first(); - - //The new variant exists and is visible - await expect(variant3).toBeVisible(); -}); - -test("User drag and drop a component with path inside a variant", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await setupVariantsFileWithVariant(workspacePage); - - const variant = findVariantNoWait(workspacePage, 0); - - //Create a component - await workspacePage.selectToolFromFlyout(workspacePage, { - triggerToolName: "Rectangle (R)", - targetToolName: "Ellipse (E)", + await expect(variantNamed("button, hover")).toHaveCount(before + 1); }); - await workspacePage.clickWithDragViewportAt(500, 500, 20, 20); - await workspacePage.clickLeafLayer("Ellipse"); - await workspacePage.page.keyboard.press("ControlOrMeta+k"); - await workspacePage.page.waitForTimeout(3000); - - //Rename the component - await workspacePage.layers.getByText("Ellipse").dblclick(); - await workspacePage.page - .getByTestId("layer-item") - .getByRole("textbox") - .pressSequentially("button / hover"); - await workspacePage.page.keyboard.press("Enter"); - - //Drag and drop the component the component - await workspacePage.clickWithDragViewportAt(510, 510, 200, 0); - - const variant3 = await workspacePage.layers - .getByTestId("layer-row") - .filter({ has: workspacePage.page.getByText("button, hover") }) - .filter({ has: workspacePage.page.getByTestId("icon-variant") }) - .first(); - - //The new variant exists and is visible - await expect(variant3).toBeVisible(); }); test("User cut paste a variant into another container", async ({ page }) => { diff --git a/frontend/playwright/ui/specs/workspace.spec.js b/frontend/playwright/ui/specs/workspace.spec.js index 051530b877..8d45cd47fd 100644 --- a/frontend/playwright/ui/specs/workspace.spec.js +++ b/frontend/playwright/ui/specs/workspace.spec.js @@ -1,6 +1,10 @@ import { test, expect } from "@playwright/test"; import { WasmWorkspacePage } from "../pages/WasmWorkspacePage"; -import { presenceFixture, joinFixture2, joinFixture3 } from "../../data/workspace/ws-notifications"; +import { + presenceFixture, + joinFixture2, + joinFixture3, +} from "../../data/workspace/ws-notifications"; test.beforeEach(async ({ page }) => { await WasmWorkspacePage.init(page); @@ -26,40 +30,36 @@ test("User opens a file with a bad page id", async ({ page }) => { await expect(workspacePage.pageName).toHaveText("Page 1"); }); -test("User receives presence notifications updates in the workspace", async ({ - page, -}) => { +// Presence: the list shows one avatar per person in the file and, when the +// three slots fill up, the remaining people collapse into a "+N" counter +// (BUG 13058). +test("The presence list shows the people in the file", async ({ page }) => { const workspacePage = new WasmWorkspacePage(page); await workspacePage.setupEmptyFile(); await workspacePage.goToWorkspace(); - await workspacePage.sendPresenceMessage(presenceFixture); - await expect( - page.getByTestId("active-users-list").getByAltText("Princesa Leia"), - ).toHaveCount(2); -}); + const avatar = (name) => + page.getByTestId("active-users-list").getByAltText(name); -test("BUG 13058 - Presence list shows up to 3 user avatars", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); + // The user of the session is always there, so the fixture adds the second. + await test.step("another person appears in the list", async () => { + await workspacePage.sendPresenceMessage(presenceFixture); + await expect(avatar("Princesa Leia")).toHaveCount(2); + }); - await workspacePage.goToWorkspace(); - await workspacePage.sendPresenceMessage(presenceFixture); - await workspacePage.sendPresenceMessage(joinFixture2); + await test.step("a third person fills the three avatars", async () => { + await workspacePage.sendPresenceMessage(joinFixture2); + await expect(avatar("Princesa Leia")).toHaveCount(3); + }); - await expect( - page.getByTestId("active-users-list").getByAltText("Princesa Leia"), - ).toHaveCount(3); - - await workspacePage.sendPresenceMessage(joinFixture3); - await expect( - page.getByTestId("active-users-list").getByAltText("Princesa Leia"), - ).toHaveCount(2); - - await expect(page.getByTestId("active-users-list").getByText("+2")).toBeVisible(); + await test.step("the fourth person goes behind the counter", async () => { + await workspacePage.sendPresenceMessage(joinFixture3); + await expect(avatar("Princesa Leia")).toHaveCount(2); + await expect( + page.getByTestId("active-users-list").getByText("+2"), + ).toBeVisible(); + }); }); test("User draws a rect", async ({ page }) => { @@ -158,38 +158,7 @@ test("Selection size badge shows unrotated dimensions for rotated single selecti await expect(badgeText).toHaveText("126 x 134"); }); -test("Selection size badge shows dimensions for path shapes", async ({ page }) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - "update-file?id=*", - "workspace/update-file-empty.json", - ); - - await workspacePage.goToWorkspace(); - - // Workaround: hover viewport first to avoid nil mouse position crash - await workspacePage.viewport.hover(); - - // Draw a path with two segments; a single straight segment places - // the size badge along the line instead - await workspacePage.pathButton.click(); - await workspacePage.clickAt(779, 163); - await workspacePage.clickAt(951, 258); - await workspacePage.clickAt(1050, 163); - - // Finish drawing (commits path, path enters edition mode) - await page.keyboard.press("Escape"); - - // Exit edition mode (path stays selected, badge becomes visible) - await page.keyboard.press("Escape"); - - const badgeText = page.locator(".selection-size-badge text"); - await expect(badgeText).toBeVisible(); - await expect(badgeText).toHaveText(/\d+\.?\d* x \d+\.?\d*/); -}); - -test("Selection size badge runs along straight line paths", async ({ +test("Selection size badge measures paths and straight lines", async ({ page, }) => { const workspacePage = new WasmWorkspacePage(page); @@ -204,28 +173,46 @@ test("Selection size badge runs along straight line paths", async ({ // Workaround: hover viewport first to avoid nil mouse position crash await workspacePage.viewport.hover(); - // Draw a path with a single straight segment, going down to the right - await workspacePage.pathButton.click(); - await workspacePage.clickAt(779, 163); - await workspacePage.clickAt(951, 258); - - // Finish drawing (commits path, path enters edition mode) - await page.keyboard.press("Escape"); - - // Exit edition mode (path stays selected) - await page.keyboard.press("Escape"); - - await expect(page.locator(".line-controls")).toBeVisible(); - - // A straight line shows its length, with two decimals at most const badge = page.locator(".selection-size-badge"); - await expect(badge.locator("text")).toHaveText(/^\d+(\.\d{1,2})?$/); - // The badge follows the line angle, about 29 degrees - const transform = await badge.getAttribute("transform"); - const rotation = Number(transform.match(/rotate\(([^)]+)\)/)[1]); - expect(rotation).toBeGreaterThan(20); - expect(rotation).toBeLessThan(40); + const drawPath = async (points) => { + await workspacePage.pathButton.click(); + for (const [x, y] of points) { + await workspacePage.clickAt(x, y); + } + // Finish drawing (commits path, path enters edition mode) + await page.keyboard.press("Escape"); + // Exit edition mode (path stays selected, badge becomes visible) + await page.keyboard.press("Escape"); + }; + + await test.step("a path with two segments shows its box", async () => { + await drawPath([ + [779, 163], + [951, 258], + [1050, 163], + ]); + + await expect(badge.locator("text")).toBeVisible(); + await expect(badge.locator("text")).toHaveText(/\d+\.?\d* x \d+\.?\d*/); + }); + + // The line is drawn away from the first path so its clicks cannot land on it, + // and with the same slope, so the rotation bounds below still apply. + await test.step("a straight line shows its length and its angle", async () => { + await drawPath([ + [300, 400], + [472, 495], + ]); + + await expect(page.locator(".line-controls")).toBeVisible(); + await expect(badge.locator("text")).toHaveText(/^\d+(\.\d{1,2})?$/); + + const transform = await badge.getAttribute("transform"); + const rotation = Number(transform.match(/rotate\(([^)]+)\)/)[1]); + expect(rotation).toBeGreaterThan(20); + expect(rotation).toBeLessThan(40); + }); }); test("User makes a group", async ({ page }) => { @@ -290,7 +277,6 @@ test("Bug 7525 - User moves a scrollbar and no selection rectangle appears", asy // Grab scrollbar and move const { x, y } = await horizontalScrollbar.boundingBox(); - await page.waitForTimeout(100); await workspacePage.viewport.hover({ position: { x: x, y: y + 5 } }); await page.mouse.down(); await workspacePage.viewport.hover({ position: { x: x - 130, y: y - 95 } }); @@ -298,52 +284,6 @@ test("Bug 7525 - User moves a scrollbar and no selection rectangle appears", asy await expect(workspacePage.selectionRect).not.toBeInViewport(); }); -test("User adds a library and its automatically selected in the color palette", async ({ - page, -}) => { - const workspacePage = new WasmWorkspacePage(page); - await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC( - "link-file-to-library", - "workspace/link-file-to-library.json", - ); - await workspacePage.mockRPC( - "unlink-file-from-library", - "workspace/unlink-file-from-library.json", - ); - await workspacePage.mockRPC( - "get-team-shared-files?team-id=*", - "workspace/get-team-shared-libraries-non-empty.json", - ); - - await workspacePage.goToWorkspace(); - - // Add Testing library 1 - await workspacePage.clickColorPalette(); - await workspacePage.clickAssets(); - // Now the get-file call should return a library - await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-library.json"); - await workspacePage.openLibrariesModal(); - await workspacePage.librariesModal.getByRole("tab", { name: "Libraries" }).click(); - await workspacePage.clickLibrary("Testing library 1"); - await workspacePage.closeLibrariesModal(); - - await expect( - workspacePage.palette.getByRole("button", { name: "test-color-187cd5" }), - ).toBeVisible(); - - // Remove Testing library 1 - await workspacePage.openLibrariesModal(); - await workspacePage.clickLibrary("Testing library 1"); - await workspacePage.closeLibrariesModal(); - - await expect( - workspacePage.palette.getByText( - "There are no color styles in your library yet", - ), - ).toBeVisible(); -}); - test("Bug 10179 - Drag & drop doesn't add colors to the Recent Colors palette", async ({ page, }) => { @@ -489,11 +429,23 @@ test("Copy/paste properties", async ({ page, context }) => { // Access to the read/write clipboard necesary for this functionality await context.grantPermissions(["clipboard-read", "clipboard-write"]); - await page.getByTestId("layer-item").getByRole("button").first().click(); - await page - .getByTestId("children-0eef4dd0-b39b-807a-8005-934805578f93") - .getByText("Rectangle") - .click({ button: "right" }); + // Two rows carry the `root-board` class (the empty board and the one with + // shapes) and only the board with children renders a `toggle-content` button, + // so the filter picks its expand toggle. The real root frame is not a row. + const boardRow = page + .locator('[data-testid="layer-row"][class*="root-board"]') + .filter({ has: page.getByTestId("toggle-content") }); + + await boardRow.getByTestId("toggle-content").click(); + + // The children container is named after the board's own id, so it does not + // need the fixture's uuid written by hand. + const boardChildren = page.getByTestId( + `children-${await boardRow.getAttribute("id")}`, + ); + await expect(boardChildren).toBeVisible(); + + await boardChildren.getByText("Rectangle").click({ button: "right" }); await page.getByText("Copy/Paste as").hover(); await page.getByText("Copy properties").click(); @@ -658,9 +610,7 @@ test("BUG 13415 - Grid layout overlay is not removed when deleting a board", asy await expect(workspacePage.canvas).toHaveScreenshot(); }); -test("BUG 13822 - Problems with z-index", async ({ - page -}) => { +test("BUG 13822 - Problems with z-index", async ({ page }) => { const workspacePage = new WasmWorkspacePage(page); await workspacePage.setupEmptyFile(); await workspacePage.mockGetFile("workspace/get-file-13822.json"); @@ -674,12 +624,13 @@ test("BUG 13822 - Problems with z-index", async ({ await expect(workspacePage.canvas).toHaveScreenshot(); }); -test("BUG 14239 - Fix default path thickness", async ({ - page -}) => { +test("BUG 14239 - Fix default path thickness", async ({ page }) => { const workspacePage = new WasmWorkspacePage(page); await workspacePage.setupEmptyFile(); - await workspacePage.mockRPC("update-file?id=*", "workspace/update-file-empty.json"); + await workspacePage.mockRPC( + "update-file?id=*", + "workspace/update-file-empty.json", + ); await workspacePage.goToWorkspace(); // (Workaround a bug in which mouse position can be nil and path editor crashes @@ -692,7 +643,9 @@ test("BUG 14239 - Fix default path thickness", async ({ // 2. Close it await page.keyboard.press("Escape"); - await expect(workspacePage.rightSidebar.getByRole("textbox", { name: "Stroke width" })).toHaveValue("1"); + await expect( + workspacePage.rightSidebar.getByRole("textbox", { name: "Stroke width" }), + ).toHaveValue("1"); }); test("Bug 14250 - User with viewer role can select a locked board with a grid", async ({ @@ -701,10 +654,7 @@ test("Bug 14250 - User with viewer role can select a locked board with a grid", const workspacePage = new WasmWorkspacePage(page); await workspacePage.setupEmptyFile(); await workspacePage.mockRPC("get-teams", "get-teams-role-viewer.json"); - await workspacePage.mockRPC( - /get\-file\?/, - "workspace/get-file-14250.json", - ); + await workspacePage.mockRPC(/get\-file\?/, "workspace/get-file-14250.json"); await workspacePage.goToWorkspace();