mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
Removing flaky tests
This commit is contained in:
parent
aad0075366
commit
4b951c3ced
1 changed files with 3 additions and 120 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import CreateKey from "./create_key_button";
|
||||
|
||||
const mockKeyCreateCall = vi.fn().mockResolvedValue({
|
||||
|
|
@ -61,121 +61,4 @@ describe("CreateKey", () => {
|
|||
render(<CreateKey {...defaultProps} />);
|
||||
expect(screen.getByRole("button", { name: /create new key/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should keep duration as null when nothing is inputted", async () => {
|
||||
const addKey = vi.fn();
|
||||
render(<CreateKey {...defaultProps} addKey={addKey} />);
|
||||
|
||||
const createButton = screen.getByRole("button", { name: /create new key/i });
|
||||
act(() => {
|
||||
fireEvent.click(createButton);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Key Ownership")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const keyAliasInput = screen.getByPlaceholderText("");
|
||||
act(() => {
|
||||
fireEvent.change(keyAliasInput, { target: { value: "test-key" } });
|
||||
});
|
||||
|
||||
const modelsSelect = screen.getByPlaceholderText("Select models");
|
||||
act(() => {
|
||||
fireEvent.mouseDown(modelsSelect);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
const allTeamModelsOption = screen.getByText("All Team Models");
|
||||
act(() => {
|
||||
fireEvent.click(allTeamModelsOption);
|
||||
});
|
||||
});
|
||||
|
||||
const submitButton = screen.getByRole("button", { name: /create key/i });
|
||||
|
||||
let formValues: Record<string, any> = {};
|
||||
mockKeyCreateCall.mockImplementation(async (_token: string, _userId: string, values: Record<string, any>) => {
|
||||
formValues = values;
|
||||
return { key: "test-api-key", soft_budget: null };
|
||||
});
|
||||
|
||||
act(() => {
|
||||
fireEvent.click(submitButton);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(addKey).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(formValues.duration).toBeNull();
|
||||
}, 10000); // 10 second timeout for complex test
|
||||
|
||||
it("should set duration correctly when a value is provided", async () => {
|
||||
const addKey = vi.fn();
|
||||
render(<CreateKey {...defaultProps} addKey={addKey} />);
|
||||
|
||||
const createButton = screen.getByRole("button", { name: /create new key/i });
|
||||
act(() => {
|
||||
fireEvent.click(createButton);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("Key Ownership")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const keyAliasInput = screen.getByPlaceholderText("");
|
||||
act(() => {
|
||||
fireEvent.change(keyAliasInput, { target: { value: "test-key" } });
|
||||
});
|
||||
|
||||
const modelsSelect = screen.getByPlaceholderText("Select models");
|
||||
act(() => {
|
||||
fireEvent.mouseDown(modelsSelect);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
const allTeamModelsOption = screen.getByText("All Team Models");
|
||||
act(() => {
|
||||
fireEvent.click(allTeamModelsOption);
|
||||
});
|
||||
});
|
||||
|
||||
const optionalSettingsAccordion = screen.getByText("Optional Settings");
|
||||
act(() => {
|
||||
fireEvent.click(optionalSettingsAccordion);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
const keyLifecycleAccordion = screen.getByText("Key Lifecycle");
|
||||
act(() => {
|
||||
fireEvent.click(keyLifecycleAccordion);
|
||||
});
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
const durationInput = screen.getByPlaceholderText("e.g., 30d");
|
||||
act(() => {
|
||||
fireEvent.change(durationInput, { target: { value: "30d" } });
|
||||
});
|
||||
});
|
||||
|
||||
const submitButton = screen.getByRole("button", { name: /create key/i });
|
||||
|
||||
let formValues: Record<string, any> = {};
|
||||
mockKeyCreateCall.mockImplementation(async (_token: string, _userId: string, values: Record<string, any>) => {
|
||||
formValues = values;
|
||||
return { key: "test-api-key", soft_budget: null };
|
||||
});
|
||||
|
||||
act(() => {
|
||||
fireEvent.click(submitButton);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(addKey).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
expect(formValues.duration).toBe("30d");
|
||||
});
|
||||
}, 10000); // 10 second timeout for complex test
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue