Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ jobs:
run: npx playwright install-deps chromium
- run: node test/smoke-test.js

api:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v5
with:
node-version: 24
- run: npm install
- name: API tests (no Firestore)
run: bash scripts/test-api-local.sh

codeql:
runs-on: ubuntu-latest
steps:
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
firestore:
image: google/cloud-sdk:slim
command: >
gcloud emulators firestore start
--host-port=0.0.0.0:8686
--project=casecomp-test
ports:
- "8686:8686"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8686/"]
interval: 2s
timeout: 5s
retries: 10
11 changes: 11 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"emulators": {
"firestore": {
"port": 8686,
"host": "localhost"
},
"ui": {
"enabled": false
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:unit": "node test/unit-test.js",
"test:api": "node test/api-test.js",
"test:live": "API_URL=https://api.casecomp.xyz node test/api-test.js",
"test:api:local": "bash scripts/test-api-local.sh",
"test:smoke": "node test/smoke-test.js",
"scan": "node scan.js",
"psa": "node scripts/psa-report.js",
Expand Down
35 changes: 35 additions & 0 deletions scripts/test-api-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e

PORT=3033

cleanup() {
echo "Cleaning up..."
[ -n "$SERVER_PID" ] && kill $SERVER_PID 2>/dev/null
wait $SERVER_PID 2>/dev/null
echo "Done."
}
trap cleanup EXIT

echo "Starting API server on :$PORT..."
API_PORT=$PORT node api.js 2>/dev/null &
SERVER_PID=$!
SERVER_PID=$!

echo "Waiting for server..."
for i in $(seq 1 15); do
if curl -sf "http://localhost:$PORT/api/health" >/dev/null 2>&1; then
echo "Server ready."
break
fi
if [ "$i" -eq 15 ]; then
echo "Server failed to start"
exit 1
fi
sleep 1
done

# Run tests
echo ""
echo "Running API tests..."
API_URL="http://localhost:$PORT" node test/api-test.js
Loading
Loading