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 d63adea commit 83b3249
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 @@ -58,6 +58,7 @@ jobs:
echo MI_MINIMUM_AGE=$MI_MINIMUM_AGE >> .env
echo MI_EXPO_ACCESS_TOKEN=$MI_EXPO_ACCESS_TOKEN >> .env
echo MI_STRIPE_SECRET_KEY=$MI_STRIPE_SECRET_KEY >> .env
echo MI_ADMIN_EMAIL=$MI_ADMIN_EMAIL >> .env
npm install
npm test
env:
Expand Down Expand Up @@ -88,3 +89,4 @@ jobs:
MI_MINIMUM_AGE: ${{ vars.MI_MINIMUM_AGE }}
MI_EXPO_ACCESS_TOKEN: ${{ secrets.MI_EXPO_ACCESS_TOKEN }}
MI_STRIPE_SECRET_KEY: ${{ secrets.MI_STRIPE_SECRET_KEY }}
MI_ADMIN_EMAIL: ${{ vars.MI_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 83b3249

Please sign in to comment.