kaboot/server/tests
Joey Yakimowich-Payne 2e12edc249
Add Stripe payment integration for AI subscriptions
Implement subscription-based AI access with 250 generations/month at $5/month or $50/year.

Changes:
- Backend: Stripe service, payment routes, webhook handlers, generation tracking
- Frontend: Upgrade page with pricing, payment success/cancel pages, UI prompts
- Database: Add subscription fields to users, payments table, migrations
- Config: Stripe env vars to .env.example, docker-compose.prod.yml, PRODUCTION.md
- Tests: Payment route tests, component tests, subscription hook tests

Users without AI access see upgrade prompts; subscribers see remaining generation count.
2026-01-21 16:11:03 -07:00
..
api.test.ts Add sharing 2026-01-16 08:49:21 -07:00
get-token.ts Fix tests 2026-01-13 15:27:46 -07:00
payments.test.ts Add Stripe payment integration for AI subscriptions 2026-01-21 16:11:03 -07:00
README.md Phase 2 + 3 complete 2026-01-13 15:20:46 -07:00
run-tests.ts Fix tests 2026-01-13 15:27:46 -07:00

Kaboot Backend API Tests

Getting a Test Token

Since Authentik uses OAuth2 flows that require browser interaction, you need to obtain a token manually.

Method 1: Browser DevTools (Easiest)

  1. Start the Kaboot frontend: npm run dev (in root directory)
  2. Open http://localhost:5173
  3. Click "Sign In" and log in with Authentik
  4. Open browser DevTools (F12)
  5. Go to Application > Local Storage > http://localhost:5173
  6. Find the key starting with oidc.user:
  7. Click on it and find "access_token" in the JSON value
  8. Copy the token value (without quotes)

Method 2: Service Account

  1. Go to Authentik Admin: http://localhost:9000/if/admin/
  2. Navigate to Directory > Users
  3. Click Create Service Account
  4. Enter a name (e.g., kaboot-test-service)
  5. Note the generated username and token
  6. Use these credentials:
    TEST_USERNAME=<service-account-username> \
    TEST_PASSWORD=<generated-token> \
    npm run test:get-token
    

Running Tests

cd server
npm install

# Set the token you obtained
export TEST_TOKEN="your-access-token-here"

# Run tests
npm run test

Test Coverage

The test suite covers:

  • Health Check: Basic server availability
  • Authentication: 401 without token, 401 with invalid token
  • User API: GET /api/users/me
  • Quiz CRUD:
    • GET /api/quizzes (list)
    • POST /api/quizzes (create)
    • GET /api/quizzes/:id (read)
    • PUT /api/quizzes/:id (update)
    • DELETE /api/quizzes/:id (delete)

Environment Variables

Variable Default Description
API_URL http://localhost:3001 Backend API URL
TEST_TOKEN (required) JWT access token from Authentik
AUTHENTIK_URL http://localhost:9000 Authentik server URL
CLIENT_ID kaboot-spa OAuth2 client ID
TEST_USERNAME kaboottest Username for token request
TEST_PASSWORD kaboottest Password for token request