diff --git a/frontend/playwright.config.js b/frontend/playwright.config.js index db8b9be4fc..e7659cd459 100644 --- a/frontend/playwright.config.js +++ b/frontend/playwright.config.js @@ -1,5 +1,4 @@ -import { defineConfig, devices } from "@playwright/test"; -import { platform } from "os"; +import { defineConfig } from "@playwright/test"; /** * Read environment variables from file. @@ -7,10 +6,6 @@ import { platform } from "os"; */ // require('dotenv').config(); -const userAgent = platform === 'darwin' ? - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" : - undefined; - // Default timeout of the retrying expects (toBeVisible and friends). CI // runners are slower and the first load of a page fetches its module, so // they get more time. A project that sets its own `expect` replaces the @@ -60,11 +55,9 @@ export default defineConfig({ name: "default", testDir: "./playwright/ui/specs", use: { - ...devices["Desktop Chrome"], viewport: { width: 1920, height: 1080 }, // Add custom viewport size video: 'retain-on-failure', trace: 'retain-on-failure', - userAgent, }, snapshotPathTemplate: "{testDir}/{testFilePath}-snapshots/{arg}.png", expect: { @@ -76,7 +69,6 @@ export default defineConfig({ }, { name: "ds", - use: { ...devices["Desktop Chrome"] }, testDir: "./playwright/ui/visual-specs", expect: { timeout: expectTimeout, @@ -86,7 +78,6 @@ export default defineConfig({ { name: "render-wasm", use: { - ...devices["Desktop Chrome"], viewport: { width: 1920, height: 1080 }, // Add custom viewport size deviceScaleFactor: 2, launchOptions: { diff --git a/frontend/playwright/ui/pages/WasmWorkspacePage.js b/frontend/playwright/ui/pages/WasmWorkspacePage.js index 583d25f5f9..37289f9a71 100644 --- a/frontend/playwright/ui/pages/WasmWorkspacePage.js +++ b/frontend/playwright/ui/pages/WasmWorkspacePage.js @@ -53,7 +53,8 @@ export class WasmWorkspacePage extends WorkspacePage { } async waitForFirstRender() { - await this.pageName.waitFor(); + // The sitemap shows one name per page; any of them proves the UI is up. + await this.pageName.first().waitFor(); await this.canvas.waitFor(); await this.page.waitForFunction(() => { console.log("RAF:", window.wasmSetObjectsFinished); @@ -81,7 +82,7 @@ export class WasmWorkspacePage extends WorkspacePage { async hideUI() { await this.page.keyboard.press("\\"); - await expect(this.pageName).not.toBeVisible(); + await expect(this.pageName.first()).not.toBeVisible(); } static async mockGoogleFont(page, fontSlug, assetFilename, options = {}) { diff --git a/frontend/playwright/ui/pages/WorkspacePage.js b/frontend/playwright/ui/pages/WorkspacePage.js index 361426d195..9137311dca 100644 --- a/frontend/playwright/ui/pages/WorkspacePage.js +++ b/frontend/playwright/ui/pages/WorkspacePage.js @@ -275,7 +275,12 @@ export class WorkspacePage extends BaseWebSocketPage { async #waitForWebSocketReadiness(pageName) { // TODO: find a better event to settle whether the app is ready to receive notifications via ws - await expect(this.pageName).toHaveText(pageName, { timeout: 30000 }) + // The sitemap shows every page of the file: wait for the one we opened. + // The anchored match tells "Page 1" from "Page 10". + const item = this.pageName.filter({ + hasText: new RegExp(`^${escapeRegExp(pageName)}$`), + }); + await expect(item).toBeAttached({ timeout: 30000 }); } async sendPresenceMessage(fixture) { diff --git a/frontend/playwright/ui/specs/rename-page.spec.js b/frontend/playwright/ui/specs/rename-page.spec.js index f5e070f3b2..027923bbe6 100644 --- a/frontend/playwright/ui/specs/rename-page.spec.js +++ b/frontend/playwright/ui/specs/rename-page.spec.js @@ -55,14 +55,6 @@ async function setupWorkspace(workspacePage) { "workspace/update-file-create-rect.json", ); - // The base WorkspacePage uses `this.pageName` (getByTestId("page-name")) as a - // readiness signal inside goToWorkspace. With 3 pages in the sidebar there are - // 3 matching elements, which violates Playwright's strict mode. Narrow the - // locator to the first occurrence so the internal readiness check can pass. - workspacePage.pageName = workspacePage.page - .getByTestId("page-name") - .first(); - await workspacePage.goToWorkspace({ fileId: FILE_ID, pageId: PAGE1_ID,