diff --git a/.agents/skills/migrate-ds-area/SKILL.md b/.agents/skills/migrate-ds-area/SKILL.md index d06d40a4f5..90e9f31015 100644 --- a/.agents/skills/migrate-ds-area/SKILL.md +++ b/.agents/skills/migrate-ds-area/SKILL.md @@ -104,6 +104,10 @@ the file: two PRs that both append at the end conflict. `[class*='…']`, or `a.or(b)` when the element type changes (raw `[class*='menu-btn']` before, `getByRole("button", { name: "Options" })` after). Scope `.or()` to the area so it cannot match elsewhere. +- Press the primary modifier as `ControlOrMeta`, never a literal + `Control` (`keyboard.press("ControlOrMeta+d")`, + `click({ modifiers: ["ControlOrMeta"] })`): on macOS Penpot binds its + shortcuts to Command, so `Control` fails there. - Missing data? Add a fixture under `frontend/playwright/data/` and mock it (`dashboardPage.mockRPC(...)`, `DashboardPage.mockConfigFlags` for flags). Watch for expired or inconsistent fixtures (dates in the past, diff --git a/.serena/memories/frontend/playwright-gestures.md b/.serena/memories/frontend/playwright-gestures.md index 218049abbe..c2845d4085 100644 --- a/.serena/memories/frontend/playwright-gestures.md +++ b/.serena/memories/frontend/playwright-gestures.md @@ -42,6 +42,8 @@ async (page) => { } ``` +For the primary modifier (Ctrl on Linux/Windows, Command on macOS) use `ControlOrMeta`, not `Control`; see `mem:frontend/testing-playwright`. + ## Coordinate Planning Playwright mouse coordinates and `getBoundingClientRect()` use viewport CSS pixels, not screen coordinates or device pixels. Read the viewport controls' `viewBox` and rectangle at the time of the gesture; pan, zoom and panels change the mapping. Ruler labels can be frame-relative and are not a substitute for the viewBox. diff --git a/.serena/memories/frontend/testing-playwright.md b/.serena/memories/frontend/testing-playwright.md index 4d278f20a5..14b2320a8e 100644 --- a/.serena/memories/frontend/testing-playwright.md +++ b/.serena/memories/frontend/testing-playwright.md @@ -4,4 +4,5 @@ - The web server serves the release bundle in `frontend/resources/public`, not live sources. Rebuild from `frontend/` with `./scripts/build` after product edits or a branch switch with different sources/assets; a spec-only edit does not require that rebuild. A stale bundle that fails at boot says nothing about the spec. - Mock the RPC and socket traffic your page needs; the integration suite does not exercise live backend behavior. `BasePage.mockRPC` expects a command name, not the full RPC URL. Set up `BaseWebSocketPage` mocks before workspace initialization subscribes. - Prefer user-facing locators. Layer rows are an exception: selection can add hide/lock titles to their accessible name. Use `WorkspacePage.layerRow`/`layerRows` and `selectRow`/`selectLayer` rather than matching the entire role name or clicking twice. +- Press the primary modifier as `ControlOrMeta`, never a literal `Control`, in `keyboard.press` and in `click({ modifiers })`. Chromium sends the host's user agent, so on macOS Penpot binds `c-mod`/`ca-mod` shortcuts to Command and `kbd/mod?` reads `metaKey`; a literal `Control` passes on Linux CI and fails on macOS. Keep `Control` only where Penpot reads `ctrlKey` itself, or where the spec records a raw key combo (the shortcut editor). - For build-once CI and stable check names see `mem:frontend/e2e-ci-workflow`. For targeted live pointer and keyboard input see `mem:frontend/playwright-gestures`. diff --git a/docs/technical-guide/developer/frontend.md b/docs/technical-guide/developer/frontend.md index 7df103655d..26bc5b665e 100644 --- a/docs/technical-guide/developer/frontend.md +++ b/docs/technical-guide/developer/frontend.md @@ -636,6 +636,19 @@ page.getByText("Penpot is the free open-"); To locate the rest of the elements we continue exploring the list of queries according to the order of priority. If none of the above options match the item, we resort to getByTestId as a last resort. +#### Keyboard shortcuts and modifier keys + +Penpot maps its shortcuts to the user's OS: Ctrl on Linux and Windows, Command on macOS. Playwright's Chromium reports the real host OS, so a test that presses a literal Control passes on Linux and fails on macOS. + +Use ControlOrMeta for the primary modifier, both in key presses and in clicks: + +```js +await page.keyboard.press("ControlOrMeta+d"); +await layer.click({ modifiers: ["ControlOrMeta"] }); +``` + +Keep Control only when the app reads the Ctrl key itself on every OS, or when the test records a raw key combination, such as a custom shortcut. + #### Assertions Assertions use Playwright's expect method. Here are some tips for writing your assertions: diff --git a/frontend/playwright/ui/render-wasm-specs/texts.spec.js b/frontend/playwright/ui/render-wasm-specs/texts.spec.js index ca59f0afa2..00852c66b6 100644 --- a/frontend/playwright/ui/render-wasm-specs/texts.spec.js +++ b/frontend/playwright/ui/render-wasm-specs/texts.spec.js @@ -73,7 +73,7 @@ test("Updates a text font", async ({ page }) => { await workspace.waitForFirstRender(); await workspace.clickLeafLayer("this is a text"); - await page.keyboard.press("Control+b"); + await page.keyboard.press("ControlOrMeta+b"); await workspace.hideUI(); diff --git a/frontend/playwright/ui/specs/multiseleccion.spec.js b/frontend/playwright/ui/specs/multiseleccion.spec.js index d579400252..8be7156209 100644 --- a/frontend/playwright/ui/specs/multiseleccion.spec.js +++ b/frontend/playwright/ui/specs/multiseleccion.spec.js @@ -191,7 +191,7 @@ test("Multiselection of text and typographies", async ({ page }) => { }); // Select rectangle and elipse together await rectangleLayer.click(); - await elipseLayer.click({ modifiers: ["Control"] }); + await elipseLayer.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).not.toBeVisible(); // Select plain text layer @@ -201,7 +201,7 @@ test("Multiselection of text and typographies", async ({ page }) => { await expect(textSection.getByText("Mixed assets")).not.toBeVisible(); // Select two plain text layer with different font family - await plainTextLayerTwo.click({ modifiers: ["Control"] }); + await plainTextLayerTwo.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect( textSection.getByTitle("Font family").getByText("Mixed Font Families"), @@ -213,7 +213,7 @@ test("Multiselection of text and typographies", async ({ page }) => { await expect(textSection.getByText("Typography one")).toBeVisible(); // Select two typography text layer with different typography - await typographyTextLayerTwo.click({ modifiers: ["Control"] }); + await typographyTextLayerTwo.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed assets")).toBeVisible(); @@ -223,36 +223,36 @@ test("Multiselection of text and typographies", async ({ page }) => { await expect(textSection.getByLabel("token-typo-one")).toBeVisible(); // Select two token typography text layer with different token typography - await tokenTypographyTextLayerTwo.click({ modifiers: ["Control"] }); + await tokenTypographyTextLayerTwo.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed tokens")).toBeVisible(); //Select plain text layer and typography text layer together await plainTextLayer.click(); - await typographyTextLayerOne.click({ modifiers: ["Control"] }); + await typographyTextLayerOne.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed assets")).toBeVisible(); //Select plain text layer and typography text layer together on reverse order await typographyTextLayerOne.click(); - await plainTextLayer.click({ modifiers: ["Control"] }); + await plainTextLayer.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed assets")).toBeVisible(); //Selen token typography text layer and typography text layer together await tokenTypographyTextLayerOne.click(); - await typographyTextLayerOne.click({ modifiers: ["Control"] }); + await typographyTextLayerOne.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed assets")).toBeVisible(); //Select token typography text layer and typography text layer together on reverse order await typographyTextLayerOne.click(); - await tokenTypographyTextLayerOne.click({ modifiers: ["Control"] }); + await tokenTypographyTextLayerOne.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).toBeVisible(); await expect(textSection.getByText("Mixed assets")).toBeVisible(); // Select rectangle and elipse together await rectangleLayer.click(); - await elipseLayer.click({ modifiers: ["Control"] }); + await elipseLayer.click({ modifiers: ["ControlOrMeta"] }); await expect(textSection).not.toBeVisible(); }); diff --git a/frontend/playwright/ui/visual-specs/workspace.spec.js b/frontend/playwright/ui/visual-specs/workspace.spec.js index 5c5e41c42e..77e764d3af 100644 --- a/frontend/playwright/ui/visual-specs/workspace.spec.js +++ b/frontend/playwright/ui/visual-specs/workspace.spec.js @@ -204,9 +204,9 @@ test.describe("Design tab", () => { await workspace.rectShapeButton.click(); await workspace.clickWithDragViewportAt(128, 128, 200, 100); await workspace.clickLeafLayer("Rectangle"); - await page.keyboard.press("Control+D"); + await page.keyboard.press("ControlOrMeta+D"); await expect(workspace.layers.getByText("Rectangle")).toHaveCount(2); - await page.keyboard.press("Control+A"); + await page.keyboard.press("ControlOrMeta+A"); await expect( workspace.rightSidebar.getByRole("button", { name: "Flatten" }), @@ -308,9 +308,9 @@ test.describe("Design tab", () => { await workspace.rectShapeButton.click(); await workspace.clickWithDragViewportAt(128, 128, 200, 100); await workspace.clickLeafLayer("Rectangle"); - await page.keyboard.press("Control+D"); + await page.keyboard.press("ControlOrMeta+D"); await expect(workspace.layers.getByText("Rectangle")).toHaveCount(2); - await page.keyboard.press("Control+A"); + await page.keyboard.press("ControlOrMeta+A"); await expect( workspace.rightSidebar.getByRole("button", { name: /^Align left/ }), @@ -946,7 +946,7 @@ test.describe("Undo history", () => { await page.keyboard.press("r"); await workspace.clickWithDragViewportAt(128, 128, 200, 100); - await page.keyboard.press("Control+Alt+h"); + await page.keyboard.press("ControlOrMeta+Alt+h"); await page.getByRole("tab", { name: "Actions" }).click(); const panel = page.getByRole("tabpanel", { name: "Actions" }); const entry = panel.getByText("New rectangle"); @@ -1035,7 +1035,7 @@ test.describe("Plugins", () => { await workspace.mockRPC("get-profile", profile); } await workspace.goToWorkspace(); - await workspace.page.keyboard.press("Control+Alt+P"); + await workspace.page.keyboard.press("ControlOrMeta+Alt+P"); }; test("Shows the plugins manager without plugins", async ({ page }) => { @@ -1159,7 +1159,7 @@ test.describe("Selected colors", () => { }); await workspace.clickToggableLayer("Board"); - await page.keyboard.press("Control+A"); + await page.keyboard.press("ControlOrMeta+A"); await expect( workspace.rightSidebar.getByRole("button", { name: "More colors" }),