Fix concurrency issue in TeamService.test.ts
This commit is contained in:
parent
d532ac82f0
commit
1fde923dbf
@ -78,7 +78,7 @@ describe('team', () => {
|
||||
const client = getClient()
|
||||
const team = await client.create({name: 'test'})
|
||||
const teamId = team.id
|
||||
const {userId} = await test.registerAccount('test2@user.com')
|
||||
const {userId} = await test.registerAccount(test.createTestUsername(2))
|
||||
await client.addUser({userId, teamId, roleId: 1})
|
||||
})
|
||||
})
|
||||
@ -88,7 +88,7 @@ describe('team', () => {
|
||||
const client = getClient()
|
||||
const team = await client.create({name: 'test'})
|
||||
const teamId = team.id
|
||||
const {userId} = await test.registerAccount('test2@user.com')
|
||||
const {userId} = await test.registerAccount(test.createTestUsername(2))
|
||||
await client.addUser({userId, teamId, roleId: 1})
|
||||
await client.removeUser({userId, teamId, roleId: 1})
|
||||
})
|
||||
@ -99,7 +99,7 @@ describe('team', () => {
|
||||
const client = getClient()
|
||||
const team = await client.create({name: 'test'})
|
||||
const teamId = team.id
|
||||
const {userId} = await test.registerAccount('test2@user.com')
|
||||
const {userId} = await test.registerAccount(test.createTestUsername(2))
|
||||
await client.addUser({userId, teamId, roleId: 1})
|
||||
const {usersInTeam} = await client.findUsers(teamId)
|
||||
expect(usersInTeam.length).toBe(2)
|
||||
|
||||
@ -16,7 +16,7 @@ import {Server} from 'http'
|
||||
import { IAppServer } from '../application/IAppServer'
|
||||
|
||||
export class TestUtils<T extends IRoutes> {
|
||||
readonly username = `test${process.env.JEST_WORKER_ID}@user.com`
|
||||
readonly username = this.createTestUsername()
|
||||
readonly password = 'Password10'
|
||||
|
||||
readonly app: IAppServer
|
||||
@ -29,6 +29,10 @@ export class TestUtils<T extends IRoutes> {
|
||||
this.transactionManager = this.bootstrap.database.transactionManager
|
||||
}
|
||||
|
||||
createTestUsername(id = 1) {
|
||||
return `test${process.env.JEST_WORKER_ID}_${id}@user.com`
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up beforeEach and afterEach cases for jest tests. Helps create and
|
||||
* execute the tests in transaction, and rolls it back in the end.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user