-
-
Notifications
You must be signed in to change notification settings - Fork 6
Add firebase emulator, Add registration script, Add signup spec #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e04656c
add firebase emulator, add registration script, add signup spec
n3c777 201f63b
Upgrade firebase emulator and make it pass the E2E tests
MartinBraquet eb50437
Merge branch 'main' into fork/n3c777/e2e-signup
MartinBraquet 874b6ff
Merge branch 'main' into e2e-signup
n3c777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,42 @@ | ||
| #!/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")"/.. | ||
|
|
||
| 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} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| export const config = { | ||
| BASE_URL: 'http://localhost:3000', | ||
|
|
||
| USERS: { | ||
| DEV_1: { | ||
| EMAIL: '[email protected]', | ||
| PASSWORD: 'dev_1Password', | ||
| }, | ||
| DEV_2: { | ||
| EMAIL: '[email protected]', | ||
| PASSWORD: 'dev_2Password', | ||
| }, | ||
| SPEC: { | ||
| EMAIL: '[email protected]', | ||
| PASSWORD: 'compassConnections1!', | ||
| }, | ||
| SPEC_GOOGLE: { | ||
| EMAIL: '[email protected]', | ||
| //unsure if gmail password should be public | ||
| PASSWORD: '', | ||
| } | ||
| }, | ||
| }; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { test as base } from '@playwright/test'; | ||
| import axios from 'axios'; | ||
| import { config } from '../SPEC_CONFIG'; | ||
|
|
||
| const baseUrl = 'http://localhost:9099/identitytoolkit.googleapis.com/v1'; | ||
|
|
||
| async function deleteUser(email: string, password: string) { | ||
| try { | ||
| const login = await axios.post( | ||
| `${baseUrl}/accounts:signInWithPassword?key=fake-api-key`, | ||
| { | ||
| email, | ||
| password, | ||
| returnSecureToken: true | ||
| } | ||
| ); | ||
|
|
||
| await axios.post( | ||
| `${baseUrl}/accounts:delete?key=fake-api-key`, | ||
| { idToken: login.data.idToken } | ||
| ); | ||
| } catch (err: any) { | ||
| console.log(err); | ||
| } | ||
| } | ||
|
|
||
| type CleanupFixtures = { | ||
| cleanupUsers: void; | ||
| }; | ||
|
|
||
| export const test = base.extend<CleanupFixtures>({ | ||
| cleanupUsers: [ | ||
| async ({}, use) => { | ||
| // Run all tests first | ||
| await use(); | ||
|
|
||
| //then delete users | ||
| await deleteUser(config.USERS.SPEC.EMAIL, config.USERS.SPEC.PASSWORD); | ||
| }, | ||
| { auto: true }, | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 18 additions & 6 deletions
24
tests/e2e/web/pages/signInPage.ts → tests/e2e/web/pages/AuthPage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may also have been one key missing line.