Skip to content

Commit 0108657

Browse files
committed
fix(desktop-e2e): correct three migrated waits and keep the real toast timer
1 parent f36c991 commit 0108657

4 files changed

Lines changed: 29 additions & 18 deletions

File tree

‎apps/desktop/e2e/browser-focus.spec.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ test('browser focus and shortcuts stay with the surface the user is using', asyn
9898
: null
9999
})
100100
const visiblePageUrl = async () => (await visiblePage())?.url ?? null
101+
/** Whether a page at exactly `url` finished loading, visible or not. */
102+
const pageLoaded = (url: string) =>
103+
app.evaluate(
104+
({ webContents }, url) =>
105+
webContents
106+
.getAllWebContents()
107+
.some((contents) => contents.getURL() === url && !contents.isLoading()),
108+
url
109+
)
101110
/** How many popup pages have finished loading, wherever they are in the strip. */
102111
const loadedPopups = () =>
103112
app.evaluate(
@@ -186,7 +195,8 @@ test('browser focus and shortcuts stay with the surface the user is using', asyn
186195
['browser_open_tab', '/three'],
187196
] as const) {
188197
await execute(tool, { url: `${site}${path}` })
189-
await expect.poll(visiblePage).toEqual({ url: `${site}${path}`, loading: false })
198+
// browser_open_tab works in a background tab, so the page need not be the visible one.
199+
await expect.poll(() => pageLoaded(`${site}${path}`)).toBe(true)
190200
expect(await composerFocused()).toBe(true)
191201
expect(await focusedPageUrls()).toEqual([])
192202
}

‎apps/desktop/e2e/browser-page-dialogs.spec.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
345345
.poll(() => shell.evaluate(() => (globalThis as FixtureGlobals).pageIssue))
346346
.toBe('load-error')
347347
await act({ action: 'back' })
348-
// Until Back lands, the tab still shows /broken's error page.
349-
await expect.poll(pageUrl).toBe(form)
350-
await expect.poll(formTitle).toBe('form')
348+
// The page navigates itself from whatever document Back left in the tab.
349+
const current = await pageUrl()
350+
if (!current) throw new Error('No page on the fixture site after Back')
351351
await inPage(
352352
app,
353-
form,
353+
current,
354354
`setTimeout(() => { location.href = ${JSON.stringify(`${site}/next`)} })`
355355
)
356356
await expect.poll(pageUrl).toBe(`${site}/next`)

‎apps/desktop/e2e/browser-sign-in-prompts.spec.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,17 @@ const test = base.extend<{ signIn: SignInBrowser }>({
233233
await expect(dialog).toHaveCount(1)
234234
const usernameField = dialog.getByRole('textbox', { name: 'Username' })
235235
const passwordField = dialog.getByRole('textbox', { name: 'Password' })
236-
await usernameField.fill(username)
237-
// The password field stays read-only until it takes focus, which keeps autofill out.
238-
await passwordField.click()
239-
await expect(passwordField).toBeEditable()
240-
await passwordField.fill(password)
241-
await expect(usernameField).toHaveValue(username)
242-
await expect(passwordField).toHaveValue(password)
236+
// Kept from the original suite: the Username field can come back empty right after the
237+
// prompt appears (seen in CI, cause not yet found), so the entry repeats until both hold.
238+
await expect(async () => {
239+
await usernameField.fill(username)
240+
// The password field stays read-only until it takes focus, which keeps autofill out.
241+
await passwordField.click()
242+
await expect(passwordField).toBeEditable({ timeout: 1_000 })
243+
await passwordField.fill(password)
244+
await expect(usernameField).toHaveValue(username, { timeout: 1_000 })
245+
await expect(passwordField).toHaveValue(password, { timeout: 1_000 })
246+
}).toPass({ timeout: 10_000 })
243247
},
244248
async expectQuiet(openedBefore) {
245249
await sleep(QUIET_MS)

‎apps/desktop/e2e/update-notification.spec.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,14 @@ mountUpdateNotificationFixture(DesktopUpdateNotification);`,
7171
ipcMain.removeHandler('desktop:updates:get-state')
7272
ipcMain.handle('desktop:updates:get-state', () => ({ status: 'ready', version: '2.0.0' }))
7373
})
74-
// The page's timers run on Playwright's clock, installed before the reload so they all use it.
75-
await page.clock.install()
7674
await page.reload()
7775
await expect(restart).toHaveCount(1)
7876
await expect(restart).toBeVisible()
7977
await page.getByRole('button', { name: 'Switch workspace' }).click()
8078
await expect(page.getByLabel('Current route')).toHaveText('/workspace/second')
81-
// Past any auto-dismiss timer the notice could have started.
82-
const before = await page.evaluate(() => Date.now())
83-
await page.clock.fastForward(5_500)
84-
expect(await page.evaluate(() => Date.now())).toBeGreaterThanOrEqual(before + 5_500)
79+
// Outlasts the 5s default toast lifetime: proving a real timer doesn't dismiss the notice needs
80+
// its real duration, and a fake clock would also freeze the dismiss animations used below.
81+
await page.waitForTimeout(5_500)
8582
await expect(restart).toBeVisible()
8683
})
8784

0 commit comments

Comments
 (0)