adding tests

This commit is contained in:
yuneng-jiang 2025-12-29 15:21:19 -08:00
parent b69c1dcee7
commit b21b156e55
2 changed files with 40 additions and 0 deletions

View file

@ -93,6 +93,10 @@ const mockKey: KeyResponse = {
user_tpm_limit: 1000,
user_rpm_limit: 100,
user_email: "user@example.com",
user: {
user_email: "user@example.com",
user_id: "user-1",
},
};
const mockTeam: Team = {
@ -190,3 +194,35 @@ it("should display key information correctly", async () => {
expect(screen.getByText("5.5000")).toBeInTheDocument();
});
});
it("should display user email correctly", async () => {
const mockProps = {
keys: [mockKey],
setKeys: vi.fn(),
isLoading: false,
pagination: {
currentPage: 1,
totalPages: 1,
totalCount: 1,
},
onPageChange: vi.fn(),
pageSize: 50,
teams: [mockTeam],
selectedTeam: null,
setSelectedTeam: vi.fn(),
selectedKeyAlias: null,
setSelectedKeyAlias: vi.fn(),
accessToken: "test-token",
userID: "user-1",
userRole: "admin",
organizations: [mockOrganization],
setCurrentOrg: vi.fn(),
premiumUser: false,
};
renderWithProviders(<AllKeysTable {...mockProps} />);
await waitFor(() => {
expect(screen.getByText("user@example.com")).toBeInTheDocument();
});
});

View file

@ -91,6 +91,10 @@ export interface KeyResponse {
last_rotation_at?: string;
key_rotation_at?: string;
next_rotation_at?: string;
user?: {
user_id: string;
user_email: string;
};
}
interface KeyListResponse {