fix(test): await async data in auditLog test to prevent race condition
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Successful in 1m7s
Test / frontend-typecheck (pull_request) Successful in 1m16s
Test / frontend-tests (pull_request) Successful in 1m48s
Test / rust-clippy (pull_request) Successful in 8m28s
Test / rust-tests (pull_request) Successful in 10m48s

This commit is contained in:
Shaun Arman 2026-04-19 19:56:50 -05:00
parent 0e6fd09455
commit 1db21ae3c1

View File

@ -42,11 +42,8 @@ describe("Audit Log", () => {
it("displays audit entries", async () => { it("displays audit entries", async () => {
render(<Security />); render(<Security />);
// Wait for audit log to load // Wait for table to appear after async audit data loads
await screen.findByText("Audit Log"); const table = await screen.findByRole("table");
// Check that the table has rows (header + data rows)
const table = screen.getByRole("table");
expect(table).toBeInTheDocument(); expect(table).toBeInTheDocument();
const rows = screen.getAllByRole("row"); const rows = screen.getAllByRole("row");
@ -56,9 +53,7 @@ describe("Audit Log", () => {
it("provides way to view transmitted data details", async () => { it("provides way to view transmitted data details", async () => {
render(<Security />); render(<Security />);
await screen.findByText("Audit Log"); // Wait for async data to load and render the table
// Should have View/Hide buttons for expanding details
const viewButtons = await screen.findAllByRole("button", { name: /View/i }); const viewButtons = await screen.findAllByRole("button", { name: /View/i });
expect(viewButtons.length).toBeGreaterThan(0); expect(viewButtons.length).toBeGreaterThan(0);
}); });
@ -66,14 +61,13 @@ describe("Audit Log", () => {
it("details column or button exists for viewing data", async () => { it("details column or button exists for viewing data", async () => {
render(<Security />); render(<Security />);
await screen.findByText("Audit Log"); // Wait for async data to load and render the table
await screen.findByRole("table");
// The audit log should have a Details column header
const detailsHeader = screen.getByText("Details"); const detailsHeader = screen.getByText("Details");
expect(detailsHeader).toBeInTheDocument(); expect(detailsHeader).toBeInTheDocument();
// Should have view buttons const viewButtons = screen.getAllByRole("button", { name: /View/i });
const viewButtons = await screen.findAllByRole("button", { name: /View/i });
expect(viewButtons.length).toBe(2); // One for each mock entry expect(viewButtons.length).toBe(2); // One for each mock entry
}); });
}); });