mirror of
https://github.com/penpot/penpot.git
synced 2026-11-20 17:11:15 +00:00
* ♻️ Reduce the routes, viewer, theme and typography e2e specs The five specs of Task 10 (routes, theme, viewer and roles) go from 14 tests to 6, and the two of Task 11 (missing font and add typography) from 9 to 4. Nine unit tests cover rules that had none: five for the private legacy-match and four for the viewer frame navigation. No skipped test and no fixture removed. The browser keeps the wiring: the known and unknown hash as two steps of one test, the theme applied live without a reload, the viewer role walked in two loads with the context menu counted instead of trusted, and the typography states merged around shared fixtures. The viewer zoom click comes back as a header step; the arrows e2e becomes unit tests, with the Next button still clicked by the child-click test. The missing-font test asserts the renamed, disabled typography button instead of a hidden one it never described. WorkspacePage gains reloadWorkspace, which clears the socket registry, reloads and reopens the mock, and settles on the sitemap page name or on the canvas when the restored sidebar tab hides it. layerRow matches rows by anchored text, because a selected row's action buttons can join its accessible name, and selectLayer accepts click options for the shift-click steps. The font specs use both and no longer import MockWebSocketHelper. The viewer role asserts its two absences by testid: new-project-button already existed and add-custom-font is new in fonts.cljs, the only product change, with the visible side covered by dashboard.spec. routes_test adds the path-params case for legacy-match; viewer_test asserts the first event and the page id of the frame navigation, and watch-events delivers asynchronously and handles the nil a watch can return. Measured at four workers: 23 to 10 tests; Task 10 from 141.3 to 68.5/72.3 worker-seconds and Task 11 from 150.1 to 109.0/109.3. Closes #13058 AI-assisted-by: deepseek-v4.1-flash * 🐛 Let the two reduced e2e steps fail when they should The typography step selected the next layer with Shift, which in the layers panel is a range selection: the range also brought in the text with a typography token, so the button was hidden by the applied token and not by the mixed values. A mod-click adds only that shape, and two new assertions keep the token and the asset texts out of the selection. The logo step clicked 100 px below the logo and asserted the URL, which potok updates after the click returns, so the assertion matched the old URL on its first poll. Probing elementFromPoint under the logo answers the hit-area question directly. AI-assisted-by: deepseek-v4.1-flash
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { ViewerPage } from "../pages/ViewerPage";
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await ViewerPage.init(page);
|
|
});
|
|
|
|
const singleBoardFileId = "dd5cc0bb-91ff-81b9-8004-77df9cd3edb1";
|
|
const singleBoardPageId = "dd5cc0bb-91ff-81b9-8004-77df9cd3edb2";
|
|
|
|
// The zoom menu needs a board, so the header test runs on the single-board
|
|
// fixture. The logo hit area holds on either fixture.
|
|
test("The viewer header keeps its hit area and its zoom menu", async ({
|
|
page,
|
|
}) => {
|
|
const viewerPage = new ViewerPage(page);
|
|
await viewerPage.setupLoggedInUser();
|
|
await viewerPage.setupFileWithSingleBoard();
|
|
await viewerPage.goToViewer({
|
|
fileId: singleBoardFileId,
|
|
pageId: singleBoardPageId,
|
|
});
|
|
|
|
await test.step("the logo hit area ends at the logo", async () => {
|
|
const logoLink = page.getByTestId("penpot-logo-link");
|
|
await expect(logoLink).toBeVisible();
|
|
|
|
// Navigating is a potok side effect that lands after the click, so a URL
|
|
// assertion could still match the old URL. Probe the point under the logo
|
|
// instead: a hit area that leaks there would navigate.
|
|
const { x, y } = await logoLink.boundingBox();
|
|
const hitsLogo = await page.evaluate(
|
|
([px, py]) =>
|
|
!!document
|
|
.elementFromPoint(px, py)
|
|
?.closest('[data-testid="penpot-logo-link"]'),
|
|
[x, y + 100],
|
|
);
|
|
expect(hitsLogo).toBe(false);
|
|
});
|
|
|
|
await test.step("zoom to fit updates the URL", async () => {
|
|
await page.getByTitle("Zoom").click();
|
|
await page.getByText(/Fit/).click();
|
|
|
|
await expect(page).toHaveURL(/&zoom=fit/);
|
|
});
|
|
});
|