Skip to content

Commit a0f263f

Browse files
committed
tests: fix e2e order
1 parent b305080 commit a0f263f

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

tests/e2e/specs/conference-filters.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212

1313
test.describe('Conference Filters', () => {
1414
test.beforeEach(async ({ page }) => {
15-
await clearLocalStorage(page);
1615
await page.goto('/');
16+
await clearLocalStorage(page);
1717
await waitForPageReady(page);
1818
await waitForCountdowns(page);
1919
});

tests/e2e/specs/countdown-timers.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212

1313
test.describe('Countdown Timers', () => {
1414
test.beforeEach(async ({ page }) => {
15-
await clearLocalStorage(page);
1615
await page.goto('/');
16+
await clearLocalStorage(page);
1717
await waitForPageReady(page);
1818
});
1919

tests/e2e/specs/notification-system.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515

1616
test.describe('Notification System', () => {
1717
test.beforeEach(async ({ page, context }) => {
18-
// Clear storage
19-
await clearLocalStorage(page);
20-
2118
// Navigate to home page
2219
await page.goto('/');
20+
21+
// Clear storage after navigation
22+
await clearLocalStorage(page);
2323
await waitForPageReady(page);
2424
});
2525

tests/e2e/specs/search-functionality.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import {
1212

1313
test.describe('Search Functionality', () => {
1414
test.beforeEach(async ({ page }) => {
15-
await clearLocalStorage(page);
1615
await page.goto('/search');
16+
await clearLocalStorage(page);
1717
await waitForPageReady(page);
1818
});
1919

tests/e2e/utils/helpers.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,25 @@ export async function grantNotificationPermission(context) {
5858

5959
/**
6060
* Clear all localStorage data
61+
* Note: Page must be navigated to a valid URL before calling this function
6162
*/
6263
export async function clearLocalStorage(page) {
63-
await page.evaluate(() => {
64-
localStorage.clear();
65-
sessionStorage.clear();
66-
});
64+
// Check if page has a valid URL
65+
const url = page.url();
66+
if (!url || url === 'about:blank' || url === '') {
67+
console.warn('Cannot clear localStorage on blank page. Navigate to a page first.');
68+
return;
69+
}
70+
71+
try {
72+
await page.evaluate(() => {
73+
localStorage.clear();
74+
sessionStorage.clear();
75+
});
76+
} catch (error) {
77+
console.error('Failed to clear storage:', error.message);
78+
// Don't throw - let tests continue but log the issue
79+
}
6780
}
6881

6982
/**

0 commit comments

Comments
 (0)