mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-24 17:01:09 -04:00
Fix
This commit is contained in:
@@ -563,15 +563,14 @@ yarn test:e2e:dev --debug tests/e2e/web/specs/signUp.spec.ts
|
||||
### 1. Start services once
|
||||
|
||||
```bash
|
||||
yarn e2e:services
|
||||
yarn test:e2e:services
|
||||
```
|
||||
|
||||
This starts Firebase emulators, the backend API, and Next.js in one terminal.
|
||||
In a separate terminal, start Supabase:
|
||||
|
||||
```bash
|
||||
npx supabase start
|
||||
npx supabase db reset # Apply migrations + seed
|
||||
yarn test:db:reset # Restart and apply migrations + seed
|
||||
```
|
||||
|
||||
### 2. Open Playwright UI
|
||||
@@ -598,7 +597,7 @@ No restart needed for test file changes.
|
||||
If your tests leave dirty state or you need a fresh DB:
|
||||
|
||||
```bash
|
||||
npx supabase db reset # Drops and re-applies all migrations + seed
|
||||
yarn test:db:reset # Drops and re-applies all migrations + seed
|
||||
```
|
||||
|
||||
---
|
||||
@@ -610,8 +609,8 @@ npx supabase db reset # Drops and re-applies all migrations + seed
|
||||
| Edit test file | Just re-run in Playwright UI |
|
||||
| Edit app code (Next.js) | Next.js hot reloads automatically |
|
||||
| Edit API code | API dev server hot reloads automatically |
|
||||
| Database schema change | `npx supabase db reset` |
|
||||
| Seed data change | `npx supabase db reset` |
|
||||
| Database schema change | `yarn test:db:reset` |
|
||||
| Seed data change | `yarn test:db:reset` |
|
||||
| Change `playwright.config.ts` | Restart Playwright UI |
|
||||
| Change env variables | Restart affected service |
|
||||
|
||||
@@ -709,7 +708,7 @@ test.describe('Authentication', () => {
|
||||
|
||||
### Test accounts
|
||||
|
||||
These are seeded automatically by `npx supabase db reset`:
|
||||
These are seeded automatically by `yarn test:db:seed`:
|
||||
|
||||
| Email | Password |
|
||||
|---------------------|---------------|
|
||||
@@ -756,7 +755,7 @@ curl http://localhost:3000 # Next.js
|
||||
### Database is in a bad state
|
||||
|
||||
```bash
|
||||
npx supabase db reset # Full reset - drops everything and reseeds
|
||||
yarn test:db:reset # Full reset - drops everything and reseeds
|
||||
```
|
||||
|
||||
### Firebase auth warning in CI
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
"test:e2e:dev": "./scripts/e2e-dev.sh",
|
||||
"test:e2e:ui": "./scripts/e2e.sh --ui",
|
||||
"test:e2e:debug": "./scripts/e2e.sh --debug",
|
||||
"test:e2e:services": "concurrently --names 'firebase,api,web' 'yarn emulate' 'yarn --cwd=backend/api dev' 'yarn --cwd=web dev'",
|
||||
"test:db:reset": "npx supabase start && ./scripts/combine-migrations.sh && npx supabase db reset",
|
||||
"test:e2e:services": "./scripts/e2e_services.sh",
|
||||
"test:db:reset": "npx supabase start && ./scripts/combine-migrations.sh && npx supabase db reset && yarn test:db:seed",
|
||||
"test:db:reset-postgres": "docker compose -f scripts/docker-compose.test.yml down -v && docker compose -f scripts/docker-compose.test.yml up -d",
|
||||
"test:db:migrate": "./scripts/test_db_migration.sh",
|
||||
"test:db:seed": "./scripts/seed.sh",
|
||||
"playwright": "playwright test",
|
||||
"playwright:ui": "playwright test --ui",
|
||||
"playwright:debug": "playwright test --debug",
|
||||
|
||||
@@ -38,7 +38,7 @@ check_services() {
|
||||
|
||||
if [ $missing -eq 1 ]; then
|
||||
echo ""
|
||||
echo "Start everything with: yarn e2e:services"
|
||||
echo "Start everything with: yarn test:e2e:services"
|
||||
echo "Or start full clean run: yarn test:e2e"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -59,8 +59,8 @@ print_status "Killing any stale processes..."
|
||||
supabase stop --no-backup 2>/dev/null || true
|
||||
sleep 2 # Give ports time to free up
|
||||
|
||||
# Start Supabase (includes Postgres, Auth, Storage, etc.) and Apply migrations
|
||||
yarn test:db:reset
|
||||
# Build backend (required?)
|
||||
./scripts/build_api.sh
|
||||
|
||||
# Get connection details
|
||||
export NEXT_PUBLIC_SUPABASE_URL=$(supabase status --output json | jq -r '.API_URL')
|
||||
@@ -87,14 +87,8 @@ npx wait-on \
|
||||
http-get://127.0.0.1:9099 \
|
||||
--timeout 30000
|
||||
|
||||
# Build backend (required?)
|
||||
./scripts/build_api.sh
|
||||
|
||||
# Seed test data if script exists
|
||||
if [ -f "scripts/seed-test-data.ts" ]; then
|
||||
print_status "Seeding test data..."
|
||||
npx tsx scripts/seed-test-data.ts
|
||||
fi
|
||||
# Start Supabase (includes Postgres, Auth, Storage, etc.) and Apply migrations and seed (needs firebase emulator running)
|
||||
yarn test:db:reset
|
||||
|
||||
# Start backend API
|
||||
print_status "Starting backend API..."
|
||||
|
||||
18
scripts/e2e_services.sh
Executable file
18
scripts/e2e_services.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Change to project root
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
export $(cat .env.test | grep -v '^#' | xargs)
|
||||
|
||||
# Get connection details
|
||||
export NEXT_PUBLIC_SUPABASE_URL=$(supabase status --output json | jq -r '.API_URL')
|
||||
export NEXT_PUBLIC_SUPABASE_ANON_KEY=$(supabase status --output json | jq -r '.ANON_KEY')
|
||||
export DATABASE_URL=$(supabase status --output json | jq -r '.DB_URL')
|
||||
|
||||
# Build backend (required?)
|
||||
./scripts/build_api.sh
|
||||
|
||||
concurrently --names 'firebase,api,web' 'yarn emulate' 'yarn --cwd=backend/api dev' 'yarn --cwd=web dev'
|
||||
@@ -6,15 +6,25 @@ import {seedDatabase} from "../tests/e2e/utils/seedDatabase";
|
||||
|
||||
import axios from 'axios';
|
||||
import {config} from '../tests/e2e/web/SPEC_CONFIG.js';
|
||||
import {tryCatch} from "common/lib/util/try-catch";
|
||||
import {insert} from "shared/lib/supabase/utils";
|
||||
|
||||
async function createAuth(email: string, password: string) {
|
||||
const base = 'http://localhost:9099/identitytoolkit.googleapis.com/v1';
|
||||
|
||||
await axios.post(`${base}/accounts:signUp?key=fake-api-key`, {
|
||||
email: email,
|
||||
password: password,
|
||||
returnSecureToken: true
|
||||
});
|
||||
try {
|
||||
await axios.post(`${base}/accounts:signUp?key=fake-api-key`, {
|
||||
email: email,
|
||||
password: password,
|
||||
returnSecureToken: true
|
||||
})
|
||||
} catch (err: any) {
|
||||
if (err.response?.status === 400 || err.response?.data?.error?.message?.includes('EMAIL_EXISTS')) {
|
||||
return;
|
||||
}
|
||||
if (err.code === 'ECONNREFUSED') throw Error('Firebase emulator not running. Start with:\n yarn test:e2e:services\n')
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
console.log('Auth created', config.USERS.DEV_1.EMAIL)
|
||||
|
||||
@@ -27,12 +37,28 @@ async function createAuth(email: string, password: string) {
|
||||
// Can remove this later once we update tests/e2e/web/fixtures/signInFixture.ts
|
||||
createAuth(config.USERS.DEV_1.EMAIL, config.USERS.DEV_1.PASSWORD)
|
||||
|
||||
async function seedCompatibilityPrompts(pg: any, userId: string = null) {
|
||||
// Need some prompts to prevent the onboarding from stopping once it reaches them (just after profile creation)
|
||||
const question = "What is your favorite color?"
|
||||
const multiple_choice_options = {"Blue": 0, "Green": 1, "Red": 2}
|
||||
const {data, error} = await tryCatch(
|
||||
insert(pg, 'compatibility_prompts', {
|
||||
creator_id: userId,
|
||||
question,
|
||||
answer_type: 'compatibility_multiple_choice',
|
||||
multiple_choice_options,
|
||||
})
|
||||
)
|
||||
console.log('Compatibility prompts created', {data, error})
|
||||
}
|
||||
|
||||
type ProfileType = 'basic' | 'medium' | 'full'
|
||||
|
||||
(async () => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
|
||||
await seedCompatibilityPrompts(pg)
|
||||
|
||||
//Edit the count seedConfig to specify the amount of each profiles to create
|
||||
const seedConfig = [
|
||||
{count: 1, profileType: 'basic' as ProfileType},
|
||||
@@ -52,5 +78,6 @@ type ProfileType = 'basic' | 'medium' | 'full'
|
||||
await seedDatabase(pg, userInfo, profileType)
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
})()
|
||||
18
scripts/seed.sh
Executable file
18
scripts/seed.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Change to project root
|
||||
cd "$(dirname "$0")"/..
|
||||
|
||||
export $(cat .env.test | grep -v '^#' | xargs)
|
||||
|
||||
# Get connection details
|
||||
export NEXT_PUBLIC_SUPABASE_URL=$(supabase status --output json | jq -r '.API_URL')
|
||||
export NEXT_PUBLIC_SUPABASE_ANON_KEY=$(supabase status --output json | jq -r '.ANON_KEY')
|
||||
export DATABASE_URL=$(supabase status --output json | jq -r '.DB_URL')
|
||||
|
||||
# Build backend (required?)
|
||||
./scripts/build_api.sh
|
||||
|
||||
npx tsx scripts/seed-test-data.ts
|
||||
Reference in New Issue
Block a user