fix(ui): drop check for storedIndex since we check for filter mismatch before reaching there

Add a check to validate that filters are marked as applied after fetch
This commit is contained in:
Łukasz Mierzwa
2018-08-30 20:09:43 +01:00
parent c0edb03bb4
commit c0131758d2
2 changed files with 12 additions and 20 deletions

View File

@@ -242,26 +242,17 @@ class AlertStore {
const storedIndex = this.filters.values.findIndex(
f => f.raw === filter.text
);
if (storedIndex >= 0) {
this.filters.values[storedIndex] = Object.assign(
this.filters.values[storedIndex],
{
applied: true,
isValid: filter.isValid,
hits: filter.hits,
name: filter.name,
matcher: filter.matcher,
value: filter.value
}
);
} else {
console.warn(
`Got response with filter ${
filter.text
} which isn't one of applied filters, ignoring`
);
return;
}
this.filters.values[storedIndex] = Object.assign(
this.filters.values[storedIndex],
{
applied: true,
isValid: filter.isValid,
hits: filter.hits,
name: filter.name,
matcher: filter.matcher,
value: filter.value
}
);
}
let updates = {};

View File

@@ -204,6 +204,7 @@ describe("AlertStore.fetch", () => {
expect(store.status.value).toEqual(AlertStoreStatuses.Idle);
expect(store.info.version).toBe("fakeVersion");
expect(store.filters.values[0].applied).toBe(true);
});
it("fetch() works with valid response", async () => {