@@ -8,8 +8,11 @@ import { updateCustomCheckItemByStatus } from "../../preconditions/customChecks"
88describe ( "FEATURE: Failing custom checks" , ( ) => {
99 describe ( "RULE: Failed custom checks should be displayed" , ( ) => {
1010 test ( "EXAMPLE: All custom checks are in a failed state are displayed in a list on the custom checks tab" , async ( { driver } ) => {
11+ const failingCustomCheckCount = 5 ;
12+ const passingCustomCheckCount = 3 ;
13+
1114 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
12- await driver . setUp ( precondition . hasCustomChecks ( 5 , 3 ) ) ;
15+ await driver . setUp ( precondition . hasCustomChecks ( failingCustomCheckCount , passingCustomCheckCount ) ) ;
1316
1417 await driver . goTo ( "/custom-checks" ) ;
1518
@@ -18,62 +21,71 @@ describe("FEATURE: Failing custom checks", () => {
1821 } ) ;
1922 expect ( customChecksMessageElement ( ) ) . not . toBeInTheDocument ( ) ; //no data message is not vsible
2023 await waitFor ( async ( ) => {
21- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 5 ) ; //count of failed checks matches failing count set
24+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
2225
2326 const failedReasonList = await customChecksFailedReasonList ( ) ;
24- expect ( failedReasonList ) . toHaveLength ( 5 ) ; //count of failed reasons matches failing count set
27+ expect ( failedReasonList ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed reasons matches failing count set
2528
2629 failedReasonList . forEach ( ( reason ) => {
27- const textContent = reason . textContent ?. trim ( ) ; // Get the text and trim any surrounding whitespace
28- expect ( textContent ) . not . toBe ( "" ) ; // Assert the failed reason text content is not empty
30+ const textContent = reason . textContent ?. trim ( ) ;
31+ expect ( textContent ) . not . toBe ( "" ) ; // the failed reason text content is not empty
2932 } ) ;
3033 } ) ;
3134 } ) ;
3235 } ) ;
3336
3437 describe ( "RULE: Failed custom checks should have pagination when failed checks count is greater than 10" , ( ) => {
3538 test ( "EXAMPLE: 11 failed custom checks is paginated on the custom checks tab" , async ( { driver } ) => {
39+ const failingCustomCheckCount = 11 ;
40+ const passingCustomCheckCount = 3 ;
41+
3642 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
37- await driver . setUp ( precondition . hasCustomChecks ( 11 , 3 ) ) ;
43+ await driver . setUp ( precondition . hasCustomChecks ( failingCustomCheckCount , passingCustomCheckCount ) ) ;
3844
3945 await driver . goTo ( "/custom-checks" ) ;
4046
4147 await waitFor ( async ( ) => {
42- expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
48+ expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list visible
4349 } ) ;
44- expect ( customChecksListPaginationElement ( ) ) . toBeInTheDocument ( ) ; //pagination vsible
50+ expect ( customChecksListPaginationElement ( ) ) . toBeInTheDocument ( ) ; //pagination visible
4551 await waitFor ( async ( ) => {
46- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 11 ) ; //count of failed checks matches failing count set
52+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
4753 } ) ;
4854 } ) ;
4955
5056 test ( "EXAMPLE: 9 failed custom checks is not paginated on the custom checks tab" , async ( { driver } ) => {
57+ const failingCustomCheckCount = 9 ;
58+ const passingCustomCheckCount = 3 ;
59+
5160 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
52- await driver . setUp ( precondition . hasCustomChecks ( 9 , 3 ) ) ;
61+ await driver . setUp ( precondition . hasCustomChecks ( failingCustomCheckCount , passingCustomCheckCount ) ) ;
5362
5463 await driver . goTo ( "/custom-checks" ) ;
5564
5665 await waitFor ( async ( ) => {
5766 expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
5867 } ) ;
59- expect ( customChecksListPaginationElement ( ) ) . not . toBeInTheDocument ( ) ; //pagination vsible
68+ expect ( customChecksListPaginationElement ( ) ) . not . toBeInTheDocument ( ) ; //pagination not visible
6069 await waitFor ( async ( ) => {
61- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 9 ) ; //count of failed checks matches failing count set
70+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
6271 } ) ;
6372 } ) ;
6473 } ) ;
6574 describe ( "RULE: Failed custom checks should be shown in descending order of last checked" , ( ) => {
6675 test ( "EXAMPLE:Three failed custom checks is displayed in descending order of last checked on the custom checks tab" , async ( { driver } ) => {
76+ const failingCustomCheckCount = 5 ;
77+ const passingCustomCheckCount = 3 ;
78+
6779 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
68- await driver . setUp ( precondition . hasCustomChecks ( 3 , 3 ) ) ;
80+ await driver . setUp ( precondition . hasCustomChecks ( failingCustomCheckCount , passingCustomCheckCount ) ) ;
6981
7082 await driver . goTo ( "/custom-checks" ) ;
7183
7284 await waitFor ( async ( ) => {
7385 expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
7486 } ) ;
7587 await waitFor ( async ( ) => {
76- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 3 ) ; //count of failed checks matches failing count set
88+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
7789 } ) ;
7890
7991 const timestamps = await customChecksReportedDateList ( ) ; // Ensure this is awaited correctly
@@ -86,8 +98,11 @@ describe("FEATURE: Failing custom checks", () => {
8698 } ) ;
8799 describe ( "RULE: Custom checks should auto-refresh" , ( ) => {
88100 test ( "EXAMPLE:When a custom check fails, the custom checks tab is auto-refreshed with the new failed custom check" , async ( { driver } ) => {
101+ const failingCustomCheckCount = 3 ;
102+ const passingCustomCheckCount = 2 ;
103+
89104 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
90- const customCheckItems = precondition . generateCustomChecksData ( 3 , 2 ) ( ) ;
105+ const customCheckItems = precondition . generateCustomChecksData ( failingCustomCheckCount , passingCustomCheckCount ) ( ) ;
91106 await driver . setUp ( precondition . getCustomChecks ( customCheckItems ) ) ;
92107
93108 await driver . goTo ( "/custom-checks" ) ;
@@ -96,22 +111,24 @@ describe("FEATURE: Failing custom checks", () => {
96111 expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
97112 } ) ;
98113 await waitFor ( async ( ) => {
99- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 3 ) ; //count of failed checks matches failing count set
114+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
100115 } ) ;
101116
102117 updateCustomCheckItemByStatus ( customCheckItems , "Pass" ) ; // Fail an existing item that is passing
103-
104118 await driver . setUp ( precondition . getCustomChecks ( customCheckItems ) ) ;
105119
106120 await driver . goTo ( "/custom-checks" ) ;
107121 await waitFor ( async ( ) => {
108- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 4 ) ; // Now it should be 4
122+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount + 1 ) ; // Now it should be increased by 1
109123 } ) ;
110124 } ) ;
111125
112126 test ( "EXAMPLE: A failing custom check that begins passing is auto-refreshed and removed from the list on the custom checks tab" , async ( { driver } ) => {
127+ const failingCustomCheckCount = 3 ;
128+ const passingCustomCheckCount = 2 ;
129+
113130 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
114- const customCheckItems = precondition . generateCustomChecksData ( 3 , 2 ) ( ) ;
131+ const customCheckItems = precondition . generateCustomChecksData ( failingCustomCheckCount , passingCustomCheckCount ) ( ) ;
115132 await driver . setUp ( precondition . getCustomChecks ( customCheckItems ) ) ;
116133
117134 await driver . goTo ( "/custom-checks" ) ;
@@ -120,7 +137,7 @@ describe("FEATURE: Failing custom checks", () => {
120137 expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
121138 } ) ;
122139 await waitFor ( async ( ) => {
123- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 3 ) ; //count of failed checks matches failing count set
140+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount ) ; //count of failed checks matches failing count set
124141 } ) ;
125142
126143 updateCustomCheckItemByStatus ( customCheckItems , "Fail" ) ; // an existing item that is failing
@@ -129,7 +146,7 @@ describe("FEATURE: Failing custom checks", () => {
129146
130147 await driver . goTo ( "/custom-checks" ) ;
131148 await waitFor ( async ( ) => {
132- expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 2 ) ; // Now it should be 2
149+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( failingCustomCheckCount - 1 ) ; // Now it should be decreased by 1
133150 } ) ;
134151 } ) ;
135152 } ) ;
0 commit comments