11import { test , describe } from "../../drivers/vitest/driver" ;
2+ import { expect } from "vitest" ;
3+ import * as precondition from "../../preconditions" ;
4+ import { customChecksFailedReasonList , customChecksList } from "./questions/failedCustomChecks" ;
5+ import { waitFor } from "@testing-library/vue" ;
6+ import { customCheckItems } from "../../mocks/custom-checks-template" ;
27
38describe ( "FEATURE: Failing custom checks" , ( ) => {
49 describe ( "RULE: Custom checks are displayed" , ( ) => {
5- test . todo ( "EXAMPLE: All custom checks are in a failed state and should be displayed in a list on the custom checks tab" ) ;
10+ test ( "EXAMPLE: All custom checks are in a failed state are displayed in a list on the custom checks tab" , async ( { driver } ) => {
11+ 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 ( ) ;
16+ await driver . goTo ( "/custom-checks" ) ;
17+ // console.log("resp:" + expectedCount);
18+ await waitFor ( async ( ) => {
19+ // expect(await customChecksMessageElement()).not.toBeInTheDocument(); //no data message is not vsible
620
7- /* SCENARIO
8- Given there are custom checks
9- And all custom checks are in a failed state
10- When navigating to the custom checks tab
11- Then a list of custom checks is shown
12- */
13-
14- /* NOTES
15- Failure reason (if given)
16- Name (Check)
17- Category
18- Endpoint
19- Host
20- Last checked
21- */
22- } ) ;
23- describe ( "RULE: Only failed custom checks are displayed" , ( ) => {
24- test . todo ( "EXAMPLE: Only failed custom checks should be displayed in the list on the custom checks tab" ) ;
25-
26- /* SCENARIO
27- Given there are two failed custom checks
28- And one passing custom check
29- When navigating to the custom checks tab
30- Then the two failed custom checks are shown
31- And the passing custom check is not shown
32- */
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 ) => {
26+ 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
28+ } ) ;
29+ } ) ;
30+ } ) ;
3331 } ) ;
3432 describe ( "RULE: Failed custom checks should be shown in descending order of last checked" , ( ) => {
35- test . todo ( "EXAMPLE: Three failed custom checks should be displayed in descending order of last checked on the custom checks tab" ) ;
33+ test . todo ( "EXAMPLE: Three failed custom checks is displayed in descending order of last checked on the custom checks tab" ) ;
3634
3735 /* SCENARIO
3836 Given there are three failed custom checks
@@ -42,7 +40,7 @@ describe("FEATURE: Failing custom checks", () => {
4240 */
4341 } ) ;
4442 describe ( "RULE: Failed custom checks should have pagination" , ( ) => {
45- test . todo ( "EXAMPLE: 51 failed custom checks should be paginated on the custom checks tab" ) ;
43+ test . todo ( "EXAMPLE: 51 failed custom checks is paginated on the custom checks tab" ) ;
4644
4745 /* SCENARIO
4846 Given there are 51 failed custom checks
@@ -53,15 +51,15 @@ describe("FEATURE: Failing custom checks", () => {
5351 And page 2 should be available to click on
5452 */
5553
56- test . todo ( "EXAMPLE: 49 failed custom checks should not be paginated on the custom checks tab" ) ;
54+ test . todo ( "EXAMPLE: 49 failed custom checks is not paginated on the custom checks tab" ) ;
5755 /* SCENARIO
5856 Given there are 49 failed custom checks
5957 When navigating to the custom checks tab
6058 Then the pagination controls should not be visible
6159 */
6260 } ) ;
6361 describe ( "RULE: Custom checks should auto-refresh" , ( ) => {
64- test . todo ( "EXAMPLE: When a custom check fails, the custom checks tab should auto-refresh with the new failed custom check" ) ;
62+ test . todo ( "EXAMPLE: When a custom check fails, the custom checks tab is auto-refreshed with the new failed custom check" ) ;
6563
6664 /* SCENARIO
6765 Given 2 passing custom checks
@@ -70,7 +68,7 @@ describe("FEATURE: Failing custom checks", () => {
7068 Then the failing custom check should be rendered
7169 */
7270
73- test . todo ( "EXAMPLE: A failing custom check that begins passing should be removed from the list on the custom checks tab" ) ;
71+ test . todo ( "EXAMPLE: A failing custom check that begins passing is auto-refreshed and removed from the list on the custom checks tab" ) ;
7472 /* SCENARIO
7573 Given 2 failing custom checks
7674 And the custom checks page is open
0 commit comments