@@ -3,9 +3,7 @@ import { customCheckItems } from "../mocks/custom-checks-template";
33
44const content = JSON . stringify ( [ ] ) ;
55const failedCustomCheckItems = customCheckItems . filter ( ( check ) => check . status === "Fail" ) ;
6- const failedCustomCheckCount = failedCustomCheckItems . length . toString ( ) ;
76const passedCustomCheckItems = customCheckItems . filter ( ( check ) => check . status === "Pass" ) ;
8- const passedCustomCheckCount = passedCustomCheckItems . length . toString ( ) ;
97
108export const hasCustomChecksEmpty = ( { driver } : SetupFactoryOptions ) => {
119 const serviceControlInstanceUrl = window . defaultConfig . service_control_url ;
@@ -16,21 +14,30 @@ export const hasCustomChecksEmpty = ({ driver }: SetupFactoryOptions) => {
1614 } ,
1715 } ) ;
1816} ;
17+
1918export const hasCustomChecksFailing = ( { driver } : SetupFactoryOptions ) => {
2019 const serviceControlInstanceUrl = window . defaultConfig . service_control_url ;
21- driver . mockEndpoint ( `${ serviceControlInstanceUrl } customchecks` , {
22- body : failedCustomCheckItems ,
23- headers : {
24- "Total-Count" : failedCustomCheckCount , //count of failing custom checks
25- } ,
20+ driver . mockEndpointDynamic ( `${ serviceControlInstanceUrl } customchecks` , ( url ) => {
21+ const status = url . searchParams . get ( "status" ) ;
22+ if ( status === "fail" ) {
23+ return {
24+ body : failedCustomCheckItems ,
25+ headers : { "Total-Count" : failedCustomCheckItems . length . toString ( ) } ,
26+ } ;
27+ }
28+
29+ return {
30+ body : passedCustomCheckItems ,
31+ headers : { "Total-Count" : passedCustomCheckItems . length . toString ( ) } ,
32+ } ;
2633 } ) ;
2734} ;
2835export const hasCustomChecksPassing = ( { driver } : SetupFactoryOptions ) => {
2936 const serviceControlInstanceUrl = window . defaultConfig . service_control_url ;
3037 driver . mockEndpoint ( `${ serviceControlInstanceUrl } customchecks` , {
3138 body : passedCustomCheckItems ,
3239 headers : {
33- "Total-Count" : passedCustomCheckCount , //count of passing custom checks
40+ "Total-Count" : passedCustomCheckItems . length . toString ( ) , //count of passing custom checks
3441 } ,
3542 } ) ;
3643} ;
0 commit comments