Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Frontend/src/components/heartbeats/EndpointInstances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function proceedWarningDialog() {
await store.toggleEndpointMonitor(
filteredValidInstances.value.filter((instance) => (dialogWarningOperation.value === Operation.Unmute && !instance.monitor_heartbeat) || (dialogWarningOperation.value === Operation.Mute && instance.monitor_heartbeat))
);
useShowToast(TYPE.SUCCESS, `All endpoint instances ${dialogWarningOperation.value}`, "", false, { timeout: 1000 });
useShowToast(TYPE.SUCCESS, `All endpoint instances ${dialogWarningOperation.value === Operation.Mute ? "muted" : "unmuted"}`, "", false, { timeout: 1000 });
} catch {
useShowToast(TYPE.ERROR, "Save failed", "", false, { timeout: 3000 });
}
Expand All @@ -105,9 +105,10 @@ async function deleteAllInstances() {
}

async function toggleAlerts(instance: EndpointsView) {
const muting = instance.monitor_heartbeat;
try {
await store.toggleEndpointMonitor([instance]);
useShowToast(TYPE.SUCCESS, `Endpoint instance ${!instance.monitor_heartbeat ? "muted" : "unmuted"}`, "", false, { timeout: 1000 });
useShowToast(TYPE.SUCCESS, `Endpoint instance ${muting ? "muted" : "unmuted"}`, "", false, { timeout: 1000 });
} catch {
useShowToast(TYPE.ERROR, "Save failed", "", false, { timeout: 3000 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { getHeartbeatFilterValue } from "./questions/getHeartbeatFilterValue";
import { getListedEndpointNames } from "./questions/getListedEndpointNames";
import { getColumnSortDirection } from "./questions/getColumnSortDirection";
import { sortEndpointsBy } from "./actions/sortEndpointsBy";
import { waitFor } from "@testing-library/vue";
import { screen, waitFor } from "@testing-library/vue";
import UserEvent from "@testing-library/user-event";
import { EndpointStatus } from "@/resources/Heartbeat";
import { isNotificationVisible } from "../configuration/questions/notifications";

vi.mock("@vueuse/core", async (importOriginal) => {
const originalModule = await importOriginal<typeof import("@vueuse/core")>();
Expand Down Expand Up @@ -139,6 +141,37 @@ describe("FEATURE: Heartbeats configuration", () => {
expect(healthyEndpoint).toBeTruthy();
expect(healthyEndpoint?.instancesMuted).toBe(0);
});

test("EXAMPLE: Muting and then unmuting an instance shows a toast that matches each action", async ({ driver }) => {
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.HasHealthyAndUnHealthyEndpoints(1, 1));
await driver.goTo("heartbeats/instances/TestEndpoint_1");

await toggleHeartbeatMonitoring("TestEndpoint_1");

await waitFor(() => expect(isNotificationVisible(/^endpoint instance muted$/i)).toBe(true));
expect(isNotificationVisible(/^endpoint instance unmuted$/i)).toBe(false);

await toggleHeartbeatMonitoring("TestEndpoint_1");

await waitFor(() => expect(isNotificationVisible(/^endpoint instance unmuted$/i)).toBe(true));
});

test("EXAMPLE: Muting and then unmuting all instances shows a toast that says muted and then unmuted", async ({ driver }) => {
await driver.setUp(precondition.serviceControlWithMonitoring);
await driver.setUp(precondition.HasHealthyAndUnHealthyEndpoints(1, 1));
await driver.goTo("heartbeats/instances/TestEndpoint_1");

await UserEvent.click(await screen.findByRole("button", { name: /Mute Alerts on All/ }));
await UserEvent.click(await screen.findByRole("button", { name: "Yes" }));

await waitFor(() => expect(isNotificationVisible(/^all endpoint instances muted$/i)).toBe(true));

await UserEvent.click(await screen.findByRole("button", { name: /Unmute Alerts on All/ }));
await UserEvent.click(await screen.findByRole("button", { name: "Yes" }));

await waitFor(() => expect(isNotificationVisible(/^all endpoint instances unmuted$/i)).toBe(true));
});
});

describe("RULE: Sorting by of the name of an endpoint should be possible in all displays", () => {
Expand Down
Loading