From 413ebaeaeeeb4ae5609b8d589b0129e57a376926 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Sun, 3 May 2026 17:35:39 -0700 Subject: [PATCH] fix: correct CI test configuration and Navigation test provider - Wrap Navigation tests in RoleSwitcherProvider to fix 6 test failures - Use remote CI server URL (euchre-ci.notsosm.art) for acceptance tests in CI - Fix DATABASE_URL reference from vars to secrets in PR workflow --- .gitea/workflows/pr.yml | 2 +- playwright.config.ts | 2 +- src/__tests__/Navigation.test.tsx | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index ba86eaf..9cde7aa 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -46,7 +46,7 @@ jobs: DATABASE_URL: postgresql://user:pass@localhost:5432/dummy - name: Run acceptance tests - run: DATABASE_URL="${{ vars.CI_DATABASE_URL }}" bun test:acceptance + run: DATABASE_URL="${{ secrets.CI_DATABASE_URL }}" bun test:acceptance env: CI: true diff --git a/playwright.config.ts b/playwright.config.ts index 1e2df7e..2ae17d1 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -21,7 +21,7 @@ export default defineConfig({ globalTeardown: require.resolve('./e2e/global.teardown'), // Use base URL for relative navigation use: { - baseURL: 'http://localhost:3000', + baseURL: process.env.CI ? 'https://euchre-ci.notsosm.art' : 'http://localhost:3000', // Collect trace when retrying the failed test. trace: 'on-first-retry', // Capture screenshot only on failure diff --git a/src/__tests__/Navigation.test.tsx b/src/__tests__/Navigation.test.tsx index 70cac87..220bcbd 100644 --- a/src/__tests__/Navigation.test.tsx +++ b/src/__tests__/Navigation.test.tsx @@ -8,6 +8,7 @@ import { describe, it, expect, mock, beforeEach, afterEach } from 'bun:test' import { render, screen, waitFor } from '@testing-library/react' import Navigation from '@/components/Navigation' +import { RoleSwitcherProvider } from '@/components/RoleSwitcher' // Mock next/link mock.module('next/link', () => ({ @@ -31,6 +32,14 @@ mock.module('@/lib/auth-client', () => ({ // Mock fetch for role API call global.fetch = mock(async () => new Response()) as any +function renderNavigation() { + return render( + + + + ) +} + import { useSession as useSessionOriginal } from '@/components/SessionProvider' const useSession = useSessionOriginal as any @@ -61,7 +70,7 @@ describe('Epic 1: Navigation Component', () => { refreshSession: mock(() => {}), }) - render() + renderNavigation() expect(screen.getByText('EuchreCamp')).toBeInTheDocument() expect(screen.getByText('Rankings')).toBeInTheDocument() @@ -84,7 +93,7 @@ describe('Epic 1: Navigation Component', () => { refreshSession: mock(() => {}), }) - render() + renderNavigation() await waitFor(() => { expect(screen.getByText('Test User')).toBeInTheDocument() @@ -109,7 +118,7 @@ describe('Epic 1: Navigation Component', () => { refreshSession: mock(() => {}), }) - render() + renderNavigation() await waitFor(() => { expect(screen.getByText('Tournaments')).toBeInTheDocument() @@ -142,7 +151,7 @@ describe('Epic 1: Navigation Component', () => { return new Response(JSON.stringify({}), { status: 200 }) }) - render() + renderNavigation() await waitFor(() => { expect(screen.getByText('Admin')).toBeInTheDocument() @@ -177,7 +186,7 @@ describe('Epic 1: Navigation Component', () => { } as Response }) - render() + renderNavigation() await waitFor(() => { expect(screen.getByText('Tournaments')).toBeInTheDocument() @@ -192,7 +201,7 @@ describe('Epic 1: Navigation Component', () => { refreshSession: mock(() => {}), }) - render() + renderNavigation() expect(screen.getByText('Loading...')).toBeInTheDocument() })