matches snapshot with empty matcher 1`] = `
+"
+
+ 0
+
+"
+`;
diff --git a/ui/src/Components/SilenceModal/SilenceMatch.js b/ui/src/Components/SilenceModal/SilenceMatch/index.js
similarity index 85%
rename from ui/src/Components/SilenceModal/SilenceMatch.js
rename to ui/src/Components/SilenceModal/SilenceMatch/index.js
index 9c4357b3e..cd3163627 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch.js
+++ b/ui/src/Components/SilenceModal/SilenceMatch/index.js
@@ -7,6 +7,7 @@ import { observer } from "mobx-react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faTrash } from "@fortawesome/free-solid-svg-icons/faTrash";
+import { SilenceFormStore } from "Stores/SilenceFormStore";
import { SilenceFormMatcher } from "Models/SilenceForm";
import { LabelNameInput } from "./LabelNameInput";
import { LabelValueInput } from "./LabelValueInput";
@@ -14,6 +15,7 @@ import { LabelValueInput } from "./LabelValueInput";
const SilenceMatch = observer(
class SilenceMatch extends Component {
static propTypes = {
+ silenceFormStore: PropTypes.instanceOf(SilenceFormStore).isRequired,
matcher: SilenceFormMatcher.isRequired,
showDelete: PropTypes.bool.isRequired,
onDelete: PropTypes.func.isRequired,
@@ -30,7 +32,13 @@ const SilenceMatch = observer(
});
render() {
- const { matcher, showDelete, onDelete, isValid } = this.props;
+ const {
+ silenceFormStore,
+ matcher,
+ showDelete,
+ onDelete,
+ isValid
+ } = this.props;
return (
@@ -38,7 +46,11 @@ const SilenceMatch = observer(
-
+
diff --git a/ui/src/Components/SilenceModal/SilenceMatch.test.js b/ui/src/Components/SilenceModal/SilenceMatch/index.test.js
similarity index 96%
rename from ui/src/Components/SilenceModal/SilenceMatch.test.js
rename to ui/src/Components/SilenceModal/SilenceMatch/index.test.js
index ffd7897df..74acb12e4 100644
--- a/ui/src/Components/SilenceModal/SilenceMatch.test.js
+++ b/ui/src/Components/SilenceModal/SilenceMatch/index.test.js
@@ -7,7 +7,7 @@ import {
NewEmptyMatcher,
MatcherValueToObject
} from "Stores/SilenceFormStore";
-import { SilenceMatch } from "./SilenceMatch";
+import { SilenceMatch } from ".";
let silenceFormStore;
let matcher;
diff --git a/ui/src/Components/SilenceModal/SilenceModalContent.js b/ui/src/Components/SilenceModal/SilenceModalContent.js
index be7109652..33243f048 100644
--- a/ui/src/Components/SilenceModal/SilenceModalContent.js
+++ b/ui/src/Components/SilenceModal/SilenceModalContent.js
@@ -7,11 +7,12 @@ import { observer } from "mobx-react";
import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock";
import { AlertStore } from "Stores/AlertStore";
-import { SilenceFormStore } from "Stores/SilenceFormStore";
+import { SilenceFormStore, SilenceFormStage } from "Stores/SilenceFormStore";
import { Settings } from "Stores/Settings";
import { MountModalBackdrop } from "Components/Animations/MountModal";
import { SilenceForm } from "./SilenceForm";
-import { SilenceSubmitController } from "./SilenceSubmitController";
+import { SilencePreview } from "./SilencePreview";
+import { SilenceSubmitController } from "./SilenceSubmit/SilenceSubmitController";
const SilenceModalContent = observer(
class SilenceModalContent extends Component {
@@ -46,7 +47,13 @@ const SilenceModalContent = observer(
{silenceFormStore.data.silenceID === null
- ? "Add new silence"
+ ? silenceFormStore.data.currentStage ===
+ SilenceFormStage.UserInput
+ ? "Add new silence"
+ : silenceFormStore.data.currentStage ===
+ SilenceFormStage.Preview
+ ? "Preview silenced alerts"
+ : "Silence submitted"
: `Editing silence ${silenceFormStore.data.silenceID}`}
- {silenceFormStore.data.inProgress ? (
-
- ) : (
+ {silenceFormStore.data.currentStage ===
+ SilenceFormStage.UserInput ? (
+ ) : silenceFormStore.data.currentStage ===
+ SilenceFormStage.Preview ? (
+
+ ) : (
+
)}
diff --git a/ui/src/Components/SilenceModal/SilenceModalContent.test.js b/ui/src/Components/SilenceModal/SilenceModalContent.test.js
index 0e9497637..edb033e25 100644
--- a/ui/src/Components/SilenceModal/SilenceModalContent.test.js
+++ b/ui/src/Components/SilenceModal/SilenceModalContent.test.js
@@ -4,7 +4,7 @@ import { shallow } from "enzyme";
import { AlertStore } from "Stores/AlertStore";
import { Settings } from "Stores/Settings";
-import { SilenceFormStore } from "Stores/SilenceFormStore";
+import { SilenceFormStore, SilenceFormStage } from "Stores/SilenceFormStore";
import { SilenceModalContent } from "./SilenceModalContent";
let alertStore;
@@ -31,15 +31,22 @@ const ShallowSilenceModalContent = () => {
};
describe("
", () => {
- it("renders SilenceForm when silenceFormStore.data.inProgress is false", () => {
- silenceFormStore.data.inProgress = false;
+ it("renders SilenceForm when silenceFormStore.data.currentStage is 'UserInput'", () => {
+ silenceFormStore.data.currentStage = SilenceFormStage.UserInput;
const tree = ShallowSilenceModalContent();
const form = tree.find("SilenceForm");
expect(form).toHaveLength(1);
});
- it("renders SilenceSubmitController when silenceFormStore.data.inProgress is true", () => {
- silenceFormStore.data.inProgress = true;
+ it("renders SilencePreview when silenceFormStore.data.currentStage is 'Preview'", () => {
+ silenceFormStore.data.currentStage = SilenceFormStage.Preview;
+ const tree = ShallowSilenceModalContent();
+ const ctrl = tree.find("SilencePreview");
+ expect(ctrl).toHaveLength(1);
+ });
+
+ it("renders SilenceSubmitController when silenceFormStore.data.currentStage is 'Submit'", () => {
+ silenceFormStore.data.currentStage = SilenceFormStage.Submit;
const tree = ShallowSilenceModalContent();
const ctrl = tree.find("SilenceSubmitController");
expect(ctrl).toHaveLength(1);
diff --git a/ui/src/Components/SilenceModal/SilencePreview/__snapshots__/index.test.js.snap b/ui/src/Components/SilenceModal/SilencePreview/__snapshots__/index.test.js.snap
new file mode 100644
index 000000000..a70beda82
--- /dev/null
+++ b/ui/src/Components/SilenceModal/SilencePreview/__snapshots__/index.test.js.snap
@@ -0,0 +1,52 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`
matches snapshot 1`] = `
+"
+
+
+ This silence will match
+
+ 3
+
+ alerts
+
+
+
+ -
+
+ alertname: foo
+
+
+ job: foo
+
+
+ instance: foo1
+
+
+ -
+
+ alertname: bar
+
+
+ job: bar
+
+
+ instance: bar1
+
+
+ -
+
+ alertname: bar
+
+
+ job: bar
+
+
+ instance: bar2
+
+
+
+
+
+"
+`;
diff --git a/ui/src/Components/SilenceModal/SilencePreview/index.js b/ui/src/Components/SilenceModal/SilencePreview/index.js
new file mode 100644
index 000000000..ee83b4107
--- /dev/null
+++ b/ui/src/Components/SilenceModal/SilencePreview/index.js
@@ -0,0 +1,169 @@
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+
+import { observable, action } from "mobx";
+import { observer } from "mobx-react";
+
+import hash from "object-hash";
+
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { faArrowLeft } from "@fortawesome/free-solid-svg-icons/faArrowLeft";
+import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle";
+import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons/faExclamationCircle";
+
+import { AlertStore, FormatBackendURI, FormatAlertsQ } from "Stores/AlertStore";
+import { SilenceFormStore } from "Stores/SilenceFormStore";
+import { StaticLabel } from "Components/Labels/StaticLabel";
+import { MatcherToFilter, AlertManagersToFilter } from "../Matchers";
+
+const FetchError = ({ message }) => (
+
+);
+FetchError.propTypes = {
+ message: PropTypes.node.isRequired
+};
+
+const Preview = ({ alertStore, labelsList }) => (
+
+ {labelsList.map(labels => (
+ -
+ {Object.entries(labels).map(([name, value]) => (
+
+ ))}
+
+ ))}
+
+);
+Preview.propTypes = {
+ alertStore: PropTypes.instanceOf(AlertStore).isRequired,
+ labelsList: PropTypes.arrayOf(PropTypes.object).isRequired
+};
+
+const SilencePreview = observer(
+ class SilencePreview extends Component {
+ static propTypes = {
+ alertStore: PropTypes.instanceOf(AlertStore).isRequired,
+ silenceFormStore: PropTypes.instanceOf(SilenceFormStore).isRequired
+ };
+
+ matchedAlerts = observable(
+ {
+ alertLabels: [],
+ error: null,
+ fetch: null,
+ groupsToUniqueLabels(groups) {
+ const alerts = {};
+ for (const group of groups) {
+ for (const alert of group.alerts) {
+ const alertLabels = Object.assign(
+ {},
+ group.labels,
+ group.shared.labels,
+ alert.labels
+ );
+ const alertHash = hash(alertLabels);
+ alerts[alertHash] = alertLabels;
+ }
+ }
+ this.alertLabels = Object.values(alerts);
+ },
+ setError(value) {
+ this.error = value;
+ }
+ },
+ {
+ groupsToUniqueLabels: action,
+ setError: action
+ }
+ );
+
+ onFetch = () => {
+ const { silenceFormStore } = this.props;
+
+ const filters = [
+ ...silenceFormStore.data.matchers.map(m => MatcherToFilter(m)),
+ AlertManagersToFilter(silenceFormStore.data.alertmanagers)
+ ];
+
+ const alertsURI =
+ FormatBackendURI("alerts.json?") + FormatAlertsQ(filters);
+
+ this.matchedAlerts.fetch = fetch(alertsURI, { credentials: "include" })
+ .then(result => {
+ return result.json();
+ })
+ .then(result => {
+ this.matchedAlerts.groupsToUniqueLabels(Object.values(result.groups));
+ this.matchedAlerts.setError(null);
+ })
+ .catch(err => {
+ console.trace(err);
+ return this.matchedAlerts.setError(
+ `Request failed with: ${err.message}`
+ );
+ });
+ };
+
+ componentDidMount() {
+ this.onFetch();
+ }
+
+ render() {
+ const { alertStore, silenceFormStore } = this.props;
+
+ return (
+
+
+ {this.matchedAlerts.error !== null ? (
+
+ ) : (
+
+
+ This silence will match{" "}
+ {this.matchedAlerts.alertLabels.length} alert
+ {this.matchedAlerts.alertLabels.length > 1 ? "s" : ""}
+
+
+
+ )}
+
+
+
+
+
+
+ );
+ }
+ }
+);
+
+export { SilencePreview };
diff --git a/ui/src/Components/SilenceModal/SilencePreview/index.test.js b/ui/src/Components/SilenceModal/SilencePreview/index.test.js
new file mode 100644
index 000000000..91b10d70a
--- /dev/null
+++ b/ui/src/Components/SilenceModal/SilencePreview/index.test.js
@@ -0,0 +1,120 @@
+import React from "react";
+
+import { mount } from "enzyme";
+
+import toDiffableHtml from "diffable-html";
+
+import { EmptyAPIResponse } from "__mocks__/Fetch";
+import { MockAlertGroup, MockAlert } from "__mocks__/Alerts";
+import { AlertStore } from "Stores/AlertStore";
+import {
+ SilenceFormStore,
+ SilenceFormStage,
+ NewEmptyMatcher,
+ MatcherValueToObject
+} from "Stores/SilenceFormStore";
+import { SilencePreview } from ".";
+
+let alertStore;
+let silenceFormStore;
+
+beforeEach(() => {
+ fetch.resetMocks();
+
+ alertStore = new AlertStore([]);
+
+ const matcher = NewEmptyMatcher();
+ matcher.name = "foo";
+ matcher.values = [MatcherValueToObject("bar")];
+
+ silenceFormStore = new SilenceFormStore();
+ silenceFormStore.data.matchers = [matcher];
+});
+
+afterEach(() => {
+ jest.restoreAllMocks();
+});
+
+const MockAPIResponse = () => {
+ const response = EmptyAPIResponse();
+ response.groups = {
+ "1": MockAlertGroup(
+ { alertname: "foo" },
+ [MockAlert([], { instance: "foo1" }, "active")],
+ [],
+ { job: "foo" }
+ ),
+ "2": MockAlertGroup(
+ { alertname: "bar" },
+ [
+ MockAlert([], { instance: "bar1" }, "active"),
+ MockAlert([], { instance: "bar2" }, "active")
+ ],
+ [],
+ { job: "bar" }
+ )
+ };
+ return response;
+};
+
+const MountedSilencePreview = () => {
+ return mount(
+
+ );
+};
+
+describe("
", () => {
+ it("fetches matching alerts on mount", async () => {
+ fetch.mockResponse(JSON.stringify(MockAPIResponse()));
+
+ const tree = MountedSilencePreview();
+ await expect(tree.instance().matchedAlerts.fetch).resolves.toBeUndefined();
+ expect(fetch).toHaveBeenCalled();
+ });
+
+ it("matches snapshot", async () => {
+ fetch.mockResponse(JSON.stringify(MockAPIResponse()));
+
+ const tree = MountedSilencePreview();
+ await expect(tree.instance().matchedAlerts.fetch).resolves.toBeUndefined();
+ expect(toDiffableHtml(tree.html())).toMatchSnapshot();
+ });
+
+ it("renders FetchError on failed fetch", async () => {
+ const consoleSpy = jest
+ .spyOn(console, "trace")
+ .mockImplementation(() => {});
+ fetch.mockReject("Fetch error");
+
+ const tree = MountedSilencePreview();
+ await expect(tree.instance().matchedAlerts.fetch).resolves.toBeUndefined();
+
+ tree.update();
+ expect(tree.find("FetchError")).toHaveLength(1);
+ expect(consoleSpy).toHaveBeenCalled();
+ expect(tree.find("Preview")).toHaveLength(0);
+ });
+
+ it("renders Preview on successful fetch", async () => {
+ fetch.mockResponse(JSON.stringify(MockAPIResponse()));
+
+ const tree = MountedSilencePreview();
+ await expect(tree.instance().matchedAlerts.fetch).resolves.toBeUndefined();
+
+ tree.update();
+ expect(tree.find("FetchError")).toHaveLength(0);
+ expect(tree.find("Preview")).toHaveLength(1);
+ });
+
+ it("clicking on the submit button moves form to the 'Submit' stage", () => {
+ fetch.mockResponse(JSON.stringify(MockAPIResponse()));
+
+ const tree = MountedSilencePreview();
+ const button = tree.find(".btn-outline-primary");
+ button.simulate("click");
+ expect(silenceFormStore.data.currentStage).toBe(SilenceFormStage.Submit);
+ });
+});
diff --git a/ui/src/Components/SilenceModal/SilenceSubmitController.js b/ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitController.js
similarity index 100%
rename from ui/src/Components/SilenceModal/SilenceSubmitController.js
rename to ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitController.js
diff --git a/ui/src/Components/SilenceModal/SilenceSubmitController.test.js b/ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitController.test.js
similarity index 87%
rename from ui/src/Components/SilenceModal/SilenceSubmitController.test.js
rename to ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitController.test.js
index facc04ffc..3d9f92dde 100644
--- a/ui/src/Components/SilenceModal/SilenceSubmitController.test.js
+++ b/ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitController.test.js
@@ -5,6 +5,7 @@ import { shallow } from "enzyme";
import { AlertStore } from "Stores/AlertStore";
import {
SilenceFormStore,
+ SilenceFormStage,
MatcherValueToObject
} from "Stores/SilenceFormStore";
import { SilenceSubmitController } from "./SilenceSubmitController";
@@ -36,10 +37,10 @@ describe("
", () => {
});
it("resets the form on 'Back' button click", () => {
- silenceFormStore.data.inProgress = true;
+ silenceFormStore.data.currentStage = SilenceFormStage.Submit;
const tree = ShallowSilenceSubmitController();
const button = tree.find("button");
button.simulate("click");
- expect(silenceFormStore.data.inProgress).toBe(false);
+ expect(silenceFormStore.data.currentStage).toBe(SilenceFormStage.UserInput);
});
});
diff --git a/ui/src/Components/SilenceModal/SilenceSubmitProgress.js b/ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitProgress.js
similarity index 100%
rename from ui/src/Components/SilenceModal/SilenceSubmitProgress.js
rename to ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitProgress.js
diff --git a/ui/src/Components/SilenceModal/SilenceSubmitProgress.test.js b/ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitProgress.test.js
similarity index 100%
rename from ui/src/Components/SilenceModal/SilenceSubmitProgress.test.js
rename to ui/src/Components/SilenceModal/SilenceSubmit/SilenceSubmitProgress.test.js
diff --git a/ui/src/Components/SilenceModal/__snapshots__/SilenceSubmitProgress.test.js.snap b/ui/src/Components/SilenceModal/SilenceSubmit/__snapshots__/SilenceSubmitProgress.test.js.snap
similarity index 100%
rename from ui/src/Components/SilenceModal/__snapshots__/SilenceSubmitProgress.test.js.snap
rename to ui/src/Components/SilenceModal/SilenceSubmit/__snapshots__/SilenceSubmitProgress.test.js.snap
diff --git a/ui/src/Components/SilenceModal/index.test.js b/ui/src/Components/SilenceModal/index.test.js
index 5205a0a67..f31aaf94a 100644
--- a/ui/src/Components/SilenceModal/index.test.js
+++ b/ui/src/Components/SilenceModal/index.test.js
@@ -4,7 +4,12 @@ import { mount } from "enzyme";
import { AlertStore } from "Stores/AlertStore";
import { Settings } from "Stores/Settings";
-import { SilenceFormStore } from "Stores/SilenceFormStore";
+import {
+ SilenceFormStore,
+ SilenceFormStage,
+ NewEmptyMatcher,
+ MatcherValueToObject
+} from "Stores/SilenceFormStore";
import { SilenceModal } from ".";
let alertStore;
@@ -100,12 +105,17 @@ describe("
", () => {
expect(document.body.className.split(" ")).not.toContain("modal-open");
});
- it("inProgress is set to false after modal is hidden", () => {
+ it("currentStage is set to 'UserInput' after modal is hidden", () => {
+ const matcher = NewEmptyMatcher();
+ matcher.name = "foo";
+ matcher.values = [MatcherValueToObject("bar")];
+ silenceFormStore.data.matchers = [matcher];
+
silenceFormStore.toggle.visible = true;
const tree = MountedSilenceModal();
- silenceFormStore.data.inProgress = true;
+ silenceFormStore.data.currentStage = SilenceFormStage.Preview;
const toggle = tree.find("button.close");
toggle.simulate("click");
- expect(silenceFormStore.data.inProgress).toBe(false);
+ expect(silenceFormStore.data.currentStage).toBe(SilenceFormStage.UserInput);
});
});
diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js
index 3648e3afd..7bd470fd6 100644
--- a/ui/src/Stores/AlertStore.js
+++ b/ui/src/Stores/AlertStore.js
@@ -6,16 +6,22 @@ import equal from "fast-deep-equal";
import qs from "qs";
+const QueryStringEncodeOptions = {
+ encodeValuesOnly: true, // don't encode q[]
+ indices: false // go-gin doesn't support parsing q[0]=foo&q[1]=bar
+};
+
+function FormatAlertsQ(filters) {
+ return qs.stringify({ q: filters }, QueryStringEncodeOptions);
+}
+
// generate URL for the UI with a set of filters
function FormatAPIFilterQuery(filters) {
return qs.stringify(
Object.assign(DecodeLocationSearch(window.location.search).params, {
q: filters
}),
- {
- encodeValuesOnly: true, // don't encode q[]
- indices: false // go-gin doesn't support parsing q[0]=foo&q[1]=bar
- }
+ QueryStringEncodeOptions
);
}
@@ -336,6 +342,7 @@ export {
AlertStoreStatuses,
FormatBackendURI,
FormatAPIFilterQuery,
+ FormatAlertsQ,
DecodeLocationSearch,
UpdateLocationSearch,
NewUnappliedFilter
diff --git a/ui/src/Stores/AlertStore.test.js b/ui/src/Stores/AlertStore.test.js
index 90e3473a2..a9df5f260 100644
--- a/ui/src/Stores/AlertStore.test.js
+++ b/ui/src/Stores/AlertStore.test.js
@@ -4,6 +4,7 @@ import {
AlertStore,
AlertStoreStatuses,
FormatBackendURI,
+ FormatAlertsQ,
DecodeLocationSearch,
UpdateLocationSearch,
NewUnappliedFilter
@@ -146,6 +147,12 @@ describe("FormatBackendURI", () => {
});
});
+describe("FormatAlertsQ", () => {
+ it("encodes multiple values without indices", () => {
+ expect(FormatAlertsQ(["a", "b"])).toBe("q=a&q=b");
+ });
+});
+
describe("DecodeLocationSearch", () => {
const defaultParams = {
defaultsUsed: true,
diff --git a/ui/src/Stores/SilenceFormStore.js b/ui/src/Stores/SilenceFormStore.js
index 54f939c14..5f16b0903 100644
--- a/ui/src/Stores/SilenceFormStore.js
+++ b/ui/src/Stores/SilenceFormStore.js
@@ -19,6 +19,12 @@ const NewEmptyMatcher = () => {
const MatcherValueToObject = value => ({ label: value, value: value });
+const SilenceFormStage = Object.freeze({
+ UserInput: "form",
+ Preview: "preview",
+ Submit: "submit"
+});
+
class SilenceFormStore {
// this is used to store modal visibility toggle
toggle = observable(
@@ -43,7 +49,7 @@ class SilenceFormStore {
// this form from that alert so user can easily silence that alert
data = observable(
{
- inProgress: false,
+ currentStage: SilenceFormStage.UserInput,
wasValidated: false,
silenceID: null,
alertmanagers: [],
@@ -76,7 +82,7 @@ class SilenceFormStore {
},
resetProgress() {
- this.inProgress = false;
+ this.currentStage = SilenceFormStage.UserInput;
this.wasValidated = false;
},
@@ -84,6 +90,10 @@ class SilenceFormStore {
this.silenceID = null;
},
+ setStageSubmit() {
+ this.currentStage = SilenceFormStage.Submit;
+ },
+
// append a new empty matcher to the list
addEmptyMatcher() {
let m = NewEmptyMatcher();
@@ -235,6 +245,7 @@ class SilenceFormStore {
resetStartEnd: action.bound,
resetProgress: action.bound,
resetSilenceID: action.bound,
+ setStageSubmit: action.bound,
addEmptyMatcher: action.bound,
deleteMatcher: action.bound,
fillMatchersFromGroup: action.bound,
@@ -252,4 +263,9 @@ class SilenceFormStore {
);
}
-export { SilenceFormStore, NewEmptyMatcher, MatcherValueToObject };
+export {
+ SilenceFormStore,
+ SilenceFormStage,
+ NewEmptyMatcher,
+ MatcherValueToObject
+};
diff --git a/ui/src/Stores/SilenceFormStore.test.js b/ui/src/Stores/SilenceFormStore.test.js
index 6c85ccfca..b25a288ea 100644
--- a/ui/src/Stores/SilenceFormStore.test.js
+++ b/ui/src/Stores/SilenceFormStore.test.js
@@ -6,7 +6,11 @@ import {
MockSilence,
MockAlertmanager
} from "__mocks__/Alerts.js";
-import { SilenceFormStore, NewEmptyMatcher } from "./SilenceFormStore";
+import {
+ SilenceFormStore,
+ SilenceFormStage,
+ NewEmptyMatcher
+} from "./SilenceFormStore";
let store;
beforeEach(() => {
@@ -72,11 +76,10 @@ describe("SilenceFormStore.data", () => {
expect(store.data.endsAt.isSame([2000, 1, 1], "day")).toBe(false);
});
- it("resetProgress() sets 'inProgress' to false", () => {
- store.data.inProgress = true;
- expect(store.data.inProgress).toBe(true);
+ it("resetProgress() sets currentStage to UserInput", () => {
+ store.data.currentStage = SilenceFormStage.Submit;
store.data.resetProgress();
- expect(store.data.inProgress).toBe(false);
+ expect(store.data.currentStage).toBe(SilenceFormStage.UserInput);
});
it("resetProgress() sets 'wasValidated' to false", () => {