From 385133b63a5334a206fbf14fd7d4fc707e1306e2 Mon Sep 17 00:00:00 2001 From: StylusFrost Date: Fri, 21 Nov 2025 11:21:33 +0100 Subject: [PATCH] fix(auth): update logout behavior to redirect to sign-in page; refactor tests to remove unnecessary page load waits --- ui/actions/auth/auth.ts | 2 +- ui/tests/base-page.ts | 6 ------ ui/tests/providers/providers-page.ts | 22 ---------------------- ui/tests/scans/scans-page.ts | 1 - ui/tests/sign-up/sign-up-page.ts | 1 - 5 files changed, 1 insertion(+), 31 deletions(-) diff --git a/ui/actions/auth/auth.ts b/ui/actions/auth/auth.ts index 9dfdde4d9a..5ea25b3c36 100644 --- a/ui/actions/auth/auth.ts +++ b/ui/actions/auth/auth.ts @@ -188,5 +188,5 @@ export const getUserByMe = async (accessToken: string) => { }; export async function logOut() { - await signOut(); + await signOut({ redirectTo: "/sign-in" }); } diff --git a/ui/tests/base-page.ts b/ui/tests/base-page.ts index c9b73f2b1a..85a68f250e 100644 --- a/ui/tests/base-page.ts +++ b/ui/tests/base-page.ts @@ -24,21 +24,15 @@ export abstract class BasePage { // Common navigation methods async goto(url: string): Promise { await this.page.goto(url); - await this.waitForPageLoad(); } - async waitForPageLoad(): Promise { - await this.page.waitForLoadState("networkidle"); - } async refresh(): Promise { await this.page.reload(); - await this.waitForPageLoad(); } async goBack(): Promise { await this.page.goBack(); - await this.waitForPageLoad(); } // Common verification methods diff --git a/ui/tests/providers/providers-page.ts b/ui/tests/providers/providers-page.ts index 1a28c64f8c..3daba6f2dc 100644 --- a/ui/tests/providers/providers-page.ts +++ b/ui/tests/providers/providers-page.ts @@ -275,33 +275,28 @@ export class ProvidersPage extends BasePage { // Click the add provider button await this.addProviderButton.click(); - await this.waitForPageLoad(); } async selectAWSProvider(): Promise { // Prefer label-based click for radios, force if overlay intercepts await this.awsProviderRadio.click({ force: true }); - await this.waitForPageLoad(); } async selectAZUREProvider(): Promise { // Prefer label-based click for radios, force if overlay intercepts await this.azureProviderRadio.click({ force: true }); - await this.waitForPageLoad(); } async selectM365Provider(): Promise { // Select the M365 provider await this.m365ProviderRadio.click({ force: true }); - await this.waitForPageLoad(); } async selectKubernetesProvider(): Promise { // Select the Kubernetes provider await this.kubernetesProviderRadio.click({ force: true }); - await this.waitForPageLoad(); } @@ -356,7 +351,6 @@ export class ProvidersPage extends BasePage { // If on the "connect-account" step, click the "Next" button if (/\/providers\/connect-account/.test(url)) { await this.nextButton.click(); - await this.waitForPageLoad(); return; } @@ -367,13 +361,11 @@ export class ProvidersPage extends BasePage { if (await saveBtn.count()) { await saveBtn.click(); - await this.waitForPageLoad(); return; } // If "Save" is not present, try clicking the "Next" button if (await this.nextButton.count()) { await this.nextButton.click(); - await this.waitForPageLoad(); return; } } @@ -385,7 +377,6 @@ export class ProvidersPage extends BasePage { .filter({ hasText: "Launch scan" }); await buttonByText.click(); - await this.waitForPageLoad(); // Wait for either success (redirect to scans) or error message to appear // The error container has multiple p.text-text-error elements, we want the first one with the technical error @@ -446,7 +437,6 @@ export class ProvidersPage extends BasePage { if (await btn.count()) { await btn.click(); - await this.waitForPageLoad(); return; } } @@ -469,8 +459,6 @@ export class ProvidersPage extends BasePage { } else { throw new Error(`Invalid AWS credential type: ${type}`); } - // Wait for the page to load - await this.waitForPageLoad(); } async selectM365CredentialsType(type: M365CredentialType): Promise { @@ -485,8 +473,6 @@ export class ProvidersPage extends BasePage { } else { throw new Error(`Invalid M365 credential type: ${type}`); } - // Wait for the page to load - await this.waitForPageLoad(); } async fillRoleCredentials(credentials: AWSProviderCredential): Promise { @@ -586,7 +572,6 @@ export class ProvidersPage extends BasePage { await expect(this.page).toHaveTitle(/Prowler/); await expect(this.addProviderButton).toBeVisible(); - await this.page.waitForLoadState("networkidle"); } async verifyConnectAccountPageLoaded(): Promise { @@ -646,7 +631,6 @@ export class ProvidersPage extends BasePage { async verifyLoadProviderPageAfterNewProvider(): Promise { // Verify the provider page is loaded - await this.waitForPageLoad(); await expect(this.page).toHaveTitle(/Prowler/); await expect(this.providersTable).toBeVisible(); } @@ -684,9 +668,6 @@ export class ProvidersPage extends BasePage { await searchInput.fill(providerUID); await searchInput.press("Enter"); - // Wait for the table to finish loading/filtering - await this.waitForPageLoad(); - // Additional wait for React table to re-render with the server-filtered data // The filtering happens on the server, but the table component needs time // to process the response and update the DOM after network idle @@ -782,9 +763,6 @@ export class ProvidersPage extends BasePage { // Wait for modal to close (this indicates deletion was initiated) await expect(modal).not.toBeVisible({ timeout: 10000 }); - // Wait for page to reload - await this.waitForPageLoad(); - // Navigate back to providers page to ensure clean state await this.goto(); await expect(this.providersTable).toBeVisible({ timeout: 10000 }); diff --git a/ui/tests/scans/scans-page.ts b/ui/tests/scans/scans-page.ts index beb7d3cea9..9d6e18e535 100644 --- a/ui/tests/scans/scans-page.ts +++ b/ui/tests/scans/scans-page.ts @@ -23,6 +23,5 @@ export class ScansPage extends BasePage { async verifyPageLoaded(): Promise { await expect(this.page).toHaveTitle(/Prowler/); await expect(this.scanTable).toBeVisible(); - await this.waitForPageLoad(); } } diff --git a/ui/tests/sign-up/sign-up-page.ts b/ui/tests/sign-up/sign-up-page.ts index 30d8f4d50d..49eb6fe378 100644 --- a/ui/tests/sign-up/sign-up-page.ts +++ b/ui/tests/sign-up/sign-up-page.ts @@ -50,7 +50,6 @@ export class SignUpPage extends BasePage { await expect(this.page.getByRole("heading", { name: "Sign up" })).toBeVisible(); await expect(this.emailInput).toBeVisible(); await expect(this.submitButton).toBeVisible(); - await this.waitForPageLoad(); } async fillName(name: string): Promise {