diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fb434133..84d2e88c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -266,6 +266,13 @@ jobs: max_attempts: 3 retry_wait_seconds: 30 command: rad deploy ${{ matrix.path }} ${{ matrix.deployArgs }} + - name: Wait for all pods to be ready + if: steps.gen-id.outputs.RUN_TEST == 'true' + id: wait-for-pods + run: | + namespace="${{ matrix.env }}-${{ matrix.app }}" + label="radapp.io/application=${{ matrix.app }}" + kubectl rollout status deployment -l $label -n $namespace --timeout=120s - name: Run Playwright Test if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != '' id: run-playwright-test diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index a44ba2e0..5c4cfc24 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -47,8 +47,8 @@ export default defineConfig({ use: { ...devices["Desktop Safari"] }, }, ], - timeout: 1 * 60 * 1000, + timeout: 2 * 60 * 1000, expect: { - timeout: 30 * 1000, + timeout: 60 * 1000, }, }); diff --git a/playwright/tests/eshop/eshop.app.spec.ts b/playwright/tests/eshop/eshop.app.spec.ts index 4340cc88..38bb61d3 100644 --- a/playwright/tests/eshop/eshop.app.spec.ts +++ b/playwright/tests/eshop/eshop.app.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from "@playwright/test"; +import { expect, test } from "@playwright/test"; test("eShop on Containers App Basic UI and Functionality Checks", async ({ page, @@ -17,17 +17,34 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({ let endpoint = process.env.ENDPOINT; expect(endpoint).toBeDefined(); - // Remove quotes from the endpoint if they exist - try { - endpoint = (endpoint as string).replace(/['"]+/g, ""); - log(`Navigating to the endpoint: ${endpoint}`); - await page.goto(endpoint); - } catch (error) { - console.error( - `Attempt ${testInfo.retry}: Failed to navigate to the endpoint:`, - error - ); - } +// Remove quotes from the endpoint if they exist +try { + endpoint = (endpoint as string).replace(/['"]+/g, ""); + log(`Endpoint after removing quotes: ${endpoint}`); +} catch (error) { + console.error(`Error processing the endpoint:`, error); +} + +// Check if the endpoint is reachable +try { + const response = await fetch(endpoint); + if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`); + log(`Endpoint is reachable: ${endpoint}`); +} catch (error) { + console.error(`Failed to reach the endpoint:`, error); + return; +} + +// Navigate to the endpoint +try { + log(`Navigating to the endpoint: ${endpoint}`); + await page.goto(endpoint); +} catch (error) { + console.error( + `Attempt ${testInfo.retry}: Failed to navigate to the endpoint:`, + error + ); +} // Expect page to have proper URL log(`Checking the URL: ${endpoint}/catalog`); diff --git a/playwright/tests/util/helper.ts b/playwright/tests/util/helper.ts index 45a5b500..e8a3eeec 100644 --- a/playwright/tests/util/helper.ts +++ b/playwright/tests/util/helper.ts @@ -1,6 +1,6 @@ import axios from "axios"; -export async function waitForWebApp(url: string | undefined, timeout = 30000) { +export async function waitForWebApp(url: string | undefined, timeout = 60000) { if (!url) { throw new Error("URL is not defined"); }