Automated E2E API tests for rootcodelabs/skapp-pm backend.
- A PR is opened in
rootcodelabs/skapp-pmtouchingbackend/**files - The
e2e-trigger.ymlworkflow fires arepository_dispatchevent to this repo - This repo's
generate-and-test.ymlworkflow:- Checks out the source at the PR's commit SHA
- Generates Playwright API tests via GitHub Models API (Copilot)
- Spins up Postgres + Redis + Backend via Docker Compose
- Runs the generated tests against the live backend
- Opens a PR in this repo with the generated tests and ✅/❌ results
- Posts a status comment on the source PR
- Node.js 22+
- Docker & Docker Compose
npm install# Start the backend stack (Postgres + Redis + Backend)
npm run docker:up
# Wait for backend to be ready, then run tests
npx playwright test
# Tear down
npm run docker:downAdd test files to tests/api/. Use the existing tests and tests/helpers/auth.ts as reference:
import { test, expect } from '@playwright/test';
import { createTestToken } from '../helpers/auth';
test.describe('My API tests', () => {
test('query returns data', async ({ request }) => {
const token = createTestToken();
const response = await request.post('/graphql', {
headers: { Authorization: token },
data: {
query: `query { myQuery { id name } }`,
},
});
expect(response.ok()).toBeTruthy();
const body = await response.json();
expect(body.data.myQuery).toBeDefined();
});
});| Secret | Where | Description |
|---|---|---|
SOURCE_REPO_TOKEN |
This repo | PAT with repo scope on rootcodelabs/skapp-pm (for checkout + PR comments) |
NPM_READ_TOKEN |
This repo | Token to read @rootcodelabs packages from GitHub Packages |
COPILOT_API_TOKEN |
This repo | (Optional) Copilot API token — falls back to GitHub Models API |
E2E_REPO_TOKEN |
rootcodelabs/skapp-pm |
PAT with repo scope on this repo (for repository_dispatch) |
rootcodelabs/skapp-pm thusala/skapp-pm-e2e (this repo)
┌─────────────────────┐ dispatch event ┌──────────────────────────┐
│ e2e-trigger.yml │ ───────────────▶ │ generate-and-test.yml │
│ (on: pull_request) │ payload: sha, │ (on: repository_dispatch)│
│ │ branch, files │ │
│ backend/ │ │ docker/ (compose stack) │
│ graphql/ │ │ tests/api/ (Playwright) │
└─────────────────────┘ └──────────────────────────┘