fix: LogsPreviewer filter clear button values should not persist old values

This commit is contained in:
TzeYiing authored and Joshen Lim committed 2022-09-20 16:05:29 +08:00
1 parent e920f31f5b
commit 4489b73c6d
2 files changed
+23 -2

No files matched your search

+1 -1
View File
@@ -175,7 +175,7 @@ function useLogsPreview(
return { ...resolved, ...filterOverride }
})
} else {
setFilters((prev) => ({ ...prev, ...newFilters, ...filterOverride }))
setFilters({ ...newFilters, ...filterOverride })
}
}
return [
@@ -350,9 +350,30 @@ test('filters alter generated query', async () => {
userEvent.click(await screen.findByText(/Save/))
await waitFor(() => {
expect(get).toHaveBeenCalledWith(expect.stringContaining('select'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('500'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('599'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('200'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('299'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('where'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('and'))
})
// should be able to clear the filters
userEvent.click(await screen.findByRole('button', { name: 'Status' }))
userEvent.click(await screen.findByRole('button', { name: 'Clear' }))
get.mockClear()
userEvent.click(await screen.findByRole('button', { name: 'Status' }))
userEvent.click(await screen.findByText(/400 codes/))
userEvent.click(await screen.findByText(/Save/))
await waitFor(() => {
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('500'))
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('599'))
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('200'))
expect(get).not.toHaveBeenCalledWith(expect.stringContaining('299'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('400'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('499'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('where'))
expect(get).toHaveBeenCalledWith(expect.stringContaining('and'))
})