Skip to content

Commit

Permalink
Fix testHelper.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Nov 18, 2024
1 parent f5802da commit 7b89206
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
echo BC_MINIMUM_AGE=$BC_MINIMUM_AGE >> .env
echo BC_EXPO_ACCESS_TOKEN=$BC_EXPO_ACCESS_TOKEN >> .env
echo BC_STRIPE_SECRET_KEY=$BC_STRIPE_SECRET_KEY >> .env
echo BC_ADMIN_EMAIL=$BC_ADMIN_EMAIL >> .env
npm install
npm test
env:
Expand Down Expand Up @@ -92,3 +93,4 @@ jobs:
BC_MINIMUM_AGE: ${{ vars.BC_MINIMUM_AGE }}
BC_EXPO_ACCESS_TOKEN: ${{ secrets.BC_EXPO_ACCESS_TOKEN }}
BC_STRIPE_SECRET_KEY: ${{ secrets.BC_STRIPE_SECRET_KEY }}
BC_ADMIN_EMAIL: ${{ vars.BC_ADMIN_EMAIL }}
6 changes: 3 additions & 3 deletions api/tests/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const initialize = async () => {
expect(admin.id).toBeDefined()
ADMIN_USER_ID = admin.id

const adminFromEnv = env.ADMIN_EMAIL && await User.findOne({ email: env.ADMIN_EMAIL })
if (!adminFromEnv) {
const adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL })
if (env.ADMIN_EMAIL && !adminFromEnv) {
await (new User({
fullName: 'admin',
email: env.ADMIN_EMAIL,
Expand Down Expand Up @@ -82,7 +82,7 @@ export const getAdminUserId = () => ADMIN_USER_ID
export const getUserId = () => USER_ID

export const close = async () => {
const res = await User.deleteMany({ email: { $in: [ADMIN_EMAIL, USER_EMAIL] } })
const res = await User.deleteMany({ _id: { $in: [ADMIN_USER_ID, USER_ID] } })
expect(res.deletedCount).toBe(2)
await Notification.deleteMany({ user: { $in: [ADMIN_USER_ID, USER_ID] } })
await NotificationCounter.deleteMany({ user: { $in: [ADMIN_USER_ID, USER_ID] } })
Expand Down

0 comments on commit 7b89206

Please sign in to comment.