test(dashboard): stabilize MailboxView unread-badge assertion

The badge only appears after fetchAgentMailbox resolves, so asserting
immediately after the subtabs render raced against the async update.
Move the badge check inside waitFor so it polls until populated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-24 09:43:25 -07:00
parent 8a723c86b5
commit d37cb519d3

View File

@@ -974,12 +974,9 @@ describe("MailboxView", () => {
fireEvent.change(screen.getByTestId("mailbox-agent-select"), { target: { value: "agent-001" } });
await waitFor(() => {
expect(screen.getByTestId("mailbox-agent-subtabs")).toBeDefined();
const inboxTab = screen.getByTestId("mailbox-agent-subtab-inbox");
expect(inboxTab.querySelector(".mailbox-tab-badge")?.textContent).toBe("3");
});
// Inbox tab should have the unread badge
const inboxTab = screen.getByTestId("mailbox-agent-subtab-inbox");
expect(inboxTab.querySelector(".mailbox-tab-badge")?.textContent).toBe("3");
});
});