From 0f613b21a6cdc870b9153333830fb1858d40610b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20M=C3=B6rling?= Date: Tue, 19 May 2026 19:40:40 +0200 Subject: [PATCH] fix: allow frontend container host in vite preview and update payment E2E tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: add preview.allowedHosts and preview.host to vite.config.ts Vite preview server blocks requests from non-localhost hosts by default. In the E2E Docker Compose stack, Playwright accesses the frontend via http://frontend (container hostname). Without allowedHosts, Vite returns "Blocked request. This host is not allowed." and the SPA never mounts, causing all 59 E2E tests to fail with blank pages and missing elements. - Add preview.host: true (bind to 0.0.0.0) - Add preview.allowedHosts: ['frontend', 'localhost'] test: update payment-redirect E2E tests to match current UI The payment page was redesigned to a two-step confirmation flow: "Jag har betalat" → confirmation → "Ja, jag har betalat". The E2E tests still referenced the old single-step "Genomför testbetalning" button and a removed .payment__note CSS class. - Update 'payment button marks order as paid' to click through both steps - Rename 'shows mock payment note' to 'shows Swish payment instructions' and assert on actual UI elements (Swish label + payment button) Result: E2E suite now passes 59/59 tests in the Docker Compose CI stack. --- frontend/e2e/payment-redirect.spec.ts | 8 +++++--- frontend/vite.config.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/e2e/payment-redirect.spec.ts b/frontend/e2e/payment-redirect.spec.ts index 30c230e..c479011 100644 --- a/frontend/e2e/payment-redirect.spec.ts +++ b/frontend/e2e/payment-redirect.spec.ts @@ -28,7 +28,8 @@ test.describe('Payment redirect', () => { await page.getByRole('button', { name: 'Fortsätt till betalning' }).click() await page.waitForURL(/\/betalning\//) - await page.getByRole('button', { name: 'Genomför testbetalning' }).click() + await page.getByRole('button', { name: 'Jag har betalat' }).click() + await page.getByRole('button', { name: 'Ja, jag har betalat' }).click() await expect(page).toHaveURL('/orders') await expect(page.getByText('DEF456').first()).toBeVisible() @@ -41,12 +42,13 @@ test.describe('Payment redirect', () => { await expect(page).toHaveURL(/\/logga-in/) }) - test('shows mock payment note', async ({ page }) => { + test('shows Swish payment instructions', async ({ page }) => { await page.goto('/compose?plate=GHI789') await page.getByLabel('Ditt meddelande').fill('Hej!') await page.getByRole('button', { name: 'Fortsätt till betalning' }).click() await page.waitForURL(/\/betalning\//) - await expect(page.locator('.payment__note')).toBeVisible() + await expect(page.getByText('Swisha till')).toBeVisible() + await expect(page.getByRole('button', { name: 'Jag har betalat' })).toBeVisible() }) }) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 24f178a..5c35fd0 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -18,6 +18,8 @@ export default defineConfig({ }, preview: { port: 80, + host: true, + allowedHosts: ['frontend', 'localhost'], proxy: { '/api': 'http://backend:8080', },