mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
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:
@@ -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 = {};
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user