Skip to content

Commit

Permalink
Test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
edlouth committed Aug 23, 2023
1 parent 95d1f94 commit 52f7ca9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultProps = {
type: "table",
field: "namespace",
operator: "equals",
value: "test",
value: "prod",
},
],
setInlineFilters,
Expand All @@ -32,7 +32,7 @@ const mocks = [
id: "1",
name: "demo",
namespaces: {
data: ["default", "test", "prod"],
data: ["default", "prod"],
},
tags: {
data: [],
Expand All @@ -46,6 +46,14 @@ const mocks = [
},
]

beforeEach(() => {
window.localStorage.clear()
})

afterEach(() => {
window.localStorage.clear()
})

test("renders", async () => {
render(<GraphFilterInline {...defaultProps} />, {
path: ":organisationName/:workspaceName/graph",
Expand Down Expand Up @@ -135,7 +143,7 @@ test("renders not field", async () => {
inlineFilters={[
{
type: "table",
field: "test",
field: "testfield",
operator: null,
value: null,
},
Expand Down Expand Up @@ -188,7 +196,7 @@ test("add", async () => {
)

expect(setInlineFilters).toHaveBeenCalledWith([
{ field: "namespace", operator: "equals", type: "table", value: "test" },
{ field: "namespace", operator: "equals", type: "table", value: "prod" },
{ field: "tag", operator: "contains", type: "table", value: null },
])
})
Expand Down Expand Up @@ -275,7 +283,7 @@ test("edit", async () => {
field: "namespace",
operator: "in",
type: "table",
value: "test",
value: "prod",
},
])

Expand All @@ -294,7 +302,7 @@ test("edit", async () => {
},
])

await act(async () => await user.type(screen.getByRole("listbox"), "test"))
await act(async () => await user.type(screen.getByRole("listbox"), "prod"))

await act(async () => await user.keyboard("{escape}"))
})
Expand All @@ -309,7 +317,7 @@ test("edit multiple", async () => {
type: "table",
field: "namespace",
operator: "in",
value: ["test"],
value: ["prod"],
},
]}
setInlineFilters={setInlineFilters}
Expand Down Expand Up @@ -347,7 +355,7 @@ test("edit multiple", async () => {
field: "namespace",
operator: "in",
type: "table",
value: ["test", "default"],
value: ["prod", "default"],
},
])

Expand All @@ -364,7 +372,7 @@ test("edit text", async () => {
type: "table",
field: "name",
operator: "equals",
value: "test",
value: "testname",
},
]}
setInlineFilters={setInlineFilters}
Expand Down Expand Up @@ -395,7 +403,7 @@ test("edit text", async () => {
field: "name",
operator: "equals",
type: "table",
value: "testa",
value: "testnamea",
},
])
})
Expand Down
10 changes: 7 additions & 3 deletions grai-frontend/src/pages/Graph.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ test("renders", async () => {
// })
// })

afterEach(() => {
window.localStorage.clear()
})

test("renders empty", async () => {
class ResizeObserver {
callback: globalThis.ResizeObserverCallback
Expand Down Expand Up @@ -625,7 +629,7 @@ test("inline filter", async () => {
id: "1",
name: "demo",
namespaces: {
data: ["default", "test"],
data: ["default", "prod"],
},
tags: {
data: [],
Expand Down Expand Up @@ -655,7 +659,7 @@ test("inline filter", async () => {
inlineFilterMock(),
inlineFilterMock(),
inlineFilterMock(),
inlineFilterMock("test"),
inlineFilterMock("prod"),
workspacesMock,
workspacesMock,
],
Expand All @@ -682,7 +686,7 @@ test("inline filter", async () => {
})

await act(async () => {
await user.click(screen.getByText("test"))
await user.click(screen.getByText("prod"))
})

await waitFor(async () => {
Expand Down

0 comments on commit 52f7ca9

Please sign in to comment.