49b413bf07
* feat: implement comprehensive testing infrastructure - Fix image dataURL truncation bug in security.ts with configurable size limits - Add backend integration tests (22 tests) with Vitest for API validation - Add frontend unit tests (11 tests) for JSON serialization - Implement browser-based E2E tests (8 tests) with Playwright - Create Docker setup for repeatable E2E testing environment - Add GitHub Actions CI workflow for automated testing - Update .gitignore for test artifacts and temporary files Testing Infrastructure: - Backend: Vitest + Supertest for API integration tests - Frontend: Vitest + Testing Library for component tests - E2E: Playwright with Chromium for full browser automation - CI/CD: GitHub Actions with parallel test execution Security Improvements: - Make dataURL size limit configurable (default: 10MB) - Enhanced validation for image dataURLs - Block malicious content (javascript:, script tags) All tests pass: 41 total (22 backend + 11 frontend + 8 E2E) * feat(tests): add comprehensive E2E tests for dashboard workflows and image persistence chore(env): update environment variables for consistent API URL usage fix(api): centralize API request helpers for drawing and collection management style(DrawingCard): enhance accessibility with ARIA attributes and data-testid for testing * cleanup/revise documentation * cleanup/revise documentation * Add end-to-end tests for drawing CRUD, export/import, search/sort, and theme toggle functionalities - Implemented E2E tests for drawing creation, editing, and deletion in `drawing-crud.spec.ts`. - Added tests for export and import features, including JSON and SQLite formats in `export-import.spec.ts`. - Created tests for searching and sorting drawings by name and date in `search-and-sort.spec.ts`. - Developed tests for theme toggle functionality to ensure persistence across sessions in `theme-toggle.spec.ts`. * fix: exclude test files from production build to fix Docker build * feat: implement comprehensive testing infrastructure (#19) * bump version 0.1.7 * feat: implement comprehensive testing infrastructure - Fix image dataURL truncation bug in security.ts with configurable size limits - Add backend integration tests (22 tests) with Vitest for API validation - Add frontend unit tests (11 tests) for JSON serialization - Implement browser-based E2E tests (8 tests) with Playwright - Create Docker setup for repeatable E2E testing environment - Add GitHub Actions CI workflow for automated testing - Update .gitignore for test artifacts and temporary files Testing Infrastructure: - Backend: Vitest + Supertest for API integration tests - Frontend: Vitest + Testing Library for component tests - E2E: Playwright with Chromium for full browser automation - CI/CD: GitHub Actions with parallel test execution Security Improvements: - Make dataURL size limit configurable (default: 10MB) - Enhanced validation for image dataURLs - Block malicious content (javascript:, script tags) All tests pass: 41 total (22 backend + 11 frontend + 8 E2E) * feat(tests): add comprehensive E2E tests for dashboard workflows and image persistence chore(env): update environment variables for consistent API URL usage fix(api): centralize API request helpers for drawing and collection management style(DrawingCard): enhance accessibility with ARIA attributes and data-testid for testing * Add end-to-end tests for drawing CRUD, export/import, search/sort, and theme toggle functionalities - Implemented E2E tests for drawing creation, editing, and deletion in `drawing-crud.spec.ts`. - Added tests for export and import features, including JSON and SQLite formats in `export-import.spec.ts`. - Created tests for searching and sorting drawings by name and date in `search-and-sort.spec.ts`. - Developed tests for theme toggle functionality to ensure persistence across sessions in `theme-toggle.spec.ts`. * Update backend/src/__tests__/testUtils.ts --------- Co-authored-by: Zimeng Xiong <zxzimeng@gmail.com> * version bump 0.1.8 * fix(ci): consolidate E2E server startup to prevent shell isolation issues Background processes started with & in separate GitHub Actions run steps can terminate when those steps complete because each step creates a new shell. This caused the backend and frontend servers to die before the E2E tests could run. Fixed by consolidating server startup and test execution into a single shell step with: - Proper PID tracking for cleanup - Health check loops instead of fixed sleep times - All processes run in the same shell session * fix(ci): use absolute database path for E2E tests * fix(backend): use resolved DATABASE_URL path for export/import endpoints --------- Co-authored-by: Adrian Acala <adrianacala017@gmail.com>
200 lines
4.8 KiB
YAML
200 lines
4.8 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
backend-tests:
|
|
name: Backend Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install backend dependencies
|
|
run: |
|
|
cd backend
|
|
npm ci
|
|
|
|
- name: Generate Prisma client
|
|
run: |
|
|
cd backend
|
|
npx prisma generate
|
|
|
|
- name: Run backend tests
|
|
run: |
|
|
cd backend
|
|
npm test
|
|
|
|
frontend-unit-tests:
|
|
name: Frontend Unit Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Install frontend dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Run frontend tests
|
|
run: |
|
|
cd frontend
|
|
npm test
|
|
|
|
e2e-tests:
|
|
name: E2E Browser Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Install backend dependencies
|
|
run: |
|
|
cd backend
|
|
npm ci
|
|
|
|
- name: Generate Prisma client
|
|
run: |
|
|
cd backend
|
|
npx prisma generate
|
|
|
|
- name: Setup backend database
|
|
run: |
|
|
cd backend
|
|
npx prisma db push
|
|
env:
|
|
DATABASE_URL: file:${{ github.workspace }}/backend/prisma/e2e-test.db
|
|
|
|
- name: Install frontend dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Install E2E test dependencies
|
|
run: |
|
|
cd e2e
|
|
npm ci
|
|
|
|
- name: Install Playwright browsers
|
|
run: |
|
|
cd e2e
|
|
npx playwright install chromium --with-deps
|
|
|
|
- name: Start servers and run E2E tests
|
|
run: |
|
|
# Start backend server in background
|
|
cd backend
|
|
DATABASE_URL="file:${{ github.workspace }}/backend/prisma/e2e-test.db" FRONTEND_URL="http://localhost:5173" npm run dev &
|
|
BACKEND_PID=$!
|
|
cd ..
|
|
|
|
# Wait for backend to be ready
|
|
echo "Waiting for backend server..."
|
|
for i in {1..30}; do
|
|
if curl -s http://localhost:8000/health > /dev/null; then
|
|
echo "Backend is ready!"
|
|
break
|
|
fi
|
|
echo "Attempt $i: Backend not ready yet..."
|
|
sleep 2
|
|
done
|
|
|
|
# Start frontend server in background
|
|
cd frontend
|
|
npm run dev -- --host &
|
|
FRONTEND_PID=$!
|
|
cd ..
|
|
|
|
# Wait for frontend to be ready
|
|
echo "Waiting for frontend server..."
|
|
for i in {1..30}; do
|
|
if curl -s http://localhost:5173 > /dev/null; then
|
|
echo "Frontend is ready!"
|
|
break
|
|
fi
|
|
echo "Attempt $i: Frontend not ready yet..."
|
|
sleep 2
|
|
done
|
|
|
|
# Run E2E tests
|
|
cd e2e
|
|
NO_SERVER=true CI=true npx playwright test
|
|
TEST_EXIT_CODE=$?
|
|
|
|
# Cleanup
|
|
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true
|
|
|
|
exit $TEST_EXIT_CODE
|
|
env:
|
|
DATABASE_URL: file:${{ github.workspace }}/backend/prisma/e2e-test.db
|
|
|
|
- name: Upload Playwright report
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: playwright-report
|
|
path: e2e/playwright-report/
|
|
retention-days: 7
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: test-results
|
|
path: e2e/test-results/
|
|
retention-days: 7
|
|
|
|
# Security tests for data sanitization
|
|
security-tests:
|
|
name: Security Sanitization Tests
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: backend/package-lock.json
|
|
|
|
- name: Install backend dependencies
|
|
run: |
|
|
cd backend
|
|
npm ci
|
|
|
|
- name: Generate Prisma client
|
|
run: |
|
|
cd backend
|
|
npx prisma generate
|
|
|
|
- name: Run security tests
|
|
run: |
|
|
cd backend
|
|
npx ts-node src/securityTest.ts
|