@@ -66,39 +66,6 @@ const getScanData = (win, payload) =>
6666
6767 } )
6868
69- const shouldScanForAccessibility = ( attributes ) => {
70- if ( Cypress . env ( "IS_ACCESSIBILITY_EXTENSION_LOADED" ) !== "true" ) return false ;
71-
72- const extensionPath = Cypress . env ( "ACCESSIBILITY_EXTENSION_PATH" ) ;
73- const isHeaded = Cypress . browser . isHeaded ;
74-
75- if ( ! isHeaded || ( extensionPath === undefined ) ) return false ;
76-
77- let shouldScanTestForAccessibility = true ;
78-
79- if ( Cypress . env ( "INCLUDE_TAGS_FOR_ACCESSIBILITY" ) || Cypress . env ( "EXCLUDE_TAGS_FOR_ACCESSIBILITY" ) ) {
80- try {
81- let includeTagArray = [ ] ;
82- let excludeTagArray = [ ] ;
83- if ( Cypress . env ( "INCLUDE_TAGS_FOR_ACCESSIBILITY" ) ) {
84- includeTagArray = Cypress . env ( "INCLUDE_TAGS_FOR_ACCESSIBILITY" ) . split ( ";" )
85- }
86- if ( Cypress . env ( "EXCLUDE_TAGS_FOR_ACCESSIBILITY" ) ) {
87- excludeTagArray = Cypress . env ( "EXCLUDE_TAGS_FOR_ACCESSIBILITY" ) . split ( ";" )
88- }
89-
90- const fullTestName = attributes . title ;
91- const excluded = excludeTagArray . some ( ( exclude ) => fullTestName . includes ( exclude ) ) ;
92- const included = includeTagArray . length === 0 || includeTags . some ( ( include ) => fullTestName . includes ( include ) ) ;
93- shouldScanTestForAccessibility = ! excluded && included ;
94- } catch ( error ) {
95- LambdatestLog ( "Error while validating test case for accessibility before scanning. Error : " , error ) ;
96- }
97- }
98-
99- return shouldScanTestForAccessibility ;
100- }
101-
10269Cypress . on ( 'command:start' , async ( command ) => {
10370 if ( ! command || ! command . attributes ) return ;
10471 if ( command . attributes . name == 'window' || command . attributes . name == 'then' || command . attributes . name == 'wrap' || command . attributes . name == 'wait' ) {
@@ -112,14 +79,9 @@ Cypress.on('command:start', async (command) => {
11279 return ;
11380 }
11481
115- // const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
11682
117- // let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
118- // if (!shouldScanTestForAccessibility) return;
119- // console.log('log', "debugging scan form command " + command.attributes.name);
12083console . log ( 'log' , "debugging scan form command " + command . attributes . name ) ;
12184cy . window ( ) . then ( ( win ) => {
122- // LambdatestLog('Performing scan form command ' + command.attributes.name);
12385 let wcagCriteriaValue = Cypress . env ( "WCAG_CRITERIA" ) || "wcag21a" ;
12486 let bestPracticeValue = Cypress . env ( "BEST_PRACTICE" ) || false ;
12587 let needsReviewValue = Cypress . env ( "NEEDS_REVIEW" ) || true ;
@@ -131,23 +93,22 @@ cy.window().then((win) => {
13193 needsReview : needsReviewValue
13294 }
13395 let testId = Cypress . env ( "TEST_ID" ) || ""
134- // const filePath = 'cypress/reports/accessibilityReport_' + testId + '.json';
96+
13597 const filePath = Cypress . env ( "ACCESSIBILITY_REPORT_PATH" ) || 'cypress/results/accessibilityReport_' + testId + '.json' ;
13698
13799 cy . wrap ( setScanConfig ( win , payloadToSend ) , { timeout : 30000 } ) . then ( ( res ) => {
138- // LambdatestLog('log', "logging report **************")
139100 console . log ( 'logging config reponse' , res ) ;
140101
141102 const payload = {
142103 message : 'GET_LATEST_SCAN_DATA' ,
143104 }
144- // cy.wait(5000);
145- cy . wrap ( getScanData ( win , payload ) , { timeout : 30000 } ) . then ( ( res ) => {
146- LambdatestLog ( 'log' , "logging report **************" )
105+
106+ cy . wrap ( getScanData ( win , payload ) , { timeout : 45000 } ) . then ( ( res ) => {
107+ LambdatestLog ( 'log' , "scanning data " ) ;
147108
148109
149110 cy . task ( 'initializeFile' , filePath ) . then ( ( filePath ) => {
150- cy . readFile ( filePath , { log : true , timeout : 30000 } ) . then ( ( fileContent ) => {
111+ cy . readFile ( filePath , { log : true , timeout : 45000 } ) . then ( ( fileContent ) => {
151112 let resultsArray = [ { } ] ;
152113 console . log ( 'logging report' , res ) ;
153114 // If the file is not empty, parse the existing content
@@ -160,15 +121,15 @@ cy.window().then((win) => {
160121 return ;
161122 }
162123 }
163- console . log ( 'debugging res ' , res . message ) ;
124+ console . log ( 'scanned data recieved is ' , res . message ) ;
164125 if ( res . message == "GET_LATEST_SCAN_DATA" ) {
165126 // Append the new result
166127 resultsArray . push ( res ) ;
167128 console . log ( 'resultsarray logging' , resultsArray ) ;
168129 }
169130
170131 // Write the updated content back to the file
171- cy . writeFile ( filePath , resultsArray , { log : true , timeout : 30000 } ) ;
132+ cy . writeFile ( filePath , resultsArray , { log : true , timeout : 45000 } ) ;
172133 } ) ;
173134 } ) ;
174135 } ) ;
0 commit comments