Skip to content

Commit

Permalink
test "fixes"
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Jan 30, 2025
1 parent caeda3b commit e0c21c8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/features/alerts/components/__tests__/table-alerts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ test("renders token usage cell correctly", async () => {
}),
);

const { getByRole, getByTestId } = render(<TableAlerts />);
const { getByRole, getByTestId, queryByText } = render(<TableAlerts />);

await waitFor(() => {
expect(
within(screen.getByTestId("alerts-table")).getAllByRole("row"),
).toHaveLength(2);
});

await waitFor(() => {
expect(queryByText("Connect CodeGate to your IDE")).not.toBeInTheDocument();
});

expect(getByTestId("icon-arrow-up")).toBeVisible();
expect(getByTestId("icon-arrow-down")).toBeVisible();

Expand All @@ -63,14 +67,18 @@ test("renders N/A when token usage is missing", async () => {
}),
);

const { getByText } = render(<TableAlerts />);
const { getByText, queryByText } = render(<TableAlerts />);

await waitFor(() => {
expect(
within(screen.getByTestId("alerts-table")).getAllByRole("row"),
).toHaveLength(2);
});

await waitFor(() => {
expect(queryByText("Connect CodeGate to your IDE")).not.toBeInTheDocument();
});

expect(getByText("N/A")).toBeVisible();
});

Expand All @@ -95,9 +103,9 @@ test("does not render table empty state when the API responds with alerts", asyn
}),
);

const { findAllByText } = render(<TableAlerts />);
const { queryByText } = render(<TableAlerts />);

expect((await findAllByText("Connect CodeGate to your IDE")).length).toEqual(
0,
);
await waitFor(() => {
expect(queryByText("Connect CodeGate to your IDE")).not.toBeInTheDocument();
});
});
30 changes: 30 additions & 0 deletions src/routes/__tests__/route-dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ describe("Dashboard", () => {
).toBeGreaterThan(1);
});

await waitFor(() => {
expect(
screen.queryByText("Connect CodeGate to your IDE"),
).not.toBeInTheDocument();
});

const firstRow = within(screen.getByTestId("alerts-table")).getAllByRole(
"row",
)[1] as HTMLElement;
Expand All @@ -193,6 +199,12 @@ describe("Dashboard", () => {
).toBeGreaterThan(1);
});

await waitFor(() => {
expect(
screen.queryByText("Connect CodeGate to your IDE"),
).not.toBeInTheDocument();
});

expect(
screen.getByRole("gridcell", {
name: /blocked malicious package/i,
Expand All @@ -219,6 +231,12 @@ describe("Dashboard", () => {
).toBeGreaterThan(1);
});

await waitFor(() => {
expect(
screen.queryByText("Connect CodeGate to your IDE"),
).not.toBeInTheDocument();
});

expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
expect(
screen.getAllByRole("gridcell", {
Expand Down Expand Up @@ -262,6 +280,12 @@ describe("Dashboard", () => {
).toBeGreaterThan(1);
});

await waitFor(() => {
expect(
screen.queryByText("Connect CodeGate to your IDE"),
).not.toBeInTheDocument();
});

expect(screen.getByTestId(/alerts-count/i)).toHaveTextContent("2");
expect(
screen.getAllByRole("gridcell", {
Expand Down Expand Up @@ -289,6 +313,12 @@ describe("Dashboard", () => {
).toBeGreaterThan(1);
});

await waitFor(() => {
expect(
screen.queryByText("Connect CodeGate to your IDE"),
).not.toBeInTheDocument();
});

const firstRow = within(screen.getByTestId("alerts-table")).getAllByRole(
"row",
)[1] as HTMLElement;
Expand Down

0 comments on commit e0c21c8

Please sign in to comment.