@@ -12,21 +12,21 @@ test('duck-ai-data-clearing feature clears localStorage and IndexedDB', async ({
1212 messageCallback : 'messageCallback' ,
1313 } ) ;
1414 await collector . load ( HTML , CONFIG ) ;
15-
15+
1616 const duckAiDataClearing = new DuckAiDataClearingSpec ( page ) ;
17-
17+
1818 // Setup test data
1919 await duckAiDataClearing . setupTestData ( ) ;
2020 await duckAiDataClearing . waitForDataSetup ( ) ;
21-
21+
2222 // Trigger data clearing via messaging
2323 await collector . simulateSubscriptionMessage ( 'duckAiDataClearing' , 'duckAiClearData' , { } ) ;
24-
24+
2525 // Wait for completion message
2626 const messages = await collector . waitForMessage ( 'duckAiClearDataCompleted' , 1 ) ;
2727 expect ( messages ) . toHaveLength ( 1 ) ;
2828 expect ( messages [ 0 ] . payload . method ) . toBe ( 'duckAiClearDataCompleted' ) ;
29-
29+
3030 // Verify data is actually cleared
3131 await duckAiDataClearing . verifyDataCleared ( ) ;
3232 await duckAiDataClearing . waitForVerification ( 'Verification complete: All data cleared' ) ;
@@ -40,12 +40,12 @@ test('duck-ai-data-clearing feature handles IndexedDB errors gracefully', async
4040 messageCallback : 'messageCallback' ,
4141 } ) ;
4242 await collector . load ( HTML , CONFIG ) ;
43-
43+
4444 const duckAiDataClearing = new DuckAiDataClearingSpec ( page ) ;
45-
45+
4646 // Setup localStorage data only (no IndexedDB)
4747 await duckAiDataClearing . setupLocalStorageOnly ( ) ;
48-
48+
4949 // Mock IndexedDB to fail
5050 await page . evaluate ( ( ) => {
5151 const originalOpen = window . indexedDB . open ;
@@ -60,10 +60,10 @@ test('duck-ai-data-clearing feature handles IndexedDB errors gracefully', async
6060 return request ;
6161 } ;
6262 } ) ;
63-
63+
6464 // Trigger data clearing
6565 await collector . simulateSubscriptionMessage ( 'duckAiDataClearing' , 'duckAiClearData' , { } ) ;
66-
66+
6767 // Should still get completion message (localStorage should clear successfully)
6868 const messages = await collector . waitForMessage ( 'duckAiClearDataFailed' , 1 ) ;
6969 expect ( messages ) . toHaveLength ( 1 ) ;
@@ -78,17 +78,17 @@ test('duck-ai-data-clearing feature handles localStorage errors gracefully', asy
7878 messageCallback : 'messageCallback' ,
7979 } ) ;
8080 await collector . load ( HTML , CONFIG ) ;
81-
81+
8282 // Mock localStorage to throw an error
8383 await page . evaluate ( ( ) => {
8484 Storage . prototype . removeItem = ( ) => {
8585 throw new Error ( 'Simulated localStorage error' ) ;
8686 } ;
8787 } ) ;
88-
88+
8989 // Trigger data clearing
9090 await collector . simulateSubscriptionMessage ( 'duckAiDataClearing' , 'duckAiClearData' , { } ) ;
91-
91+
9292 // Should get failure message
9393 const messages = await collector . waitForMessage ( 'duckAiClearDataFailed' , 1 ) ;
9494 expect ( messages ) . toHaveLength ( 1 ) ;
@@ -103,14 +103,14 @@ test('duck-ai-data-clearing feature succeeds when data collections do not exist
103103 messageCallback : 'messageCallback' ,
104104 } ) ;
105105 await collector . load ( HTML , CONFIG ) ;
106-
106+
107107 const duckAiDataClearing = new DuckAiDataClearingSpec ( page ) ;
108-
108+
109109 // Ensure localStorage item doesn't exist
110110 await page . evaluate ( ( ) => {
111111 localStorage . removeItem ( 'savedAIChats' ) ;
112112 } ) ;
113-
113+
114114 // Ensure IndexedDB is clean (no existing database or object store)
115115 await page . evaluate ( ( ) => {
116116 return new Promise ( ( resolve ) => {
@@ -120,15 +120,15 @@ test('duck-ai-data-clearing feature succeeds when data collections do not exist
120120 deleteRequest . onblocked = ( ) => resolve ( null ) ; // Continue even if blocked
121121 } ) ;
122122 } ) ;
123-
123+
124124 // Trigger data clearing on non-existent/empty data
125125 await collector . simulateSubscriptionMessage ( 'duckAiDataClearing' , 'duckAiClearData' , { } ) ;
126-
126+
127127 // Should still get completion message since there's nothing to fail
128128 const messages = await collector . waitForMessage ( 'duckAiClearDataCompleted' , 1 ) ;
129129 expect ( messages ) . toHaveLength ( 1 ) ;
130130 expect ( messages [ 0 ] . payload . method ) . toBe ( 'duckAiClearDataCompleted' ) ;
131-
131+
132132 // Verify that subsequent verification shows no data exists
133133 await duckAiDataClearing . verifyDataCleared ( ) ;
134134 await duckAiDataClearing . waitForVerification ( 'Verification complete: All data cleared' ) ;
@@ -148,28 +148,33 @@ class DuckAiDataClearingSpec {
148148
149149 async setupLocalStorageOnly ( ) {
150150 await this . page . evaluate ( ( ) => {
151- localStorage . setItem ( 'savedAIChats' , JSON . stringify ( [
152- { id : 1 , message : 'test chat 1' }
153- ] ) ) ;
151+ localStorage . setItem ( 'savedAIChats' , JSON . stringify ( [ { id : 1 , message : 'test chat 1' } ] ) ) ;
154152 } ) ;
155153 }
156154
157155 async waitForDataSetup ( ) {
158- await this . page . waitForFunction ( ( ) => {
159- const status = document . getElementById ( 'data-status' ) ;
160- return status && status . textContent === 'Test data setup complete' ;
161- } , { timeout : 5000 } ) ;
156+ await this . page . waitForFunction (
157+ ( ) => {
158+ const status = document . getElementById ( 'data-status' ) ;
159+ return status && status . textContent === 'Test data setup complete' ;
160+ } ,
161+ { timeout : 5000 } ,
162+ ) ;
162163 }
163164
164165 async verifyDataCleared ( ) {
165166 await this . page . click ( '#verify-data' ) ;
166167 }
167168
168169 async waitForVerification ( expectedText ) {
169- await this . page . waitForFunction ( ( expected ) => {
170- const status = document . getElementById ( 'verify-status' ) ;
171- return status && status . textContent === expected ;
172- } , expectedText , { timeout : 5000 } ) ;
170+ await this . page . waitForFunction (
171+ ( expected ) => {
172+ const status = document . getElementById ( 'verify-status' ) ;
173+ return status && status . textContent === expected ;
174+ } ,
175+ expectedText ,
176+ { timeout : 5000 } ,
177+ ) ;
173178 }
174179}
175180
0 commit comments