Add firebase emulator, Add registration script, Add signup spec (#22)

* add firebase emulator, add registration script, add signup spec

* Upgrade firebase emulator and make it pass the E2E tests

---------

Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
This commit is contained in:
Nicholas Chamberlain
2025-12-06 14:43:46 -08:00
committed by GitHub
parent 348a557f5c
commit ef7665c7da
18 changed files with 2859 additions and 140 deletions

View File

@@ -1,6 +1,21 @@
#!/bin/bash
# set -e
set -euo pipefail
# Function to clean up background processes
cleanup() {
echo "Stopping background processes..."
for pid in "${PIDS[@]:-}"; do
if kill -0 "$pid" 2>/dev/null; then
kill "$pid" || true
wait "$pid" 2>/dev/null || true
echo "Killed PID $pid"
fi
done
}
# Trap EXIT, INT, TERM to run cleanup automatically
trap cleanup EXIT INT TERM
cd "$(dirname "$0")"/..
@@ -8,15 +23,20 @@ npx playwright install chromium
export NEXT_PUBLIC_API_URL=localhost:8088
export NEXT_PUBLIC_FIREBASE_ENV=DEV
export NEXT_PUBLIC_FIREBASE_EMULATOR=true
export FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099
export FIREBASE_STORAGE_EMULATOR_HOST=127.0.0.1:9199
# Start servers in background and store their PIDs
PIDS=()
npx nyc --reporter=lcov yarn --cwd=web serve & PIDS+=($!)
npx nyc --reporter=lcov yarn --cwd=backend/api dev & PIDS+=($!)
yarn emulate & PIDS+=($!)
npx nyc --reporter=lcov yarn --cwd=web serve &
npx nyc --reporter=lcov yarn --cwd=backend/api dev &
npx wait-on http://localhost:3000
npx playwright test tests/e2e --headed
SERVER_PID=$(fuser -k 3000/tcp)
echo $SERVER_PID
kill $SERVER_PID
SERVER_PID=$(fuser -k 8088/tcp)
echo $SERVER_PID
kill $SERVER_PID
npx tsx scripts/setup-auth.ts
npx playwright test tests/e2e
exit ${TEST_FAILED:-0}

16
scripts/setup-auth.ts Normal file
View File

@@ -0,0 +1,16 @@
import axios from 'axios';
import { config } from '../tests/e2e/web/SPEC_CONFIG.js';
async function createAuth() {
const base = 'http://localhost:9099/identitytoolkit.googleapis.com/v1';
await axios.post(`${base}/accounts:signUp?key=fake-api-key`, {
email: config.USERS.DEV_1.EMAIL,
password: config.USERS.DEV_1.PASSWORD,
returnSecureToken: true
});
console.log('Auth created', config.USERS.DEV_1.EMAIL)
}
createAuth();