From e8530b8d95530e249021867e914099fb8aa1ced7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20M=C3=B6rling?= Date: Tue, 19 May 2026 18:53:52 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20E2E=20pipeline=20=E2=80=94=20vite=20prev?= =?UTF-8?q?iew=20instead=20of=20nginx,=20ts=20build=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three problems caused E2E browser tests to fail in Forgejo CI: 1. TypeScript build errors in (frontend.e2e.Dockerfile): - used parameter property which violates . Replaced with explicit property declaration. - included in type-checking, causing mock Response type mismatches. Added . - mock Order was missing field. 2. Nginx SSL crash: - copied production which references SSL certs that don't exist in the e2e image. - Replaced nginx entirely with (simpler, no SSL needed). - Added to so routes to backend. 3. Docker context hygiene: - excludes so test files don't bloat the build context or trigger type errors in the container. All other files untouched. --- .dockerignore | 1 + docker/frontend.e2e.Dockerfile | 8 ++------ frontend/src/__tests__/ComposePage.spec.ts | 1 + frontend/src/api/client.ts | 8 ++++---- frontend/tsconfig.app.json | 3 ++- frontend/vite.config.ts | 6 ++++++ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.dockerignore b/.dockerignore index 237714d..ac0ad6d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ .git frontend/node_modules backend/build +frontend/src/__tests__ diff --git a/docker/frontend.e2e.Dockerfile b/docker/frontend.e2e.Dockerfile index 0230ab6..a9c74d9 100644 --- a/docker/frontend.e2e.Dockerfile +++ b/docker/frontend.e2e.Dockerfile @@ -1,12 +1,8 @@ -FROM node:24-alpine AS builder +FROM node:24-alpine WORKDIR /app COPY frontend/package.json frontend/package-lock.json ./ RUN npm ci COPY frontend/ . RUN npm run build - -FROM nginx:alpine -COPY --from=builder /app/dist /usr/share/nginx/html -COPY docker/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] +CMD ["npx", "vite", "preview", "--host", "0.0.0.0", "--port", "80"] diff --git a/frontend/src/__tests__/ComposePage.spec.ts b/frontend/src/__tests__/ComposePage.spec.ts index 92d09fe..4ee67e6 100644 --- a/frontend/src/__tests__/ComposePage.spec.ts +++ b/frontend/src/__tests__/ComposePage.spec.ts @@ -114,6 +114,7 @@ describe('ComposePage', () => { plate: 'ABC123', status: 'pending_payment', trackingId: null, + amountPaid: 49, createdAt: '2025-01-01T00:00:00Z', }) diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index b9c6f56..bf9197a 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -1,11 +1,11 @@ const API_BASE = import.meta.env.VITE_API_URL || '/api' export class ApiError extends Error { - constructor( - public status: number, - message: string, - ) { + status: number + + constructor(status: number, message: string) { super(message) + this.status = status this.name = 'ApiError' } } diff --git a/frontend/tsconfig.app.json b/frontend/tsconfig.app.json index 8721873..b5cd4b3 100644 --- a/frontend/tsconfig.app.json +++ b/frontend/tsconfig.app.json @@ -13,5 +13,6 @@ "@/*": ["./src/*"] } }, - "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], + "exclude": ["src/__tests__"] } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 9dca790..24f178a 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -16,6 +16,12 @@ export default defineConfig({ '/api': 'http://backend:8080', }, }, + preview: { + port: 80, + proxy: { + '/api': 'http://backend:8080', + }, + }, test: { environment: 'jsdom', setupFiles: ['src/__tests__/setup.ts'],