From d492226add89e5111be76e9bfac16db80b825cfe Mon Sep 17 00:00:00 2001 From: omnisilica Date: Fri, 18 Apr 2025 23:31:32 -0400 Subject: [PATCH] Reverted a couple test files to original implementation from upstream main --- .../e2e_ui_tests/login_to_ui.spec.ts | 34 ++++---- .../e2e_ui_tests/view_internal_user.spec.ts | 78 ++++--------------- 2 files changed, 32 insertions(+), 80 deletions(-) diff --git a/tests/proxy_admin_ui_tests/e2e_ui_tests/login_to_ui.spec.ts b/tests/proxy_admin_ui_tests/e2e_ui_tests/login_to_ui.spec.ts index 4a32c39c6f..f5148bed16 100644 --- a/tests/proxy_admin_ui_tests/e2e_ui_tests/login_to_ui.spec.ts +++ b/tests/proxy_admin_ui_tests/e2e_ui_tests/login_to_ui.spec.ts @@ -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(); } }); diff --git a/tests/proxy_admin_ui_tests/e2e_ui_tests/view_internal_user.spec.ts b/tests/proxy_admin_ui_tests/e2e_ui_tests/view_internal_user.spec.ts index 348d275736..4d27a4a7ce 100644 --- a/tests/proxy_admin_ui_tests/e2e_ui_tests/view_internal_user.spec.ts +++ b/tests/proxy_admin_ui_tests/e2e_ui_tests/view_internal_user.spec.ts @@ -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 // // 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(); });