Merge pull request #8881 from penpot/azazeln28-fix-text-editor-v2-tests

🐛 Fix text-editor v2 waitForIdle not having a timeout
This commit is contained in:
Aitor Moreno 2026-04-06 13:13:05 +02:00 committed by GitHub
commit 0f389fe3ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 6 deletions

View File

@ -40,6 +40,13 @@ export class WasmWorkspacePage extends WorkspacePage {
this.canvas = page.getByTestId("canvas-wasm-shapes"); this.canvas = page.getByTestId("canvas-wasm-shapes");
} }
async waitForIdle(options) {
return this.page.evaluate(
(options) => new Promise((resolve) => globalThis.requestIdleCallback(resolve, options)),
options
);
}
async waitForFirstRender() { async waitForFirstRender() {
await this.pageName.waitFor(); await this.pageName.waitFor();
await this.canvas.waitFor(); await this.canvas.waitFor();

View File

@ -53,19 +53,18 @@ export class WorkspacePage extends BaseWebSocketPage {
for (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
await this.page.keyboard.press("ArrowLeft"); await this.page.keyboard.press("ArrowLeft");
} }
await this.waitForIdle(); await this.waitForIdle({ timeout: 100 });
} }
async moveToRight(amount = 0) { async moveToRight(amount = 0) {
for (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
await this.page.keyboard.press("ArrowRight"); await this.page.keyboard.press("ArrowRight");
} }
await this.waitForIdle(); await this.waitForIdle({ timeout: 100 });
} }
async moveFromStart(offset = 0) { async moveFromStart(offset = 0) {
await this.page.keyboard.press("Home"); await this.page.keyboard.press("Home");
await this.waitForIdle();
await this.moveToRight(offset); await this.moveToRight(offset);
} }
@ -107,8 +106,10 @@ export class WorkspacePage extends BaseWebSocketPage {
return this.changeNumericInput(this.letterSpacing, newValue); return this.changeNumericInput(this.letterSpacing, newValue);
} }
async waitForIdle() { async waitForIdle(options) {
await this.page.evaluate(() => new Promise((resolve) => globalThis.requestIdleCallback(resolve))); await this.page.evaluate(
(options) => new Promise(
(resolve) => globalThis.requestIdleCallback(resolve, options)), options);
} }
}; };

View File

@ -96,7 +96,6 @@ test("Update an already created text shape by prepending text", async ({
await workspace.clickLeafLayer("Lorem ipsum"); await workspace.clickLeafLayer("Lorem ipsum");
await workspace.textEditor.startEditing(); await workspace.textEditor.startEditing();
await workspace.textEditor.moveFromStart(0); await workspace.textEditor.moveFromStart(0);
await page.evaluate(() => new Promise((resolve) => globalThis.requestIdleCallback(resolve)));
await page.keyboard.type("Dolor sit amet "); await page.keyboard.type("Dolor sit amet ");
await workspace.textEditor.stopEditing(); await workspace.textEditor.stopEditing();
await workspace.waitForSelectedShapeName("Dolor sit amet Lorem ipsum"); await workspace.waitForSelectedShapeName("Dolor sit amet Lorem ipsum");