mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
committed by
Łukasz Mierzwa
parent
21c1d1d557
commit
ba459a08e2
@@ -48,16 +48,28 @@ const SilenceForm = ({
|
||||
silenceFormStore.data.verifyStarEnd();
|
||||
}
|
||||
|
||||
if (silenceFormStore.data.matchers.length === 0) {
|
||||
if (
|
||||
silenceFormStore.data.matchers.filter(
|
||||
(m) => m.name !== "" || m.values.length
|
||||
).length === 0
|
||||
) {
|
||||
if (alertStore.filters.values.length > 0) {
|
||||
alertStore.filters.values
|
||||
.filter(
|
||||
(f) => f.name[0] !== "@" && f.matcher === QueryOperators.Equal
|
||||
(f) =>
|
||||
f.name[0] !== "@" &&
|
||||
(f.matcher === QueryOperators.Equal ||
|
||||
f.matcher === QueryOperators.Regex)
|
||||
)
|
||||
.forEach((f) => {
|
||||
const matcher = NewEmptyMatcher();
|
||||
matcher.name = f.name;
|
||||
matcher.values = [MatcherValueToObject(f.value)];
|
||||
if (f.matcher === QueryOperators.Regex) {
|
||||
matcher.values = [MatcherValueToObject(`.*${f.value}.*`)];
|
||||
matcher.isRegex = f.matcher === QueryOperators.Regex;
|
||||
} else {
|
||||
matcher.values = [MatcherValueToObject(f.value)];
|
||||
}
|
||||
silenceFormStore.data.matchers.push(matcher);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ describe("<SilenceForm /> matchers", () => {
|
||||
];
|
||||
const tree = MountedSilenceForm();
|
||||
const matchers = tree.find("SilenceMatch");
|
||||
expect(matchers).toHaveLength(3);
|
||||
expect(silenceFormStore.data.matchers).toHaveLength(3);
|
||||
expect(matchers).toHaveLength(6);
|
||||
expect(silenceFormStore.data.matchers).toHaveLength(6);
|
||||
expect(silenceFormStore.data.matchers[0]).toMatchObject({
|
||||
isRegex: false,
|
||||
name: "alertname",
|
||||
@@ -100,6 +100,16 @@ describe("<SilenceForm /> matchers", () => {
|
||||
],
|
||||
});
|
||||
expect(silenceFormStore.data.matchers[1]).toMatchObject({
|
||||
isRegex: true,
|
||||
name: "alertname",
|
||||
values: [
|
||||
{
|
||||
label: ".*alertnameRegex.*",
|
||||
value: ".*alertnameRegex.*",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(silenceFormStore.data.matchers[2]).toMatchObject({
|
||||
isRegex: false,
|
||||
name: "cluster",
|
||||
values: [
|
||||
@@ -109,7 +119,17 @@ describe("<SilenceForm /> matchers", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(silenceFormStore.data.matchers[2]).toMatchObject({
|
||||
expect(silenceFormStore.data.matchers[3]).toMatchObject({
|
||||
isRegex: true,
|
||||
name: "cluster",
|
||||
values: [
|
||||
{
|
||||
label: ".*clusterRegex.*",
|
||||
value: ".*clusterRegex.*",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(silenceFormStore.data.matchers[4]).toMatchObject({
|
||||
isRegex: false,
|
||||
name: "foo",
|
||||
values: [
|
||||
@@ -119,6 +139,16 @@ describe("<SilenceForm /> matchers", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(silenceFormStore.data.matchers[5]).toMatchObject({
|
||||
isRegex: true,
|
||||
name: "foo",
|
||||
values: [
|
||||
{
|
||||
label: ".*fooRegex.*",
|
||||
value: ".*fooRegex.*",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("clicking 'Add more' button adds another matcher", () => {
|
||||
|
||||
Reference in New Issue
Block a user