Skip to content

Commit cd182ca

Browse files
committed
fix: authentication setup to handle WordPress DB upgrade
1 parent 042e638 commit cd182ca

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

tests/e2e/auth.setup.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,25 @@ setup('authenticate', async ({ page }) => {
1212

1313
await page.click('#wp-submit')
1414

15-
await page.waitForURL(/wp-admin/)
16-
await page.waitForSelector('#wpbody-content, #adminmenu')
15+
// If WordPress shows the DB upgrade interstitial it includes a link to
16+
// `upgrade.php`. In that case navigate back to `/wp-admin` (the upgrade
17+
// process is handled by the environment) and then wait for the admin UI.
18+
const upgradeLink = page.locator('a[href*="upgrade.php"]')
19+
if (0 < await upgradeLink.count()) {
20+
// Click the upgrade link to reach the upgrade interstitial page.
21+
await upgradeLink.first().click()
22+
23+
// If the interstitial shows an "Update WordPress Database" action, click it.
24+
const updateBtn = page.locator('a:has-text("Update WordPress Database")')
25+
if (0 < await updateBtn.count()) {
26+
await updateBtn.first().click()
27+
}
28+
// Give the upgrade process more time to complete and the admin UI to load.
29+
await page.waitForSelector('#wpbody-content, #adminmenu', { timeout: 120000 })
30+
} else {
31+
// Normal path: wait for admin UI.
32+
await page.waitForSelector('#wpbody-content, #adminmenu', { timeout: 60000 })
33+
}
1734

1835
await expect(page.locator('#adminmenu')).toBeVisible()
1936

0 commit comments

Comments
 (0)