|
1 | 1 | import { test, describe } from "../../drivers/vitest/driver"; |
| 2 | +import { expect } from "vitest"; |
| 3 | +import * as precondition from "../../preconditions"; |
| 4 | +import { customChecksListElement, customChecksDismissButtonList } from "./questions/failedCustomChecks"; |
| 5 | +import { waitFor } from "@testing-library/vue"; |
| 6 | +import userEvent from "@testing-library/user-event"; |
2 | 7 |
|
3 | 8 | describe("FEATURE: Dismiss custom checks", () => { |
4 | 9 | describe("RULE: Dismiss button should be visible", () => { |
5 | | - test.todo("EXAMPLE: Dismiss button should be visible on each failing custom check"); |
| 10 | + test("EXAMPLE: Dismiss button is visible on each failing custom check", async ({ driver }) => { |
| 11 | + await driver.setUp(precondition.serviceControlWithMonitoring); |
| 12 | + await driver.setUp(precondition.hasCustomChecks(9, 3)); |
6 | 13 |
|
7 | | - /* SCENARIO |
8 | | - Given 2 failing custom checks |
9 | | - And the custom checks page is open |
10 | | - Then each should render a dismiss button |
11 | | - */ |
| 14 | + await driver.goTo("/custom-checks"); |
| 15 | + |
| 16 | + await waitFor(async () => { |
| 17 | + expect(await customChecksListElement()).toBeInTheDocument(); |
| 18 | + }); |
| 19 | + |
| 20 | + await waitFor(async () => { |
| 21 | + expect(await customChecksDismissButtonList()).toHaveLength(9); //count of dismiss button |
| 22 | + }); |
| 23 | + }); |
12 | 24 | }); |
13 | 25 | describe("RULE: Dismissing a custom check should remove from the list", () => { |
14 | | - test.todo("EXAMPLE: The dismiss button should remove the custom check from the list when clicked"); |
| 26 | + test("EXAMPLE: The dismiss button removes the custom check from the list when clicked", async ({ driver }) => { |
| 27 | + await driver.setUp(precondition.serviceControlWithMonitoring); |
| 28 | + await driver.setUp(precondition.hasCustomChecks(3, 2)); |
15 | 29 |
|
16 | | - /* SCENARIO |
17 | | - Given 2 failing custom checks |
18 | | - When the dismiss button is clicked |
19 | | - Then the dismissed custom check should be removed from the list |
20 | | - */ |
| 30 | + await driver.goTo("/custom-checks"); |
| 31 | + |
| 32 | + await waitFor(async () => { |
| 33 | + expect(await customChecksListElement()).toBeInTheDocument(); //failed list is visisble |
| 34 | + }); |
| 35 | + |
| 36 | + //await waitFor(async () => { |
| 37 | + // const dismissButtonList = await customChecksDismissButtonList(); |
| 38 | + // expect(dismissButtonList).toHaveLength(3); //count of dismiss button |
| 39 | + // const dismissButton = dismissButtonList[0]; |
| 40 | + // await userEvent.click(dismissButton); |
| 41 | + // }); |
| 42 | + //get one of the dismiss button |
| 43 | + // const dismissButton = await screen.getAllByRole("button", { name: /custom-check-dismiss/i })[0]; |
| 44 | + |
| 45 | + // Simulate user click event |
| 46 | + |
| 47 | + //list count should decrease by one - |
| 48 | + //make sure that the id is notvisible on the page |
| 49 | + // await waitFor(async () => { |
| 50 | + // expect(await customChecksDismissButtonList()).toHaveLength(2); //count of dismiss button |
| 51 | + // }); |
| 52 | + }); |
21 | 53 | }); |
22 | 54 | describe("RULE: Failing after a dismiss should cause the failed check to reappear", () => { |
23 | 55 | test.todo("EXAMPLE: Dismissed custom check should reappear in the list when it fails"); |
|
0 commit comments