修复(#97): 区分邀请管理加载失败状态
PR Check / Lint, Check, Test and Build (push) Has been cancelled
Build and Release / Build (push) Has been cancelled

This commit is contained in:
2026-05-27 19:13:27 -07:00
parent aeca20ad1e
commit 100b641552
5 changed files with 92 additions and 9 deletions
+23 -2
View File
@@ -127,12 +127,33 @@ describe("InviteManagement", () => {
expect(await screen.findByText("No invite records")).not.toBeNull();
});
it("keeps the table empty when the request fails", async () => {
it("shows a loading state while invites are being fetched", () => {
let resolveRequest:
| ((
value: AxiosResponse<
API.Response & { data?: API.GetAdminInviteListResponse }
>
) => void)
| undefined;
mockedGetAdminInviteList.mockReturnValue(
new Promise((resolve) => {
resolveRequest = resolve;
})
);
render(<InviteManagement />);
expect(screen.getByRole("status", { name: "Loading data" })).not.toBeNull();
expect(resolveRequest).toBeTypeOf("function");
});
it("shows an error state when the request fails", async () => {
mockedGetAdminInviteList.mockRejectedValue(new Error("network failed"));
render(<InviteManagement />);
await waitFor(() => expect(mockedGetAdminInviteList).toHaveBeenCalled());
expect(await screen.findByText("No invite records")).not.toBeNull();
expect(await screen.findByText("Failed to load invites")).not.toBeNull();
expect(screen.queryByText("No invite records")).toBeNull();
});
});