From 3cc49beb451cb45aa19900acf3353c965df810c3 Mon Sep 17 00:00:00 2001 From: StylusFrost Date: Wed, 29 Oct 2025 15:50:48 +0100 Subject: [PATCH] test(ui): needs space --- ui/tests/providers/providers-page.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/tests/providers/providers-page.ts b/ui/tests/providers/providers-page.ts index 42616a4319..508a65659d 100644 --- a/ui/tests/providers/providers-page.ts +++ b/ui/tests/providers/providers-page.ts @@ -363,6 +363,7 @@ export class ProvidersPage extends BasePage { // Fill the Kubernetes provider details await this.kubernetesContextInput.fill(data.context); + if (data.alias) { await this.aliasInput.fill(data.alias); } @@ -372,6 +373,7 @@ export class ProvidersPage extends BasePage { // Fill the GCP provider details await this.gcpProjectIdInput.fill(data.projectId); + if (data.alias) { await this.aliasInput.fill(data.alias); } @@ -395,6 +397,7 @@ export class ProvidersPage extends BasePage { if (/\/providers\/add-credentials/.test(url)) { // Some UI implementations use "Save" instead of "Next" for primary action const saveBtn = this.saveButton; + if (await saveBtn.count()) { await saveBtn.click(); await this.waitForPageLoad(); @@ -410,6 +413,7 @@ export class ProvidersPage extends BasePage { // If on the "test-connection" step, click the "Launch scan" button if (/\/providers\/test-connection/.test(url)) { + const buttonByText = this.page .locator("button") .filter({ hasText: "Launch scan" }); @@ -433,8 +437,10 @@ export class ProvidersPage extends BasePage { // If we're still on test-connection page, check for error if (/\/providers\/test-connection/.test(this.page.url())) { const isErrorVisible = await errorMessage.isVisible().catch(() => false); + if (isErrorVisible) { const errorText = await errorMessage.textContent(); + throw new Error( `Test connection failed with error: ${errorText?.trim() || "Unknown error"}`, ); @@ -443,8 +449,11 @@ export class ProvidersPage extends BasePage { } catch (error) { // If timeout or other error, check if error message is present const isErrorVisible = await errorMessage.isVisible().catch(() => false); + if (isErrorVisible) { + const errorText = await errorMessage.textContent(); + throw new Error( `Test connection failed with error: ${errorText?.trim() || "Unknown error"}`, ); @@ -488,6 +497,7 @@ export class ProvidersPage extends BasePage { // Ensure we are on the add-credentials page where the selector exists await expect(this.page).toHaveURL(/\/providers\/add-credentials/); + if (type === AWS_CREDENTIAL_OPTIONS.AWS_ROLE_ARN) { await this.roleCredentialsRadio.click({ force: true }); } else if (type === AWS_CREDENTIAL_OPTIONS.AWS_CREDENTIALS) { @@ -503,6 +513,7 @@ export class ProvidersPage extends BasePage { // Ensure we are on the add-credentials page where the selector exists await expect(this.page).toHaveURL(/\/providers\/add-credentials/); + if (type === M365_CREDENTIAL_OPTIONS.M365_CREDENTIALS) { await this.m365StaticCredentialsRadio.click({ force: true }); } else if (type === M365_CREDENTIAL_OPTIONS.M365_CERTIFICATE_CREDENTIALS) { @@ -681,6 +692,7 @@ export class ProvidersPage extends BasePage { const launchScanButton = this.page .locator("button") .filter({ hasText: "Launch scan" }); + await expect(launchScanButton).toBeVisible(); } @@ -717,6 +729,7 @@ export class ProvidersPage extends BasePage { // Find and use the search input to filter the table const searchInput = this.page.getByPlaceholder(/search|filter/i); + await expect(searchInput).toBeVisible({ timeout: 5000 }); // Clear and search for the specific provider @@ -734,7 +747,7 @@ export class ProvidersPage extends BasePage { // Get all rows from the table const allRows = this.providersTable.locator("tbody tr"); - + // Helper function to check if a row is the "No results" row const isNoResultsRow = async (row: Locator): Promise => { const text = await row.textContent(); @@ -795,6 +808,7 @@ export class ProvidersPage extends BasePage { // Find and click the action button (last cell = actions column) const actionButton = targetRow.locator("td").last().locator("button").first(); + await expect(actionButton).toBeVisible({ timeout: 5000 }); await actionButton.click(); @@ -802,11 +816,13 @@ export class ProvidersPage extends BasePage { const deleteMenuItem = this.page.getByRole("menuitem", { name: /delete.*provider/i, }); + await expect(deleteMenuItem).toBeVisible({ timeout: 5000 }); await deleteMenuItem.click(); // Wait for confirmation modal to appear const modal = this.page.locator('[role="dialog"], .modal, [data-testid*="modal"]').first(); + await expect(modal).toBeVisible({ timeout: 10000 }); // Find and click the delete confirmation button