fix: prevent default-page redirect in project history e2e test
The home route's beforeEnter guard redirects to the last visited project
when defaultPage is LAST_VISITED (the new default). This caused the
second test to never reach Home.vue after visiting projects, since
page.goto('/') triggered a fresh page load where the redirect guard
was not yet primed.
Navigate to '/' first to set the sessionStorage redirect flag, then use
the Overview menu link (SPA navigation) to return home.
Made-with: Cursor
This commit is contained in:
parent
51bbd419e1
commit
dd50d89aab
|
|
@ -76,11 +76,17 @@ test.describe('Project History', () => {
|
|||
}, false)
|
||||
}
|
||||
|
||||
// Navigate to home first so the default-page redirect guard is primed
|
||||
// (sets sessionStorage flag), preventing later page.goto('/') from
|
||||
// redirecting to the last visited project.
|
||||
await page.goto('/')
|
||||
await page.waitForLoadState('networkidle')
|
||||
|
||||
// Visit projects to build up history
|
||||
await visitProjectsToBuildHistory(page, projects)
|
||||
|
||||
// Go to overview and verify section is visible
|
||||
await page.goto('/')
|
||||
await page.locator('nav.menu.top-menu a').filter({hasText: 'Overview'}).click()
|
||||
await expect(page.locator('body')).toContainText('Last viewed')
|
||||
|
||||
// Disable the setting via API
|
||||
|
|
@ -91,12 +97,9 @@ test.describe('Project History', () => {
|
|||
},
|
||||
})
|
||||
|
||||
// Reload and wait for the user settings to be fetched before asserting
|
||||
const userResponsePromise = page.waitForResponse(resp =>
|
||||
resp.url().includes('/api/v1/user') && resp.request().method() === 'GET' && resp.status() === 200,
|
||||
)
|
||||
// Reload and verify section is hidden
|
||||
await page.reload()
|
||||
await userResponsePromise
|
||||
await page.waitForLoadState('networkidle')
|
||||
await expect(page.locator('body')).not.toContainText('Last viewed')
|
||||
})
|
||||
|
||||
|
|
@ -127,11 +130,8 @@ test.describe('Project History', () => {
|
|||
await visitProjectsToBuildHistory(page, projects)
|
||||
|
||||
// Verify section is hidden
|
||||
const hiddenResponsePromise = page.waitForResponse(resp =>
|
||||
resp.url().includes('/api/v1/user') && resp.request().method() === 'GET' && resp.status() === 200,
|
||||
)
|
||||
await page.goto('/')
|
||||
await hiddenResponsePromise
|
||||
await page.waitForLoadState('networkidle')
|
||||
await expect(page.locator('body')).not.toContainText('Last viewed')
|
||||
|
||||
// Re-enable the setting
|
||||
|
|
@ -141,12 +141,9 @@ test.describe('Project History', () => {
|
|||
},
|
||||
})
|
||||
|
||||
// Reload and wait for the user settings to be fetched before asserting
|
||||
const visibleResponsePromise = page.waitForResponse(resp =>
|
||||
resp.url().includes('/api/v1/user') && resp.request().method() === 'GET' && resp.status() === 200,
|
||||
)
|
||||
// Reload and verify section is visible again
|
||||
await page.reload()
|
||||
await visibleResponsePromise
|
||||
await page.waitForLoadState('networkidle')
|
||||
await expect(page.locator('body')).toContainText('Last viewed')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue