Skip to content

Commit 9ee4a9a

Browse files
committed
Add heartbeat menu item tests
1 parent 46471a2 commit 9ee4a9a

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/Frontend/test/preconditions/hasHeartbeatEndpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const hasAnUnhealthyUnMonitoredEndpoint = () => {
6464
is_sending_heartbeats: true,
6565
id: "",
6666
name: `Unhealthy_UnmonitoredEndpoint`,
67-
monitor_heartbeat: true,
67+
monitor_heartbeat: false,
6868
host_display_name: "",
6969
heartbeat_information: { reported_status: EndpointStatus.Dead, last_report_at: "" },
7070
},

src/Frontend/test/specs/heartbeats/menu-item.spec.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ describe("FEATURE: Menu item", () => {
2121
});
2222

2323
/* SCENARIO
24-
Given 5 monitored endpoint instances sending heartbeats
25-
When 1 of the endpoint instances stops sending heartbeats
26-
Then the menu item in the page header updates to include a badge indicating how many have stopped
24+
Given a monitored endpoint instance sending heartbeats
25+
When the endpoint instance stops sending heartbeats
26+
Then the menu item in the page header updates to include a badge indicating it has stopped
2727
*/
28-
2928
test("EXAMPLE: An instance starts sending heartbeats, the menu item should remove the badge", async ({ driver }) => {
3029
vi.useFakeTimers();
3130
await driver.setUp(precondition.serviceControlWithMonitoring);
@@ -54,19 +53,24 @@ describe("FEATURE: Menu item", () => {
5453

5554
vi.restoreAllMocks();
5655
});
56+
5757
/* SCENARIO
5858
Given a set of monitored endpoint instances
5959
When all instances are sending heartbeats
6060
Then the menu item in the page header does not include a badge
6161
*/
62+
test("EXAMPLE: An unmonitored instance stops sending heartbeats, the menu item should not show a badge with a count", async ({ driver }) => {
63+
await driver.setUp(precondition.serviceControlWithMonitoring);
64+
await driver.setUp(precondition.hasAnUnhealthyUnMonitoredEndpoint());
6265

63-
test.todo("EXAMPLE: An unmonitored instance stops sending heartbeats, the menu item should not show a badge with a count");
66+
await driver.goTo("dashboard");
6467

65-
/* SCENARIO
66-
Given a set of monitored endpoint instances
67-
And 1 unmonitored endpoint instance
68-
When the unmonitored endpoint instance is not sending heartbeats
69-
Then the menu item badge is not displayed
70-
*/
68+
await waitFor(async () => {
69+
const heartbeatMenuItem = await queryHeartbeatMenuItem();
70+
71+
expect(heartbeatMenuItem && !heartbeatMenuItem.isCounterVisible).toBeTruthy();
72+
expect(heartbeatMenuItem && heartbeatMenuItem.counterValue).toBe(0);
73+
});
74+
});
7175
});
7276
});

0 commit comments

Comments
 (0)