Skip to content

Commit

Permalink
try this for playwright test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmimsft committed Jul 12, 2024
1 parent e755fe8 commit 05e38f9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
41 changes: 29 additions & 12 deletions playwright/tests/eshop/eshop.app.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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`);
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/util/helper.ts
Original file line number Diff line number Diff line change
@@ -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");
}
Expand Down

0 comments on commit 05e38f9

Please sign in to comment.