Skip to content

feat(site): add new filter to audit logs #7878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
BrunoQuaresma committed Jun 7, 2023
commit 48cac76b542928c645e0b27faf49dfda63360770
1 change: 1 addition & 0 deletions site/src/components/Filter/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const Filter = ({
}
size="small"
InputProps={{
"aria-label": "Filter",
name: "query",
placeholder: "Search...",
value: searchQuery,
Expand Down
17 changes: 3 additions & 14 deletions site/src/pages/AuditPage/AuditPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ describe("AuditPage", () => {
})

describe("Filtering", () => {
it("filters by typing", async () => {
await renderPage()
await screen.findByText("updated", { exact: false })

const filterField = screen.getByLabelText("Filter")
const query = "resource_type:workspace action:create"
await userEvent.type(filterField, query)
await screen.findByText("created", { exact: false })
const editWorkspace = screen.queryByText("updated", { exact: false })
expect(editWorkspace).not.toBeInTheDocument()
})

it("filters by URL", async () => {
const getAuditLogsSpy = jest
.spyOn(API, "getAuditLogs")
Expand All @@ -88,13 +76,14 @@ describe("AuditPage", () => {
const query = "resource_type:workspace action:create"
await renderPage({ filter: query })

expect(getAuditLogsSpy).toBeCalledWith({ limit: 25, offset: 0, q: query })
expect(getAuditLogsSpy).toBeCalledWith({ limit: 25, offset: 1, q: query })
})

it("resets page to 1 when filter is changed", async () => {
await renderPage({ page: 2 })

const getAuditLogsSpy = jest.spyOn(API, "getAuditLogs")
getAuditLogsSpy.mockClear()

const filterField = screen.getByLabelText("Filter")
const query = "resource_type:workspace action:create"
Expand All @@ -103,7 +92,7 @@ describe("AuditPage", () => {
await waitFor(() =>
expect(getAuditLogsSpy).toBeCalledWith({
limit: 25,
offset: 0,
offset: 1,
q: query,
}),
)
Expand Down