17 lines
672 B
TypeScript
17 lines
672 B
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);
|
|
// Wait for Vue Router to actually resolve the route (not a fixed delay)
|
|
await page.waitForURL((url) => url.pathname === path, { timeout: 10_000 });
|
|
}
|