File tree Expand file tree Collapse file tree 5 files changed +23
-10
lines changed
Expand file tree Collapse file tree 5 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import {
1212
1313test . 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 } ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import {
1212
1313test . 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
Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ import {
1515
1616test . 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
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ import {
1212
1313test . 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
Original file line number Diff line number Diff 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 */
6263export 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/**
You can’t perform that action at this time.
0 commit comments