mirror of
https://github.com/prymitive/karma
synced 2026-08-23 11:56:20 +00:00
fix(ui): remove silenceForm.author usage in the UI
This commit is contained in:
@@ -173,9 +173,7 @@ const AlertAck = observer(
|
||||
}
|
||||
|
||||
let author =
|
||||
alertStore.settings.values.silenceForm.author !== ""
|
||||
? alertStore.settings.values.silenceForm.author
|
||||
: silenceFormStore.data.author !== ""
|
||||
silenceFormStore.data.author !== ""
|
||||
? toJS(silenceFormStore.data.author)
|
||||
: toJS(alertStore.settings.values.alertAcknowledgement.author);
|
||||
|
||||
|
||||
@@ -192,7 +192,6 @@ describe("<AlertAck />", () => {
|
||||
it("uses author from authentication info when auth is enabled", () => {
|
||||
alertStore.info.authentication.enabled = true;
|
||||
alertStore.info.authentication.username = "auth@example.com";
|
||||
alertStore.settings.values.silenceForm.author = "john@example.com";
|
||||
alertStore.settings.values.alertAcknowledgement.durationSeconds = 222;
|
||||
alertStore.settings.values.alertAcknowledgement.author = "me";
|
||||
alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:";
|
||||
@@ -210,27 +209,9 @@ describe("<AlertAck />", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses author from alertStore if present", () => {
|
||||
alertStore.settings.values.silenceForm.author = "john@example.com";
|
||||
alertStore.settings.values.alertAcknowledgement.durationSeconds = 222;
|
||||
alertStore.settings.values.alertAcknowledgement.author = "me";
|
||||
alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:";
|
||||
MountAndClick();
|
||||
expect(JSON.parse(fetch.mock.calls[0][1].body)).toEqual({
|
||||
comment:
|
||||
"FOO: This alert was acknowledged using karma on Tue Feb 01 2000 00:00:00 GMT+0000",
|
||||
createdBy: "john@example.com",
|
||||
endsAt: "2000-02-01T00:03:42.000Z",
|
||||
matchers: [
|
||||
{ isRegex: false, name: "alertname", value: "Fake Alert" },
|
||||
{ isRegex: true, name: "foo", value: "(bar|baz)" }
|
||||
],
|
||||
startsAt: "2000-02-01T00:00:00.000Z"
|
||||
});
|
||||
});
|
||||
|
||||
it("uses author from silenceFormStore if alertStore is empty", () => {
|
||||
alertStore.settings.values.silenceForm.author = "";
|
||||
it("uses author from silenceFormStore if authentication is disabled", () => {
|
||||
alertStore.info.authentication.enabled = false;
|
||||
alertStore.info.authentication.username = "wrong";
|
||||
alertStore.settings.values.alertAcknowledgement.durationSeconds = 222;
|
||||
alertStore.settings.values.alertAcknowledgement.author = "me";
|
||||
alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:";
|
||||
@@ -250,7 +231,6 @@ describe("<AlertAck />", () => {
|
||||
});
|
||||
|
||||
it("uses default author as fallback", () => {
|
||||
alertStore.settings.values.silenceForm.author = "";
|
||||
alertStore.settings.values.alertAcknowledgement.durationSeconds = 222;
|
||||
alertStore.settings.values.alertAcknowledgement.author = "me";
|
||||
alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:";
|
||||
|
||||
@@ -69,11 +69,6 @@ const SilenceForm = observer(
|
||||
populateAuthor = action(() => {
|
||||
const { alertStore, silenceFormStore, settingsStore } = this.props;
|
||||
|
||||
if (alertStore.settings.values.silenceForm.author !== "") {
|
||||
settingsStore.silenceFormConfig.config.author =
|
||||
alertStore.settings.values.silenceForm.author;
|
||||
}
|
||||
|
||||
if (silenceFormStore.data.author === "") {
|
||||
silenceFormStore.data.author =
|
||||
settingsStore.silenceFormConfig.config.author;
|
||||
|
||||
@@ -145,25 +145,6 @@ describe("<SilenceForm /> inputs", () => {
|
||||
expect(silenceFormStore.data.author).toBe("foo@example.com");
|
||||
});
|
||||
|
||||
it("default author value comes from the API response if present", () => {
|
||||
alertStore.settings.values.silenceForm.author = "bar@example.com";
|
||||
settingsStore.silenceFormConfig.config.author = "foo@example.com";
|
||||
const tree = MountedSilenceForm();
|
||||
const input = tree.find("input[placeholder='Author']");
|
||||
expect(input.props().value).toBe("bar@example.com");
|
||||
});
|
||||
|
||||
it("author value from the API response is saved to the Settings store", () => {
|
||||
alertStore.settings.values.silenceForm.author = "bar@example.com";
|
||||
settingsStore.silenceFormConfig.config.author = "";
|
||||
const tree = MountedSilenceForm();
|
||||
const input = tree.find("input[placeholder='Author']");
|
||||
expect(input.props().value).toBe("bar@example.com");
|
||||
expect(settingsStore.silenceFormConfig.config.author).toBe(
|
||||
"bar@example.com"
|
||||
);
|
||||
});
|
||||
|
||||
it("default author value is empty if nothing is stored in Settings", () => {
|
||||
settingsStore.silenceFormConfig.config.author = "";
|
||||
const tree = MountedSilenceForm();
|
||||
|
||||
@@ -258,7 +258,6 @@ class AlertStore {
|
||||
valueMapping: {}
|
||||
},
|
||||
silenceForm: {
|
||||
author: "",
|
||||
strip: {
|
||||
labels: []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user