diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index d60c3fc..ab362dc 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -102,16 +102,43 @@ jobs: sleep 2 done - - name: Run frontend E2E tests + - name: Install Playwright browsers working-directory: ./frontend - run: npm test -- SearchPage.e2e.test + run: npx playwright install --with-deps + + - name: Start frontend dev server + working-directory: ./frontend + run: | + npm run dev & + echo $! > frontend.pid env: VITE_API_URL: http://localhost:8000 - - name: Stop backend server + - name: Wait for frontend to be ready + run: | + for i in {1..30}; do + if curl -f http://localhost:5173 > /dev/null 2>&1; then + echo "Frontend is ready" + break + fi + echo "Waiting for frontend... ($i/30)" + sleep 2 + done + + - name: Run frontend E2E tests + working-directory: ./frontend + run: npm run test:e2e + env: + VITE_API_URL: http://localhost:8000 + + - name: Stop servers if: always() run: | if [ -f backend.pid ]; then kill $(cat backend.pid) || true rm backend.pid + fi + if [ -f frontend.pid ]; then + kill $(cat frontend.pid) || true + rm frontend.pid fi \ No newline at end of file diff --git a/frontend/src/pages/__tests__/SearchPage.e2e.test.tsx b/frontend/src/pages/__tests__/SearchPage.integration.test.tsx similarity index 100% rename from frontend/src/pages/__tests__/SearchPage.e2e.test.tsx rename to frontend/src/pages/__tests__/SearchPage.integration.test.tsx diff --git a/frontend/vitest.integration.config.ts b/frontend/vitest.integration.config.ts new file mode 100644 index 0000000..00a08c1 --- /dev/null +++ b/frontend/vitest.integration.config.ts @@ -0,0 +1,25 @@ +import { defineConfig } from 'vitest/config' +import react from '@vitejs/plugin-react' + +export default defineConfig({ + plugins: [react()], + test: { + globals: true, + environment: 'jsdom', + setupFiles: './src/test/setup.ts', + mockReset: true, + clearMocks: true, + restoreMocks: true, + include: [ + '**/*.e2e.test.{js,jsx,ts,tsx}', + '**/*.integration.test.{js,jsx,ts,tsx}' + ], + exclude: [ + '**/node_modules/**', + '**/dist/**', + '**/cypress/**', + '**/.{idea,git,cache,output,temp}/**', + '**/e2e/**' + ], + }, +}) \ No newline at end of file