From 75b3e111055c2f02030d147d093ab2fcac17c278 Mon Sep 17 00:00:00 2001 From: Alan Buscaglia Date: Tue, 20 Jan 2026 15:36:25 +0100 Subject: [PATCH] refactor(ui): remove duplicated sign-in helpers and update env var names --- ui/tests/helpers.ts | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/ui/tests/helpers.ts b/ui/tests/helpers.ts index 0f55cc0101..19dabc837f 100644 --- a/ui/tests/helpers.ts +++ b/ui/tests/helpers.ts @@ -1,16 +1,7 @@ import { Locator, Page, expect } from "@playwright/test"; -import { - AWSProviderCredential, - AWSProviderData, - AWS_CREDENTIAL_OPTIONS, - ProvidersPage, -} from "./providers/providers-page"; +import { AWSProviderCredential, AWSProviderData, AWS_CREDENTIAL_OPTIONS, ProvidersPage } from "./providers/providers-page"; import { ScansPage } from "./scans/scans-page"; -// =========================================== -// Constants -// =========================================== - export const ERROR_MESSAGES = { INVALID_CREDENTIALS: "Invalid email or password", INVALID_EMAIL: "Please enter a valid email address.", @@ -39,10 +30,6 @@ export const TEST_CREDENTIALS = { }, } as const; -// =========================================== -// Utility Functions -// =========================================== - /** * Generate a random base36 suffix of specified length * Used for creating unique test data to avoid conflicts @@ -55,10 +42,6 @@ export function makeSuffix(len: number): string { return s.slice(0, len); } -// =========================================== -// Session Helpers -// =========================================== - export async function getSession(page: Page) { const response = await page.request.get("/api/auth/session"); return response.json(); @@ -73,15 +56,12 @@ export async function verifySessionValid(page: Page) { return session; } -// =========================================== -// Provider Helpers -// =========================================== export async function addAWSProvider( page: Page, accountId: string, accessKey: string, - secretKey: string + secretKey: string, ): Promise { // Prepare test data for AWS provider const awsProviderData: AWSProviderData = { @@ -119,7 +99,7 @@ export async function addAWSProvider( // Select static credentials type await providersPage.selectCredentialsType( - AWS_CREDENTIAL_OPTIONS.AWS_CREDENTIALS + AWS_CREDENTIAL_OPTIONS.AWS_CREDENTIALS, ); // Fill static credentials await providersPage.fillStaticCredentials(staticCredentials); @@ -134,10 +114,7 @@ export async function addAWSProvider( await scansPage.verifyPageLoaded(); } -export async function deleteProviderIfExists( - page: ProvidersPage, - providerUID: string -): Promise { +export async function deleteProviderIfExists(page: ProvidersPage, providerUID: string): Promise { // Delete the provider if it exists // Navigate to providers page @@ -194,6 +171,7 @@ export async function deleteProviderIfExists( // Wait for filtering to complete (max 0 or 1 data rows) await expect(async () => { + await findProviderRow(); const count = await allRows.count(); @@ -221,7 +199,11 @@ export async function deleteProviderIfExists( } // Find and click the action button (last cell = actions column) - const actionButton = targetRow.locator("td").last().locator("button").first(); + const actionButton = targetRow + .locator("td") + .last() + .locator("button") + .first(); // Ensure the button is in view before clicking (handles horizontal scroll) await actionButton.scrollIntoViewIfNeeded();