Replace waitForLoadState('networkidle') with a comment explaining that callers
must assert on a route-specific element. The SPA keeps persistent WebSocket
connections for blockchain event subscriptions, so networkidle never fires
within the 10 s window, causing spurious TimeoutErrors in 01-acquire-and-stake
and 02-max-stake-all-tax-rates.
Vue Router processes popstate synchronously inside page.evaluate(), so the
route transition has already started by the time evaluate() resolves. Callers'
toBeVisible() assertions (with their own timeouts) serve as the readiness gate.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 lines
1 KiB
TypeScript
22 lines
1 KiB
TypeScript
import type { Page } from '@playwright/test';
|
|
|
|
/**
|
|
* Navigate within the Vue SPA without a full page reload.
|
|
* Uses history.pushState + popstate to trigger Vue Router navigation,
|
|
* preserving wallet connection state and reactive stores.
|
|
*
|
|
* For initial page loads, use page.goto() instead.
|
|
*/
|
|
export async function navigateSPA(page: Page, path: string): Promise<void> {
|
|
await page.evaluate((p) => {
|
|
window.history.pushState({}, '', p);
|
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
}, path);
|
|
// Vue Router processes the popstate event synchronously within evaluate(),
|
|
// so the route transition has already started by the time we return here.
|
|
// Callers must assert on a route-specific element (e.g. a heading) to confirm
|
|
// the view has mounted — that assertion is the readiness signal.
|
|
// waitForLoadState('networkidle') is not used because persistent WebSocket
|
|
// connections (blockchain event subscriptions) prevent the network from ever
|
|
// going idle, causing spurious timeouts.
|
|
}
|