diff --git a/frontend/playwright/ui/pages/WorkspacePage.js b/frontend/playwright/ui/pages/WorkspacePage.js index 7f1e871c66..a4624ce37c 100644 --- a/frontend/playwright/ui/pages/WorkspacePage.js +++ b/frontend/playwright/ui/pages/WorkspacePage.js @@ -45,24 +45,27 @@ export class WorkspacePage extends BaseWebSocketPage { return this.waitForEditor(); } - stopEditing() { - return this.page.keyboard.press("Escape"); + async stopEditing() { + await this.page.keyboard.press("Escape"); } async moveToLeft(amount = 0) { for (let i = 0; i < amount; i++) { await this.page.keyboard.press("ArrowLeft"); } + await this.waitForIdle(); } async moveToRight(amount = 0) { for (let i = 0; i < amount; i++) { await this.page.keyboard.press("ArrowRight"); } + await this.waitForIdle(); } async moveFromStart(offset = 0) { await this.page.keyboard.press("Home"); + await this.waitForIdle(); await this.moveToRight(offset); } @@ -103,6 +106,10 @@ export class WorkspacePage extends BaseWebSocketPage { changeLetterSpacing(newValue) { return this.changeNumericInput(this.letterSpacing, newValue); } + + async waitForIdle() { + await this.page.evaluate(() => new Promise((resolve) => globalThis.requestIdleCallback(resolve))); + } }; /** diff --git a/frontend/playwright/ui/specs/text-editor-v2.spec.js b/frontend/playwright/ui/specs/text-editor-v2.spec.js index e32e0536a3..197a19c743 100644 --- a/frontend/playwright/ui/specs/text-editor-v2.spec.js +++ b/frontend/playwright/ui/specs/text-editor-v2.spec.js @@ -2,8 +2,6 @@ import { test, expect } from "@playwright/test"; import { Clipboard } from "../../helpers/Clipboard"; import { WasmWorkspacePage } from "../pages/WasmWorkspacePage"; -const timeToWait = 100; - test.beforeEach(async ({ page, context }) => { await Clipboard.enable(context, Clipboard.Permission.ALL); @@ -37,11 +35,13 @@ test("Create a new text shape from pasting text", async ({ page, context }) => { await workspace.setupEmptyFile(); await workspace.mockRPC("update-file?id=*", "text-editor/update-file.json"); await workspace.goToWorkspace(); + await workspace.moveButton.click(); await Clipboard.writeText(page, textToPaste); await workspace.clickAt(190, 150); await workspace.paste("keyboard"); + await workspace.textEditor.stopEditing(); await expect(workspace.layers.getByText(textToPaste)).toBeVisible(); @@ -57,6 +57,7 @@ test("Create a new text shape from pasting text using context menu", async ({ }); await workspace.setupEmptyFile(); await workspace.goToWorkspace(); + await workspace.moveButton.click(); await Clipboard.writeText(page, textToPaste); @@ -138,7 +139,7 @@ test("Update a new text shape appending text by pasting text", async ({ await workspace.paste("keyboard"); await workspace.textEditor.stopEditing(); await workspace.waitForSelectedShapeName("Lorem ipsum dolor sit amet"); - }); +}); test.skip("Update a new text shape prepending text by pasting text", async ({ page,