11import { test , describe } from "../../drivers/vitest/driver" ;
22import { expect } from "vitest" ;
33import * as precondition from "../../preconditions" ;
4- import { customChecksFailedReasonList , customChecksList } from "./questions/failedCustomChecks" ;
4+ import { customChecksFailedRowsList , customChecksListElement , customChecksMessageElement , customChecksFailedReasonList , customChecksListPaginationElement } from "./questions/failedCustomChecks" ;
55import { waitFor } from "@testing-library/vue" ;
6- import { customCheckItems } from "../../mocks/custom-checks-template" ;
76
87describe ( "FEATURE: Failing custom checks" , ( ) => {
9- describe ( "RULE: Custom checks are displayed" , ( ) => {
8+ describe ( "RULE: Failed custom checks should be displayed" , ( ) => {
109 test ( "EXAMPLE: All custom checks are in a failed state are displayed in a list on the custom checks tab" , async ( { driver } ) => {
1110 await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
12- await driver . setUp ( precondition . hasCustomChecks ) ;
13- // const response = precondition.hasCustomChecks;
14- // const expectedCount = response.headers["Total-Count"];
15- const expectedCount = customCheckItems . filter ( ( check ) => check . status === "Fail" ) . length . toString ( ) ;
11+ await driver . setUp ( precondition . hasCustomChecks ( 5 , 3 ) ) ;
12+
1613 await driver . goTo ( "/custom-checks" ) ;
17- // console.log("resp:" + expectedCount);
14+
1815 await waitFor ( async ( ) => {
19- // expect(await customChecksMessageElement()).not.toBeInTheDocument(); //no data message is not vsible
16+ expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
17+ } ) ;
18+ expect ( customChecksMessageElement ( ) ) . not . toBeInTheDocument ( ) ; //no data message is not vsible
19+ await waitFor ( async ( ) => {
20+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 5 ) ; //count of failed checks matches failing count set
21+
22+ const failedReasonList = await customChecksFailedReasonList ( ) ;
23+ expect ( failedReasonList ) . toHaveLength ( 5 ) ; //count of failed reasons matches failing count set
2024
21- expect ( await customChecksList ( ) ) . toHaveLength ( Number ( expectedCount ) ) ; //count of failed checks matches the response received
22- const failedCustomChecksReasonsList = await customChecksFailedReasonList ( ) ;
23- expect ( failedCustomChecksReasonsList ) . toHaveLength ( Number ( expectedCount ) ) ; //count of failed reasons matches the response received
24- // Ensure that each reason has non-empty text
25- failedCustomChecksReasonsList . forEach ( ( reason ) => {
25+ failedReasonList . forEach ( ( reason ) => {
2626 const textContent = reason . textContent ?. trim ( ) ; // Get the text and trim any surrounding whitespace
27- expect ( textContent ) . not . toBe ( "" ) ; // Assert the text content is not empty
27+ expect ( textContent ) . not . toBe ( "" ) ; // Assert the failed reason text content is not empty
2828 } ) ;
2929 } ) ;
3030 } ) ;
3131 } ) ;
32+
33+ describe ( "RULE: Failed custom checks should have pagination when failed checks count is greater than 50" , ( ) => {
34+ test ( "EXAMPLE: 51 failed custom checks is paginated on the custom checks tab" , async ( { driver } ) => {
35+ await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
36+ await driver . setUp ( precondition . hasCustomChecks ( 51 , 3 ) ) ;
37+
38+ await driver . goTo ( "/custom-checks" ) ;
39+
40+ await waitFor ( async ( ) => {
41+ expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
42+ } ) ;
43+ expect ( customChecksListPaginationElement ( ) ) . toBeInTheDocument ( ) ; //pagination vsible
44+ await waitFor ( async ( ) => {
45+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 51 ) ; //count of failed checks matches failing count set
46+ } ) ;
47+ } ) ;
48+
49+ test ( "EXAMPLE: 49 failed custom checks is not paginated on the custom checks tab" , async ( { driver } ) => {
50+ await driver . setUp ( precondition . serviceControlWithMonitoring ) ;
51+ await driver . setUp ( precondition . hasCustomChecks ( 49 , 3 ) ) ;
52+
53+ await driver . goTo ( "/custom-checks" ) ;
54+
55+ await waitFor ( async ( ) => {
56+ expect ( await customChecksListElement ( ) ) . toBeInTheDocument ( ) ; //failed list is visisble
57+ } ) ;
58+ expect ( customChecksListPaginationElement ( ) ) . not . toBeInTheDocument ( ) ; //pagination vsible
59+ await waitFor ( async ( ) => {
60+ expect ( await customChecksFailedRowsList ( ) ) . toHaveLength ( 49 ) ; //count of failed checks matches failing count set
61+ } ) ;
62+ } ) ;
63+ } ) ;
3264 describe ( "RULE: Failed custom checks should be shown in descending order of last checked" , ( ) => {
3365 test . todo ( "EXAMPLE: Three failed custom checks is displayed in descending order of last checked on the custom checks tab" ) ;
3466
@@ -39,25 +71,6 @@ describe("FEATURE: Failing custom checks", () => {
3971 Then the custom checks are shown in descending order of last checked
4072 */
4173 } ) ;
42- describe ( "RULE: Failed custom checks should have pagination" , ( ) => {
43- test . todo ( "EXAMPLE: 51 failed custom checks is paginated on the custom checks tab" ) ;
44-
45- /* SCENARIO
46- Given there are 51 failed custom checks
47- When navigating to the custom checks tab
48- Then the pagination controls should be visible
49- And the page number should be 1
50- And only the first 50 custom checks should be rendered
51- And page 2 should be available to click on
52- */
53-
54- test . todo ( "EXAMPLE: 49 failed custom checks is not paginated on the custom checks tab" ) ;
55- /* SCENARIO
56- Given there are 49 failed custom checks
57- When navigating to the custom checks tab
58- Then the pagination controls should not be visible
59- */
60- } ) ;
6174 describe ( "RULE: Custom checks should auto-refresh" , ( ) => {
6275 test . todo ( "EXAMPLE: When a custom check fails, the custom checks tab is auto-refreshed with the new failed custom check" ) ;
6376
0 commit comments