From be85d1db2f8e2b7b75d61208790edf591694a332 Mon Sep 17 00:00:00 2001 From: maiconcarraro Date: Tue, 8 Oct 2024 13:18:37 -0300 Subject: [PATCH 1/2] fix: playwright tests --- apps/pwabuilder/playwright.config.ts | 2 +- apps/pwabuilder/tests/basic.spec.ts | 4 +--- apps/pwabuilder/tests/packaging.spec.ts | 12 ++++-------- apps/pwabuilder/tests/report-card.spec.ts | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/apps/pwabuilder/playwright.config.ts b/apps/pwabuilder/playwright.config.ts index 08b3a1467..8715d4a44 100644 --- a/apps/pwabuilder/playwright.config.ts +++ b/apps/pwabuilder/playwright.config.ts @@ -35,7 +35,7 @@ export default defineConfig({ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://localhost:3000', + baseURL: process.env.CI ? 'https://preview.pwabuilder.com': 'http://localhost:3000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', diff --git a/apps/pwabuilder/tests/basic.spec.ts b/apps/pwabuilder/tests/basic.spec.ts index cbfbc1529..32adbb3b9 100644 --- a/apps/pwabuilder/tests/basic.spec.ts +++ b/apps/pwabuilder/tests/basic.spec.ts @@ -1,10 +1,8 @@ import { test, expect } from '@playwright/test'; -const url = 'https://preview.pwabuilder.com/'; - // before each test test.beforeEach(async ({ page }) => { - await page.goto(url); + await page.goto('/'); }); test('ensure application loads home page', async ({ page }) => { diff --git a/apps/pwabuilder/tests/packaging.spec.ts b/apps/pwabuilder/tests/packaging.spec.ts index 60ce1ad26..5dc56fc65 100644 --- a/apps/pwabuilder/tests/packaging.spec.ts +++ b/apps/pwabuilder/tests/packaging.spec.ts @@ -2,11 +2,10 @@ import { test, expect, Page } from '@playwright/test'; let currentPage: Page | undefined; -const url = 'https://preview.pwabuilder.com/'; // before each test test.beforeEach(async ({ page }) => { currentPage = page; - await page.goto(url); + await page.goto('/'); }); // only run this test once @@ -49,15 +48,12 @@ test('Ensure demo app can be packaged for Windows', async ({ page }) => { await expect(generateButton).toBeVisible(); - // wait on request to https://pwabuilder-windows-docker.azurewebsites.net/msix/generatezip to finish - const pageRequest = page.waitForRequest( - 'https://pwabuilder-windows-docker.azurewebsites.net/msix/generatezip' - ); + // wait on request to finish + const pageRequest = page.waitForRequest('https://pwabuilder-windows-docker-dev.azurewebsites.net/msix/generatezip'); await generateButton.click(); const request = await pageRequest; - // wait for response to https://pwabuilder-windows-docker.azurewebsites.net/msix/generatezip to finish - + // wait for response to finish const response = await request.response(); if (response) { diff --git a/apps/pwabuilder/tests/report-card.spec.ts b/apps/pwabuilder/tests/report-card.spec.ts index b1a1dfd55..8c3046845 100644 --- a/apps/pwabuilder/tests/report-card.spec.ts +++ b/apps/pwabuilder/tests/report-card.spec.ts @@ -2,11 +2,10 @@ import { test, expect, Page } from '@playwright/test'; let currentPage: Page | undefined; -const url = 'https://preview.pwabuilder.com'; // before each test test.beforeEach(async ({ page }) => { currentPage = page; - await page.goto(url); + await page.goto('/'); }); From a88a43214ffa547bf738f623f78e8308a65cc5b5 Mon Sep 17 00:00:00 2001 From: maiconcarraro Date: Tue, 8 Oct 2024 13:23:49 -0300 Subject: [PATCH 2/2] fix: increase timeout for localhost --- apps/pwabuilder/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/pwabuilder/playwright.config.ts b/apps/pwabuilder/playwright.config.ts index 8715d4a44..7fc4a9461 100644 --- a/apps/pwabuilder/playwright.config.ts +++ b/apps/pwabuilder/playwright.config.ts @@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: './tests', /* Maximum time one test can run for. */ - timeout: 30 * 1000, + timeout: (process.env.CI ? 30 : 50) * 1000, expect: { /** * Maximum time expect() should wait for the condition to be met.