fix: refine wait-helpers tests and improve navigation handling for URL changes

This commit is contained in:
GitHub Actions
2026-02-12 13:06:02 +00:00
parent dcb6a7f957
commit 53a3e29125
2 changed files with 12 additions and 5 deletions
+12 -4
View File
@@ -1,5 +1,5 @@
/**
* Unit tests for wait-helpers.ts - Phase 2.1: Semantic Wait Helpers
* Unit tests for wait-helpers.ts - Semantic Wait Helpers
*
* These tests verify the behavior of deterministic wait utilities
* that replace arbitrary `page.waitForTimeout()` calls.
@@ -14,7 +14,7 @@ import {
waitForNavigation,
} from './wait-helpers';
test.describe('wait-helpers - Phase 2.1 Semantic Wait Functions', () => {
test.describe('wait-helpers - Semantic Wait Functions', () => {
test.describe('waitForDialog', () => {
test('should wait for dialog to be visible and interactive', async ({ page }) => {
// Create a test page with dialog
@@ -282,16 +282,24 @@ test.describe('wait-helpers - Phase 2.1 Semantic Wait Functions', () => {
test.describe('waitForNavigation', () => {
test('should wait for URL change with string match', async ({ page }) => {
await page.route('**/test-page', async (route) => {
await route.fulfill({
status: 200,
contentType: 'text/html',
body: '<h1>New Page</h1>',
});
});
await page.goto('about:blank');
await page.setContent(`
<a href="data:text/html,<h1>New Page</h1>" id="nav-link">Navigate</a>
<a href="http://127.0.0.1:8080/test-page" id="nav-link">Navigate</a>
`);
const link = page.locator('#nav-link');
await link.click();
// Wait for navigation to complete
await waitForNavigation(page, /data:text\/html/);
await waitForNavigation(page, /\/test-page$/);
// Verify new page loaded
await expect(page.locator('h1')).toHaveText('New Page');
-1
View File
@@ -252,7 +252,6 @@ export async function waitForLoadingComplete(
'.loading',
'.spinner',
'[data-loading="true"]',
'div.animate-pulse', // Only divs upon animate-pulse (skeletons), excluding spans (badges)
'[role="status"][aria-label="Loading"]',
'[role="status"][aria-label="Authenticating"]',
'[role="status"][aria-label="Security Loading"]'