@@ -49,6 +49,69 @@ describe("qa suite summary helpers", () => {
4949 }
5050 } ) ;
5151
52+ it . each ( [
53+ [ "failure" , readQaSuiteFailedScenarioCountFromFile ] ,
54+ [ "failure and skip" , readQaSuiteFailedOrSkippedScenarioCountFromFile ] ,
55+ ] as const ) (
56+ "does not authenticate a positive total without completed %s evidence" ,
57+ async ( _name , reader ) => {
58+ await expect (
59+ readSummary ( { counts : { total : 1 , passed : 0 , failed : 0 , skipped : 0 } } , reader ) ,
60+ ) . rejects . toThrow ( "did not include any executed scenarios" ) ;
61+ } ,
62+ ) ;
63+
64+ it ( "does not let a claimed passed count override observed skipped-only scenarios" , async ( ) => {
65+ const summary = {
66+ counts : { total : 1 , passed : 1 , failed : 0 , skipped : 0 } ,
67+ scenarios : [ { name : "never executed" , status : "skip" } ] ,
68+ } ;
69+
70+ await expect ( readSummary ( summary , readQaSuiteFailedScenarioCountFromFile ) ) . rejects . toThrow (
71+ "did not include any executed scenarios" ,
72+ ) ;
73+ await expect (
74+ readSummary ( summary , readQaSuiteFailedOrSkippedScenarioCountFromFile ) ,
75+ ) . resolves . toBe ( 1 ) ;
76+ } ) ;
77+
78+ it . each ( [
79+ [ "null" , null ] ,
80+ [ "array" , [ ] ] ,
81+ [ "string" , "corrupt counts" ] ,
82+ [ "number" , 1 ] ,
83+ ] as const ) (
84+ "rejects %s counts containers even when a scenario claims to pass" ,
85+ async ( _name , counts ) => {
86+ const summary = { counts, scenarios : [ { status : "pass" } ] } ;
87+
88+ await expect ( readSummary ( summary , readQaSuiteFailedScenarioCountFromFile ) ) . rejects . toThrow (
89+ "counts must be a non-array object" ,
90+ ) ;
91+ await expect (
92+ readSummary ( summary , readQaSuiteFailedOrSkippedScenarioCountFromFile ) ,
93+ ) . rejects . toThrow ( "counts must be a non-array object" ) ;
94+ } ,
95+ ) ;
96+
97+ it . each ( [
98+ [ "negative failed" , { total : 1 , passed : 1 , failed : - 1 , skipped : 0 } ] ,
99+ [ "fractional failed" , { total : 1 , passed : 1 , failed : 0.75 , skipped : 0 } ] ,
100+ [ "unsafe passed" , { total : 1 , passed : Number . MAX_SAFE_INTEGER + 1 , failed : 0 , skipped : 0 } ] ,
101+ ] as const ) (
102+ "rejects %s instead of normalizing an invalid execution count" ,
103+ async ( _name , counts ) => {
104+ const summary = { counts, scenarios : [ { status : "pass" } ] } ;
105+
106+ await expect ( readSummary ( summary , readQaSuiteFailedScenarioCountFromFile ) ) . rejects . toThrow (
107+ "must be a non-negative safe integer" ,
108+ ) ;
109+ await expect (
110+ readSummary ( summary , readQaSuiteFailedOrSkippedScenarioCountFromFile ) ,
111+ ) . rejects . toThrow ( "must be a non-negative safe integer" ) ;
112+ } ,
113+ ) ;
114+
52115 it ( "counts failed and skipped scenarios from scenario statuses" , async ( ) => {
53116 await expect (
54117 readSummary (
@@ -379,7 +442,7 @@ describe("qa suite summary helpers", () => {
379442 ) . resolves . toBe ( 1 ) ;
380443 await expect (
381444 readSummary (
382- { counts : { failed : 3.8 } , scenarios : [ { status : "pass" } , { status : "fail" } ] } ,
445+ { counts : { failed : 3 } , scenarios : [ { status : "pass" } , { status : "fail" } ] } ,
383446 readQaSuiteFailedScenarioCountFromFile ,
384447 ) ,
385448 ) . resolves . toBe ( 3 ) ;
@@ -426,7 +489,7 @@ describe("qa suite summary helpers", () => {
426489
427490 it ( "rejects unsupported summary shapes" , async ( ) => {
428491 await expect (
429- readSummary ( { counts : { total : 2 } } , readQaSuiteFailedScenarioCountFromFile ) ,
492+ readSummary ( { counts : { total : 2 , passed : 2 } } , readQaSuiteFailedScenarioCountFromFile ) ,
430493 ) . rejects . toThrow ( "did not include counts.failed" ) ;
431494 await expect (
432495 readSummary ( "not-json-object" , readQaSuiteFailedScenarioCountFromFile ) ,
@@ -474,7 +537,7 @@ describe("qa suite summary helpers", () => {
474537 it ( "fails summary files without a failure signal" , async ( ) => {
475538 const outputDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "qa-suite-summary-" ) ) ;
476539 const summaryPath = path . join ( outputDir , "qa-suite-summary.json" ) ;
477- await fs . writeFile ( summaryPath , JSON . stringify ( { counts : { total : 1 } } ) , "utf8" ) ;
540+ await fs . writeFile ( summaryPath , JSON . stringify ( { counts : { total : 1 , passed : 1 } } ) , "utf8" ) ;
478541
479542 try {
480543 await expect ( readQaSuiteFailedScenarioCountFromFile ( summaryPath ) ) . rejects . toThrow (
0 commit comments