Skip to content

Commit

Permalink
Update testHelper.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Nov 18, 2024
1 parent ca70bcb commit 21efaa9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/tests/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ export const initialize = async () => {
if (env.ADMIN_EMAIL) {
let adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL, type: bookcarsTypes.UserType.Admin })
if (!adminFromEnv) {
const _admin = new User({
fullName: 'admin',
email: env.ADMIN_EMAIL,
language: LANGUAGE,
password: passwordHash,
type: bookcarsTypes.UserType.Admin,
})
//
// This check is necessary to avoid getting an error creating the same env admin multiple times when
// test suites are run in parallel.
//
await delay(2000)
adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL, type: bookcarsTypes.UserType.Admin })
await delay(1000)
adminFromEnv = await User.findOne({ email: env.ADMIN_EMAIL })
if (!adminFromEnv) {
const _admin = new User({
fullName: 'admin',
email: env.ADMIN_EMAIL,
language: LANGUAGE,
password: passwordHash,
type: bookcarsTypes.UserType.Admin,
})
await _admin.save()
expect(_admin.id).toBeTruthy()
}
Expand Down

0 comments on commit 21efaa9

Please sign in to comment.