Skip to content

Commit 000a586

Browse files
committed
Tweak to BasePage selectors to fix flaky full suite expectations
1 parent a17850f commit 000a586

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎test/e2e/helpers/pageObjectModels/BasePage.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414
import { navigationItems } from '@components/Navigation/server'
1515
import { clearConsentCookies } from '@test/e2e/helpers'
1616

17+
const DEFAULT_NAVIGATION_TIMEOUT = 5000
18+
const EXTENDED_NAVIGATION_TIMEOUT = 15000
19+
1720
export class BasePage {
1821
readonly page: Page
1922
private _consoleMessages: string[] = []
@@ -62,21 +65,26 @@ export class BasePage {
6265
* Automatically dismisses cookie consent modal unless skipCookieDismiss is true.
6366
*/
6467
async goto(path: string, options?: { skipCookieDismiss?: boolean; timeout?: number }): Promise<null | Response> {
65-
const navigate = async () => {
68+
const requestedTimeout = options?.timeout ?? DEFAULT_NAVIGATION_TIMEOUT
69+
70+
const navigate = async (timeout: number) => {
6671
return await this._page.goto(path, {
67-
timeout: options?.timeout ?? 5000,
72+
timeout,
6873
waitUntil: 'domcontentloaded',
6974
})
7075
}
7176

7277
let response: null | Response = null
7378

7479
try {
75-
response = await navigate()
80+
response = await navigate(requestedTimeout)
7681
} catch (error) {
7782
const message = error instanceof Error ? error.message : String(error)
7883
if (message.includes('ERR_ABORTED')) {
79-
response = await navigate()
84+
response = await navigate(requestedTimeout)
85+
} else if (!options?.timeout && message.includes('Timeout')) {
86+
// Allow a single retry with a longer timeout to absorb slow prerender navigations
87+
response = await navigate(EXTENDED_NAVIGATION_TIMEOUT)
8088
} else {
8189
throw error
8290
}

0 commit comments

Comments
 (0)