feat: SDLC database separation for CI/testing (#35)
Release / release (push) Failing after 9s
Build CI Images / build-ci-base (push) Failing after 20s

## Summary
- Fix `isProductionDatabase()` to allow CI database (`euchre_camp_ci`)
- Add database schema reset before CI test runs
- Create `global.teardown.ts` for cleanup (CI: full reset, dev/prod: selective cleanup)
- Add `acceptance-tests` job to PR workflow with CI database
- Create `sync-prod-to-dev.js` script for one-way prod→dev sync
- Add `just` recipes: `sync-dev`, `test-prod`, `reset-ci-db`
- Store credentials in `.credentials` (gitignored) with unique CI user

## Testing
Verified against CI database:
- Schema reset works
- Migrations apply correctly
- Test users created successfully
- 219 tests pass (slow but working)

## Next Steps
- Set `CI_DATABASE_URL` as Gitea repository variable

Reviewed-on: #35
Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #35.
This commit is contained in:
2026-05-11 06:40:05 +00:00
committed by david
parent 1489848b77
commit 861e14503b
16 changed files with 792 additions and 196 deletions
+15 -6
View File
@@ -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()
})
-1
View File
@@ -7,7 +7,6 @@
import { describe, test, expect, mock, beforeEach } from 'bun:test';
import { hasRole, canManageTournament, canCreateTournaments } from '@/lib/permissions';
import { getSession } from '@/lib/auth-simple';
import { prisma } from '@/lib/prisma';
import type { User } from '@prisma/client';
// Create mock functions at module level