Reverted a couple test files to original implementation from upstream main

This commit is contained in:
omnisilica 2025-04-18 23:31:32 -04:00
parent 61de6a4004
commit d492226add
2 changed files with 32 additions and 80 deletions

View file

@ -6,17 +6,17 @@ Basic UI Test
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
await page.goto("http://localhost:4000/ui");
await page.goto('http://localhost:4000/ui');
// 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
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
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
await loginButton.click();
const tabs = [
"Virtual Keys",
"Test Key",
"Models",
"Usage",
"Teams",
"Internal User",
"Settings",
"Experimental",
"API Reference",
"Model Hub",
'Virtual Keys',
'Test Key',
'Models',
'Usage',
'Teams',
'Internal User',
'Settings',
'Experimental',
'API Reference',
'Model Hub'
];
for (const tab of tabs) {
const tabElement = page.locator("span.ant-menu-title-content", {
hasText: tab,
});
const tabElement = page.locator('span.ant-menu-title-content', { hasText: tab });
await tabElement.click();
}
});

View file

@ -2,17 +2,17 @@
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
await page.goto("http://localhost:4000/ui");
await page.goto('http://localhost:4000/ui');
// 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
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
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
await loginButton.click();
const tabElement = page.locator("span.ant-menu-title-content", {
hasText: "Internal User",
});
const tabElement = page.locator('span.ant-menu-title-content', { hasText: 'Internal User' });
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>
// wait 1-2 seconds
await page.waitForTimeout(10000);
// Test all expected fields are present
// number of keys owned by user
const keysBadges = await page
.locator("p.tremor-Badge-text.text-sm.whitespace-nowrap", {
hasText: "Keys",
})
.all();
// Test all expected fields are present
// number of keys owned by user
const keysBadges = page.locator('p.tremor-Badge-text.text-sm.whitespace-nowrap', { hasText: 'Keys' });
const keysCountArray = await keysBadges.evaluateAll(elements => elements.map(el => parseInt(el.textContent.split(' ')[0], 10)));
/*
const keysCountArray = await keysBadges.evaluateAll((elements) => {
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);
}
const hasNonZeroKeys = keysCountArray.some(count => count > 0);
expect(hasNonZeroKeys).toBe(true);
// test pagination
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" }
);
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' });
await expect(prevButton).toBeDisabled();
let paginationText = await page
.locator(".flex.items-center.space-x-2")
.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();
}
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();
});