2026-02-20 17:28:59 +01:00
|
|
|
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);
|
2026-03-06 10:33:04 +00:00
|
|
|
// 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.
|
2026-02-20 17:28:59 +01:00
|
|
|
}
|