diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74d099feb..93e8eafe9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: @@ -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 }} diff --git a/api/tests/testHelper.ts b/api/tests/testHelper.ts index 40ed50b11..5793a5158 100644 --- a/api/tests/testHelper.ts +++ b/api/tests/testHelper.ts @@ -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, @@ -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] } })