🔧 Wait for first render using a custom event (visual regression tests)

This commit is contained in:
Belén Albeza 2025-06-09 14:51:25 +02:00
parent 59a4b51d2c
commit 1a10b7ebfd
4 changed files with 25 additions and 14 deletions

View file

@ -8,6 +8,12 @@ export class WasmWorkspacePage extends WorkspacePage {
"enable-feature-render-wasm",
"enable-render-wasm-dpr",
]);
await page.addInitScript(() => {
document.addEventListener("wasm:set-objects-finished", () => {
window.wasmSetObjectsFinished = true;
});
});
}
constructor(page) {
@ -15,10 +21,11 @@ export class WasmWorkspacePage extends WorkspacePage {
this.canvas = page.getByTestId("canvas-wasm-shapes");
}
async waitForCanvasRender() {
// FIXME: temp workaround. We will need to wait for set-objects to fully finish
async waitForFirstRender() {
await expect(this.pageName).toHaveText("Page 1");
await this.canvas.waitFor({ state: "visible" });
await this.page.waitForTimeout(3000);
await this.page.waitForFunction(() => {
return window.wasmSetObjectsFinished;
});
}
}