mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Reverted a couple test files to original implementation from upstream main
This commit is contained in:
parent
61de6a4004
commit
d492226add
2 changed files with 32 additions and 80 deletions
|
@ -6,17 +6,17 @@ Basic UI Test
|
||||||
Click on all the tabs ensure nothing is broken
|
Click on all the tabs ensure nothing is broken
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test, expect } from "@playwright/test";
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
test("admin login test", async ({ page }) => {
|
test('admin login test', async ({ page }) => {
|
||||||
// Go to the specified URL
|
// Go to the specified URL
|
||||||
await page.goto("http://localhost:4000/ui");
|
await page.goto('http://localhost:4000/ui');
|
||||||
|
|
||||||
// Enter "admin" in the username input field
|
// Enter "admin" in the username input field
|
||||||
await page.fill('input[name="username"]', "admin");
|
await page.fill('input[name="username"]', 'admin');
|
||||||
|
|
||||||
// Enter "gm" in the password input field
|
// Enter "gm" in the password input field
|
||||||
await page.fill('input[name="password"]', "sk-1234");
|
await page.fill('input[name="password"]', 'gm');
|
||||||
|
|
||||||
// Optionally, you can add an assertion to verify the login button is enabled
|
// Optionally, you can add an assertion to verify the login button is enabled
|
||||||
const loginButton = page.locator('input[type="submit"]');
|
const loginButton = page.locator('input[type="submit"]');
|
||||||
|
@ -25,22 +25,20 @@ test("admin login test", async ({ page }) => {
|
||||||
// Optionally, you can click the login button to submit the form
|
// Optionally, you can click the login button to submit the form
|
||||||
await loginButton.click();
|
await loginButton.click();
|
||||||
const tabs = [
|
const tabs = [
|
||||||
"Virtual Keys",
|
'Virtual Keys',
|
||||||
"Test Key",
|
'Test Key',
|
||||||
"Models",
|
'Models',
|
||||||
"Usage",
|
'Usage',
|
||||||
"Teams",
|
'Teams',
|
||||||
"Internal User",
|
'Internal User',
|
||||||
"Settings",
|
'Settings',
|
||||||
"Experimental",
|
'Experimental',
|
||||||
"API Reference",
|
'API Reference',
|
||||||
"Model Hub",
|
'Model Hub'
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
const tabElement = page.locator("span.ant-menu-title-content", {
|
const tabElement = page.locator('span.ant-menu-title-content', { hasText: tab });
|
||||||
hasText: tab,
|
|
||||||
});
|
|
||||||
await tabElement.click();
|
await tabElement.click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
Test view internal user page
|
Test view internal user page
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { test, expect } from "@playwright/test";
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
test("view internal user page", async ({ page }) => {
|
test('view internal user page', async ({ page }) => {
|
||||||
// Go to the specified URL
|
// Go to the specified URL
|
||||||
await page.goto("http://localhost:4000/ui");
|
await page.goto('http://localhost:4000/ui');
|
||||||
|
|
||||||
// Enter "admin" in the username input field
|
// Enter "admin" in the username input field
|
||||||
await page.fill('input[name="username"]', "admin");
|
await page.fill('input[name="username"]', 'admin');
|
||||||
|
|
||||||
// Enter "gm" in the password input field
|
// Enter "gm" in the password input field
|
||||||
await page.fill('input[name="password"]', "sk-1234");
|
await page.fill('input[name="password"]', 'gm');
|
||||||
|
|
||||||
// Optionally, you can add an assertion to verify the login button is enabled
|
// Optionally, you can add an assertion to verify the login button is enabled
|
||||||
const loginButton = page.locator('input[type="submit"]');
|
const loginButton = page.locator('input[type="submit"]');
|
||||||
|
@ -21,72 +21,26 @@ test("view internal user page", async ({ page }) => {
|
||||||
// Optionally, you can click the login button to submit the form
|
// Optionally, you can click the login button to submit the form
|
||||||
await loginButton.click();
|
await loginButton.click();
|
||||||
|
|
||||||
const tabElement = page.locator("span.ant-menu-title-content", {
|
const tabElement = page.locator('span.ant-menu-title-content', { hasText: 'Internal User' });
|
||||||
hasText: "Internal User",
|
|
||||||
});
|
|
||||||
await tabElement.click();
|
await tabElement.click();
|
||||||
|
|
||||||
// try to click on button
|
// try to click on button
|
||||||
// <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none" disabled="">← Prev</button>
|
// <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-l focus:outline-none" disabled="">← Prev</button>
|
||||||
// wait 1-2 seconds
|
// wait 1-2 seconds
|
||||||
await page.waitForTimeout(10000);
|
await page.waitForTimeout(10000);
|
||||||
|
|
||||||
// Test all expected fields are present
|
// Test all expected fields are present
|
||||||
// number of keys owned by user
|
// number of keys owned by user
|
||||||
const keysBadges = await page
|
const keysBadges = page.locator('p.tremor-Badge-text.text-sm.whitespace-nowrap', { hasText: 'Keys' });
|
||||||
.locator("p.tremor-Badge-text.text-sm.whitespace-nowrap", {
|
const keysCountArray = await keysBadges.evaluateAll(elements => elements.map(el => parseInt(el.textContent.split(' ')[0], 10)));
|
||||||
hasText: "Keys",
|
|
||||||
})
|
|
||||||
.all();
|
|
||||||
|
|
||||||
/*
|
const hasNonZeroKeys = keysCountArray.some(count => count > 0);
|
||||||
const keysCountArray = await keysBadges.evaluateAll((elements) => {
|
expect(hasNonZeroKeys).toBe(true);
|
||||||
elements.map((el) => {
|
|
||||||
console.log(el);
|
|
||||||
parseInt(el.textContent.split(" ")[0], 10);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
let keysCountArray: number[] = [];
|
|
||||||
|
|
||||||
for (const element of keysBadges) {
|
|
||||||
if (!((await element.innerText()) === "No Keys")) {
|
|
||||||
keysCountArray.push(
|
|
||||||
parseInt((await element.innerText()).split(" ")[0], 10)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((await keysBadges[0].first().innerText()) != "No Keys") {
|
|
||||||
const hasNonZeroKeys = keysCountArray.some((count) => count > 0);
|
|
||||||
expect(hasNonZeroKeys).toBe(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// test pagination
|
// test pagination
|
||||||
const prevButton = page.locator(
|
const prevButton = page.locator('button.px-3.py-1.text-sm.border.rounded-md.hover\\:bg-gray-50.disabled\\:opacity-50.disabled\\:cursor-not-allowed', { hasText: 'Previous' });
|
||||||
"button.px-3.py-1.text-sm.border.rounded-md.hover\\:bg-gray-50.disabled\\:opacity-50.disabled\\:cursor-not-allowed",
|
|
||||||
{ hasText: "Previous" }
|
|
||||||
);
|
|
||||||
await expect(prevButton).toBeDisabled();
|
await expect(prevButton).toBeDisabled();
|
||||||
|
|
||||||
let paginationText = await page
|
const nextButton = page.locator('button.px-3.py-1.text-sm.border.rounded-md.hover\\:bg-gray-50.disabled\\:opacity-50.disabled\\:cursor-not-allowed', { hasText: 'Next' });
|
||||||
.locator(".flex.items-center.space-x-2")
|
await expect(nextButton).toBeEnabled();
|
||||||
.locator(".text-sm.text-gray-700")
|
|
||||||
.innerText();
|
|
||||||
|
|
||||||
let paginationTextContents = paginationText.split(" ");
|
|
||||||
|
|
||||||
let totalPages = parseInt(
|
|
||||||
paginationTextContents[paginationTextContents.length - 1],
|
|
||||||
10
|
|
||||||
);
|
|
||||||
|
|
||||||
if (totalPages > 1) {
|
|
||||||
const nextButton = page.locator(
|
|
||||||
"button.px-3.py-1.text-sm.border.rounded-md.hover\\:bg-gray-50.disabled\\:opacity-50.disabled\\:cursor-not-allowed",
|
|
||||||
{ hasText: "Next" }
|
|
||||||
);
|
|
||||||
await expect(nextButton).toBeEnabled();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue