🔧 Make visual regression tests to hide the UI when taking a screenshot (render-wasm tests only)

This commit is contained in:
Belén Albeza 2025-06-19 13:37:52 +02:00
parent 4ea4a1e130
commit 9852d24b83
13 changed files with 16 additions and 2 deletions

View file

@ -21,14 +21,24 @@ export class WasmWorkspacePage extends WorkspacePage {
this.canvas = page.getByTestId("canvas-wasm-shapes"); this.canvas = page.getByTestId("canvas-wasm-shapes");
} }
async waitForFirstRender() { async waitForFirstRender(config = {}) {
const options = { hideUI: true, ...config };
await expect(this.pageName).toHaveText("Page 1"); await expect(this.pageName).toHaveText("Page 1");
if (options.hideUI) {
await this.hideUI();
}
await this.canvas.waitFor({ state: "visible" }); await this.canvas.waitFor({ state: "visible" });
await this.page.waitForFunction(() => { await this.page.waitForFunction(() => {
return window.wasmSetObjectsFinished; return window.wasmSetObjectsFinished;
}); });
} }
async hideUI() {
await this.page.keyboard.press("\\");
await expect(this.pageName).not.toBeVisible();
}
static async mockGoogleFont(page, fontSlug, assetFilename, options = {}) { static async mockGoogleFont(page, fontSlug, assetFilename, options = {}) {
const url = new RegExp(`/internal/gfonts/font/${fontSlug}`); const url = new RegExp(`/internal/gfonts/font/${fontSlug}`);
return await page.route(url, (route) => return await page.route(url, (route) =>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 149 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

@ -31,12 +31,16 @@ test("Updates a text font", async ({ page }) => {
id: "3b0d758a-8c9d-8013-8006-52c8337e5c72", id: "3b0d758a-8c9d-8013-8006-52c8337e5c72",
pageId: "3b0d758a-8c9d-8013-8006-52c8337e5c73", pageId: "3b0d758a-8c9d-8013-8006-52c8337e5c73",
}); });
await workspace.waitForFirstRender(); await workspace.waitForFirstRender({ hideUI: false });
await workspace.clickLeafLayer("this is a text"); await workspace.clickLeafLayer("this is a text");
const fontStyle = workspace.page.getByTitle("Font Style"); const fontStyle = workspace.page.getByTitle("Font Style");
await fontStyle.click(); await fontStyle.click();
const boldOption = fontStyle.getByText("bold").first(); const boldOption = fontStyle.getByText("bold").first();
await boldOption.click(); await boldOption.click();
await workspace.hideUI();
await expect(workspace.canvas).toHaveScreenshot(); await expect(workspace.canvas).toHaveScreenshot();
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

After

Width:  |  Height:  |  Size: 511 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before After
Before After