@@ -276,7 +276,8 @@ describe("reportHTML", () => {
276276 describe ( "Modify Cypress Report Data" , ( ) => {
277277 const reporterHTML = rewire ( '../../../../bin/helpers/reporterHTML' ) ;
278278 const cypressReportData = reporterHTML . __get__ ( 'cypressReportData' ) ;
279- const cypress_report_data = {
279+ const cypress_report_data_with_config = {
280+ cypress_version : "6.8.0" ,
280281 rows : {
281282 "todo.spec.js" : {
282283 "sessions" : [
@@ -290,7 +291,22 @@ describe("reportHTML", () => {
290291 }
291292 }
292293 }
293- it ( "Generate Report Data for each combination in a separate promise " , async ( ) => {
294+ const cypress_report_data_without_config = {
295+ cypress_version : "5.6.0" ,
296+ rows : {
297+ "todo.spec.js" : {
298+ "sessions" : [
299+ {
300+ "tests" : {
301+ "config_json" : "config_json" ,
302+ "result_json" : "result_json" ,
303+ }
304+ }
305+ ]
306+ }
307+ }
308+ }
309+ it ( "Generate Report Data for cypress version > 6" , async ( ) => {
294310 let configResponse = { data : {
295311 tests : [
296312 {
@@ -317,6 +333,7 @@ describe("reportHTML", () => {
317333 ]
318334 } }
319335 let expectedResponse = {
336+ cypress_version : "6.8.0" ,
320337 rows :{
321338 "todo.spec.js" : {
322339 "sessions" :[ {
@@ -331,10 +348,49 @@ describe("reportHTML", () => {
331348 let axiosGetStub = sandbox . stub ( axios , "get" )
332349 let axiosConfigStub = axiosGetStub . withArgs ( "config_json" ) . resolves ( configResponse ) ;
333350 let axiosResultStub = axiosGetStub . withArgs ( "result_json" ) . resolves ( resultsResponse ) ;
334- let result = await cypressReportData ( cypress_report_data ) ;
351+ let result = await cypressReportData ( cypress_report_data_with_config ) ;
335352 sinon . assert . calledOnce ( axiosConfigStub ) ;
336353 sinon . assert . calledOnce ( axiosResultStub ) ;
337354 expect ( JSON . stringify ( result ) ) . to . be . equal ( JSON . stringify ( expectedResponse ) ) ;
338355 } ) ;
356+
357+ it ( "Generate Report Data for cypress version < 6" , async ( ) => {
358+ let resultsResponse = { data : {
359+ tests : [
360+ {
361+ clientId : "r3" ,
362+ state : "passed" ,
363+ title :[
364+ "file_name" ,
365+ "test_case"
366+ ] ,
367+ attempts :[
368+ {
369+ "state" : "passed" ,
370+ "wallClockDuration" : 62
371+ }
372+ ]
373+ }
374+ ]
375+ } }
376+ let expectedResponse = {
377+ cypress_version : "5.6.0" ,
378+ rows :{
379+ "todo.spec.js" : {
380+ "sessions" :[ {
381+ "tests" :[ {
382+ "name" :"test_case" ,
383+ "status" :"passed" ,
384+ "duration" :"0.06" } ]
385+ } ]
386+ }
387+ }
388+ }
389+ let axiosGetStub = sandbox . stub ( axios , "get" )
390+ let axiosResultStub = axiosGetStub . withArgs ( "result_json" ) . resolves ( resultsResponse ) ;
391+ let result = await cypressReportData ( cypress_report_data_without_config ) ;
392+ sinon . assert . calledOnce ( axiosResultStub ) ;
393+ expect ( JSON . stringify ( result ) ) . to . be . equal ( JSON . stringify ( expectedResponse ) ) ;
394+ } ) ;
339395 } ) ;
340396} ) ;
0 commit comments