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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
<RoleSwitcherProvider>
|
||||
<Navigation />
|
||||
</RoleSwitcherProvider>
|
||||
)
|
||||
}
|
||||
|
||||
import { useSession as useSessionOriginal } from '@/components/SessionProvider'
|
||||
const useSession = useSessionOriginal as any
|
||||
|
||||
@@ -61,7 +70,7 @@ describe('Epic 1: Navigation Component', () => {
|
||||
refreshSession: mock(() => {}),
|
||||
})
|
||||
|
||||
render(<Navigation />)
|
||||
renderNavigation()
|
||||
|
||||
expect(screen.getByText('EuchreCamp')).toBeInTheDocument()
|
||||
expect(screen.getByText('Rankings')).toBeInTheDocument()
|
||||
@@ -84,7 +93,7 @@ describe('Epic 1: Navigation Component', () => {
|
||||
refreshSession: mock(() => {}),
|
||||
})
|
||||
|
||||
render(<Navigation />)
|
||||
renderNavigation()
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Test User')).toBeInTheDocument()
|
||||
@@ -109,7 +118,7 @@ describe('Epic 1: Navigation Component', () => {
|
||||
refreshSession: mock(() => {}),
|
||||
})
|
||||
|
||||
render(<Navigation />)
|
||||
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(<Navigation />)
|
||||
renderNavigation()
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Admin')).toBeInTheDocument()
|
||||
@@ -177,7 +186,7 @@ describe('Epic 1: Navigation Component', () => {
|
||||
} as Response
|
||||
})
|
||||
|
||||
render(<Navigation />)
|
||||
renderNavigation()
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Tournaments')).toBeInTheDocument()
|
||||
@@ -192,7 +201,7 @@ describe('Epic 1: Navigation Component', () => {
|
||||
refreshSession: mock(() => {}),
|
||||
})
|
||||
|
||||
render(<Navigation />)
|
||||
renderNavigation()
|
||||
|
||||
expect(screen.getByText('Loading...')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user