Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ui/litellm-dashboard/e2e_tests/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
export const ADMIN_STORAGE_PATH = "admin.storageState.json";

export const E2E_UPDATE_LIMITS_KEY_ID_PREFIX = "102c";
export const E2E_DELETE_KEY_ID_PREFIX = "94a5";
export const E2E_DELETE_KEY_NAME = "e2eDeleteKey";
export const E2E_REGENERATE_KEY_ID_PREFIX = "593a";
25 changes: 25 additions & 0 deletions ui/litellm-dashboard/e2e_tests/tests/keys/deleteKey.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test, expect } from "@playwright/test";
import { ADMIN_STORAGE_PATH, E2E_DELETE_KEY_ID_PREFIX, E2E_DELETE_KEY_NAME } from "../../constants";
import { Page } from "../../fixtures/pages";
import { navigateToPage } from "../../helpers/navigation";

test.describe("Delete Key", () => {
test.use({ storageState: ADMIN_STORAGE_PATH });

test("Able to delete a key", async ({ page }) => {
await navigateToPage(page, Page.ApiKeys);
await expect(page.getByRole("button", { name: "Next" })).toBeVisible();
await page
.locator("button", {
hasText: E2E_DELETE_KEY_ID_PREFIX,
})
.click();
await page.getByRole("button", { name: "Delete Key" }).click();
await page.getByRole("textbox", { name: E2E_DELETE_KEY_NAME }).click();
await page.getByRole("textbox", { name: E2E_DELETE_KEY_NAME }).fill(E2E_DELETE_KEY_NAME);
const deleteButton = page.getByRole("button", { name: "Delete", exact: true });
Comment on lines +18 to +20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect accessible name

The locator getByRole("textbox", { name: E2E_DELETE_KEY_NAME }) uses the accessible name of the input, not the placeholder/value. If the confirmation field is labeled something like "Type key name to confirm", this will never match and the test will fail. Prefer targeting the textbox by its real label (or by a stable data-testid) and then fill(E2E_DELETE_KEY_NAME).

This same issue appears twice here (click + fill) and will break the delete flow if the textbox isn’t literally named e2eDeleteKey.

await expect(deleteButton).toBeEnabled();
await deleteButton.click();
await expect(page.getByText("Key deleted successfully")).toBeVisible();
});
});
21 changes: 21 additions & 0 deletions ui/litellm-dashboard/e2e_tests/tests/keys/regenerateKey.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test, expect } from "@playwright/test";
import { ADMIN_STORAGE_PATH, E2E_REGENERATE_KEY_ID_PREFIX } from "../../constants";
import { Page } from "../../fixtures/pages";
import { navigateToPage } from "../../helpers/navigation";

test.describe("Regenerate Key", () => {
test.use({ storageState: ADMIN_STORAGE_PATH });

test("Able to regenerate a key", async ({ page }) => {
await navigateToPage(page, Page.ApiKeys);
await expect(page.getByRole("button", { name: "Next" })).toBeVisible();
await page
.locator("button", {
hasText: E2E_REGENERATE_KEY_ID_PREFIX,
})
.click();
await page.getByRole("button", { name: "Regenerate Key" }).click();
await page.getByRole("button", { name: "Regenerate", exact: true }).click();
await expect(page.getByText("Virtual Key regenerated")).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, expect } from "@playwright/test";
import { ADMIN_STORAGE_PATH, E2E_UPDATE_LIMITS_KEY_ID_PREFIX } from "../../constants";
import { Page } from "../../fixtures/pages";
import { navigateToPage } from "../../helpers/navigation";

test.describe("Update Key TPM and RPM Limits", () => {
test.use({ storageState: ADMIN_STORAGE_PATH });

test("Able to update a key's TPM and RPM limits", async ({ page }) => {
await navigateToPage(page, Page.ApiKeys);
await expect(page.getByRole("button", { name: "Next" })).toBeVisible();
await page
.locator("button", {
hasText: E2E_UPDATE_LIMITS_KEY_ID_PREFIX,
})
.click();
await page.getByRole("tab", { name: "Settings" }).click();
await page.getByRole("button", { name: "Edit Settings" }).click();
await page.getByRole("spinbutton", { name: "TPM Limit" }).click();
await page.getByRole("spinbutton", { name: "TPM Limit" }).fill("123");
await page.getByRole("spinbutton", { name: "RPM Limit" }).click();
await page.getByRole("spinbutton", { name: "RPM Limit" }).fill("456");
await page.getByRole("button", { name: "Save Changes" }).click();
await expect(page.getByRole("paragraph").filter({ hasText: "TPM: 123" })).toBeVisible();
await expect(page.getByRole("paragraph").filter({ hasText: "RPM: 456" })).toBeVisible();
});
});
Loading