mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 00:26:11 +02:00
📎 Add (temporary) visual regression tests for the Workspace
This commit is contained in:
parent
8a0aa9cd7f
commit
7f4f54e3fd
11 changed files with 914 additions and 7 deletions
Binary file not shown.
Before Width: | Height: | Size: 152 KiB |
124
frontend/playwright/ui/visual-specs/workspace.spec.js
Normal file
124
frontend/playwright/ui/visual-specs/workspace.spec.js
Normal file
|
@ -0,0 +1,124 @@
|
|||
import { test, expect } from "@playwright/test";
|
||||
import { WorkspacePage } from "../pages/WorkspacePage";
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await WorkspacePage.init(page);
|
||||
});
|
||||
|
||||
const setupFileWithAssets = async (workspace) => {
|
||||
const fileId = "015fda4f-caa6-8103-8004-862a00dd4f31";
|
||||
const pageId = "015fda4f-caa6-8103-8004-862a00ddbe94";
|
||||
const fragments = {
|
||||
"015fda4f-caa6-8103-8004-862a9e4b4d4b": "assets/get-file-fragment-with-assets-components.json",
|
||||
"015fda4f-caa6-8103-8004-862a9e4ad279": "assets/get-file-fragmnet-with-assets-page.json",
|
||||
};
|
||||
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockRPC(/get\-file\?/, "assets/get-file-with-assets.json");
|
||||
|
||||
for (const [id, fixture] of Object.entries(fragments)) {
|
||||
await workspace.mockRPC(`get-file-fragment?file-id=*&fragment-id=${id}`, fixture);
|
||||
}
|
||||
|
||||
return { fileId, pageId };
|
||||
};
|
||||
|
||||
test("Shows the workspace correctly for a blank file", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
|
||||
await workspace.goToWorkspace();
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
});
|
||||
|
||||
test.describe("Design tab", () => {
|
||||
test("Shows the design tab when selecting a shape", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockRPC(/get\-file\?/, "workspace/get-file-not-empty.json");
|
||||
|
||||
await workspace.goToWorkspace({
|
||||
fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374",
|
||||
pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375",
|
||||
});
|
||||
|
||||
await workspace.clickLeafLayer("Rectangle");
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
});
|
||||
|
||||
test("Shows expanded sections of the design tab", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockRPC(/get\-file\?/, "workspace/get-file-not-empty.json");
|
||||
|
||||
await workspace.goToWorkspace({
|
||||
fileId: "6191cd35-bb1f-81f7-8004-7cc63d087374",
|
||||
pageId: "6191cd35-bb1f-81f7-8004-7cc63d087375",
|
||||
});
|
||||
|
||||
await workspace.clickLeafLayer("Rectangle");
|
||||
await workspace.rightSidebar.getByTestId("add-stroke").click();
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Assets tab", () => {
|
||||
test("Shows the libraries modal correctly", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
await workspace.setupEmptyFile();
|
||||
await workspace.mockRPC("link-file-to-library", "workspace/link-file-to-library.json");
|
||||
await workspace.mockRPC(
|
||||
"get-team-shared-files?team-id=*",
|
||||
"workspace/get-team-shared-libraries-non-empty.json",
|
||||
);
|
||||
|
||||
await workspace.goToWorkspace();
|
||||
await workspace.clickAssets();
|
||||
await workspace.openLibrariesModal();
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
|
||||
await workspace.clickLibrary("Testing library 1");
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
});
|
||||
|
||||
test("Shows the assets correctly", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
const { fileId, pageId } = await setupFileWithAssets(workspace);
|
||||
|
||||
await workspace.goToWorkspace({ fileId, pageId });
|
||||
|
||||
await workspace.clickAssets();
|
||||
await workspace.sidebar.getByRole("button", { name: "Components" }).click();
|
||||
await workspace.sidebar.getByRole("button", { name: "Colors" }).click();
|
||||
await workspace.sidebar.getByRole("button", { name: "Typographies" }).click();
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
|
||||
await workspace.sidebar.getByTitle("List view").click();
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Palette", () => {
|
||||
test("Shows the bottom palette expanded and collapsed", async ({ page }) => {
|
||||
const workspace = new WorkspacePage(page);
|
||||
const { fileId, pageId } = await setupFileWithAssets(workspace);
|
||||
|
||||
await workspace.goToWorkspace({ fileId, pageId });
|
||||
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
|
||||
await workspace.palette.getByRole("button", { name: "Typographies" }).click();
|
||||
await expect(workspace.palette.getByText("Source Sans Pro Regular")).toBeVisible();
|
||||
await expect(workspace.page).toHaveScreenshot();
|
||||
|
||||
await workspace.palette.getByRole("button", { name: "Color Palette" }).click();
|
||||
await expect(workspace.palette.getByRole("button", { name: "#7798ff" })).toBeVisible();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue