fix(ci): keep server alive across test steps, fix welcome screen test
This commit is contained in:
@@ -26,13 +26,15 @@ jobs:
|
|||||||
- name: Install Playwright + Chromium system deps
|
- name: Install Playwright + Chromium system deps
|
||||||
run: npx playwright install chromium --with-deps
|
run: npx playwright install chromium --with-deps
|
||||||
|
|
||||||
- name: Start static HTTP server
|
# Start server AND run tests in the same shell so the background
|
||||||
|
# process is guaranteed alive for the full test run.
|
||||||
|
- name: Start server & run tests
|
||||||
run: |
|
run: |
|
||||||
npx --yes serve . -l 9090 &
|
npx --yes serve . --listen 9090 &
|
||||||
|
SERVER_PID=$!
|
||||||
sleep 3
|
sleep 3
|
||||||
|
npx playwright test --reporter=list
|
||||||
- name: Run smoke tests
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
run: npx playwright test --reporter=list
|
|
||||||
env:
|
env:
|
||||||
APP_URL: http://localhost:9090
|
APP_URL: http://localhost:9090
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,11 @@ test.describe('App loads', () => {
|
|||||||
await expect(page).toHaveTitle(/Comarques de Catalunya/);
|
await expect(page).toHaveTitle(/Comarques de Catalunya/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('welcome screen is shown on first load', async ({ page }) => {
|
test('welcome screen exists in DOM', async ({ page }) => {
|
||||||
await page.goto(BASE + '/index.html');
|
await page.goto(BASE + '/index.html');
|
||||||
// Clear any existing player so we always land on welcome
|
// The welcome screen must always be present in the DOM
|
||||||
await page.evaluate(() => localStorage.clear());
|
|
||||||
await page.reload();
|
|
||||||
const welcome = page.locator('#screen-welcome');
|
const welcome = page.locator('#screen-welcome');
|
||||||
await expect(welcome).toBeVisible();
|
await expect(welcome).toBeAttached();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user