@@ -84,14 +84,16 @@ console.log('log', "debugging scan form command " + command.attributes.name);
84
84
cy . window ( ) . then ( ( win ) => {
85
85
let wcagCriteriaValue = Cypress . env ( "WCAG_CRITERIA" ) || "wcag21a" ;
86
86
let bestPracticeValue = Cypress . env ( "BEST_PRACTICE" ) || false ;
87
- let needsReviewValue = Cypress . env ( "NEEDS_REVIEW" ) || true ;
87
+ let needsReviewValue = Cypress . env ( "NEEDS_REVIEW" ) || false ;
88
88
89
89
const payloadToSend = {
90
90
message : 'SET_CONFIG' ,
91
91
wcagCriteria : wcagCriteriaValue ,
92
92
bestPractice : bestPracticeValue ,
93
93
needsReview : needsReviewValue
94
94
}
95
+
96
+ console . log ( 'log' , "payload to send " + payloadToSend ) ;
95
97
let testId = Cypress . env ( "TEST_ID" ) || ""
96
98
97
99
const filePath = Cypress . env ( "ACCESSIBILITY_REPORT_PATH" ) || 'cypress/results/accessibilityReport_' + testId + '.json' ;
@@ -142,4 +144,68 @@ cy.window().then((win) => {
142
144
Cypress . on ( 'command:end' , ( command ) => {
143
145
144
146
return ;
147
+ } )
148
+
149
+
150
+ afterEach ( ( ) => {
151
+ console . log ( "after each hook" )
152
+ cy . window ( ) . then ( ( win ) => {
153
+ let wcagCriteriaValue = Cypress . env ( "WCAG_CRITERIA" ) || "wcag21a" ;
154
+ let bestPracticeValue = Cypress . env ( "BEST_PRACTICE" ) || false ;
155
+ let needsReviewValue = Cypress . env ( "NEEDS_REVIEW" ) || false ;
156
+
157
+ const payloadToSend = {
158
+ message : 'SET_CONFIG' ,
159
+ wcagCriteria : wcagCriteriaValue ,
160
+ bestPractice : bestPracticeValue ,
161
+ needsReview : needsReviewValue
162
+ }
163
+
164
+ console . log ( 'log' , "payload to send " + payloadToSend ) ;
165
+ let testId = Cypress . env ( "TEST_ID" ) || ""
166
+
167
+ const filePath = Cypress . env ( "ACCESSIBILITY_REPORT_PATH" ) || 'cypress/results/accessibilityReport_' + testId + '.json' ;
168
+
169
+ cy . wrap ( setScanConfig ( win , payloadToSend ) , { timeout : 30000 } ) . then ( ( res ) => {
170
+ console . log ( 'logging config reponse' , res ) ;
171
+
172
+ const payload = {
173
+ message : 'GET_LATEST_SCAN_DATA' ,
174
+ }
175
+
176
+ cy . wrap ( getScanData ( win , payload ) , { timeout : 45000 } ) . then ( ( res ) => {
177
+ LambdatestLog ( 'log' , "scanning data " ) ;
178
+
179
+
180
+ cy . task ( 'initializeFile' , filePath ) . then ( ( filePath ) => {
181
+ cy . readFile ( filePath , { log : true , timeout : 45000 } ) . then ( ( fileContent ) => {
182
+ let resultsArray = [ { } ] ;
183
+ console . log ( 'logging report' , res ) ;
184
+ // If the file is not empty, parse the existing content
185
+ if ( fileContent ) {
186
+ try {
187
+ resultsArray = JSON . parse ( JSON . stringify ( fileContent ) ) ;
188
+ } catch ( e ) {
189
+ console . log ( "parsing error for content " , fileContent )
190
+ console . log ( 'Error parsing JSON file:' , e ) ;
191
+ return ;
192
+ }
193
+ }
194
+ console . log ( 'scanned data recieved is' , res . message ) ;
195
+ if ( res . message == "GET_LATEST_SCAN_DATA" ) {
196
+ // Append the new result
197
+ resultsArray . push ( res ) ;
198
+ console . log ( 'resultsarray logging' , resultsArray ) ;
199
+ }
200
+
201
+ // Write the updated content back to the file
202
+ cy . writeFile ( filePath , resultsArray , { log : true , timeout : 45000 } ) ;
203
+ } ) ;
204
+ } ) ;
205
+ } ) ;
206
+
207
+ } ) ;
208
+ } )
209
+
210
+
145
211
} )
0 commit comments