mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-24 02:46:11 -05:00
Add pretty formatting (#29)
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
This commit is contained in:
@@ -10,7 +10,7 @@ source web/.env
|
||||
|
||||
npx cap sync android
|
||||
|
||||
# To generate icons
|
||||
# To generate icons
|
||||
# npx capacitor-assets generate --android
|
||||
|
||||
# Then go to android studio, build, generate signed APK in android/app/release, adb install -r app-release.apk
|
||||
|
||||
@@ -6,14 +6,14 @@ services:
|
||||
POSTGRES_USER: test_user
|
||||
POSTGRES_PASSWORD: test_password
|
||||
ports:
|
||||
- "5433:5432"
|
||||
- '5433:5432'
|
||||
volumes:
|
||||
- postgres-test-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: [ "CMD-SHELL", "pg_isready -U test_user -d test_db" ]
|
||||
test: ['CMD-SHELL', 'pg_isready -U test_user -d test_db']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
postgres-test-data:
|
||||
postgres-test-data:
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
// TODO: add test data to firebase emulator as well (see example below, but user IDs from supabase and firebase need to the same)
|
||||
|
||||
import {createSupabaseDirectClient} from "shared/lib/supabase/init";
|
||||
import UserAccountInformation from "../tests/e2e/backend/utils/userInformation";
|
||||
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';
|
||||
|
||||
try {
|
||||
const response = await axios.post(`${base}/accounts:signUp?key=fake-api-key`, {
|
||||
email: email,
|
||||
password: password,
|
||||
returnSecureToken: true
|
||||
})
|
||||
const userId = response.data.localId
|
||||
console.log('User created in Firebase Auth:', email, userId)
|
||||
return userId
|
||||
} 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 it with:\n yarn test:e2e:services\n')
|
||||
console.log(err);
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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},
|
||||
{count: 1, profileType: 'medium' as ProfileType},
|
||||
{count: 1, profileType: 'full' as ProfileType},
|
||||
]
|
||||
|
||||
for (const {count, profileType} of seedConfig) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
const userInfo = new UserAccountInformation()
|
||||
if (i == 0 && profileType === 'full') {
|
||||
// Seed the first profile with deterministic data for the e2e tests
|
||||
userInfo.name = 'Franklin Buckridge'
|
||||
userInfo.email = config.USERS.DEV_1.EMAIL
|
||||
userInfo.password = config.USERS.DEV_1.PASSWORD
|
||||
}
|
||||
userInfo.user_id = await createAuth(userInfo.email, userInfo.password)
|
||||
if (userInfo.user_id) {
|
||||
console.log('User created in Supabase:', userInfo)
|
||||
await seedDatabase(pg, userInfo, profileType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
})()
|
||||
@@ -13,6 +13,8 @@ export NEXT_PUBLIC_SUPABASE_ANON_KEY=$(supabase status --output json | jq -r '.A
|
||||
export DATABASE_URL=$(supabase status --output json | jq -r '.DB_URL')
|
||||
|
||||
# Build backend (required?)
|
||||
./scripts/build_api.sh
|
||||
#./scripts/build_api.sh
|
||||
|
||||
npx tsx scripts/seed-test-data.ts
|
||||
cd tests/e2e/utils
|
||||
|
||||
npx tsx seed-test-data.ts
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { config } from '../tests/e2e/web/SPEC_CONFIG.js';
|
||||
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';
|
||||
@@ -7,10 +7,9 @@ async function createAuth() {
|
||||
await axios.post(`${config.FIREBASE_URL.BASE}${config.FIREBASE_URL.SIGNUP}`, {
|
||||
email: config.USERS.DEV_1.EMAIL,
|
||||
password: config.USERS.DEV_1.PASSWORD,
|
||||
returnSecureToken: true
|
||||
});
|
||||
returnSecureToken: true,
|
||||
})
|
||||
|
||||
console.log('Auth created', config.USERS.DEV_1.EMAIL)
|
||||
|
||||
}
|
||||
createAuth();
|
||||
createAuth()
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
//Run with:
|
||||
// export ENVIRONMENT=DEV && ./scripts/build_api.sh && npx tsx ./scripts/userCreation.ts
|
||||
|
||||
import {createSupabaseDirectClient} from "shared/lib/supabase/init";
|
||||
import UserAccountInformation from "../tests/e2e/backend/utils/userInformation";
|
||||
import { seedDatabase } from "../tests/e2e/utils/seedDatabase";
|
||||
|
||||
type ProfileType = 'basic' | 'medium' | 'full'
|
||||
|
||||
|
||||
(async () => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
|
||||
//Edit the count seedConfig to specify the amount of each profiles to create
|
||||
const seedConfig = [
|
||||
{ count: 1, profileType: 'basic' as ProfileType },
|
||||
{ count: 1, profileType: 'medium' as ProfileType },
|
||||
{ count: 1, profileType: 'full' as ProfileType },
|
||||
]
|
||||
|
||||
for (const {count, profileType } of seedConfig) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
const userInfo = new UserAccountInformation()
|
||||
if (i == 0) {
|
||||
// Seed the first profile with deterministic data for the e2e tests
|
||||
userInfo.name = 'Franklin Buckridge'
|
||||
}
|
||||
await seedDatabase(pg, userInfo, profileType)
|
||||
}
|
||||
}
|
||||
process.exit(0)
|
||||
})()
|
||||
Reference in New Issue
Block a user