-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove team when sole owner and remove projects
Fixes #6655
- Loading branch information
Showing
4 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,57 @@ import { DBIdentity } from './typeorm/entity/db-identity'; | |
expect(members[0].primaryEmail).to.eq('[email protected]'); | ||
} | ||
|
||
@test(timeout(15000)) | ||
public async findTeamWhenUserIsSoleOwner() { | ||
const user = await this.userDb.newUser(); | ||
user.identities.push({ authProviderId: 'GitHub', authId: '2345', authName: 'Nana', primaryEmail: '[email protected]' }); | ||
await this.userDb.storeUser(user); | ||
|
||
const ownTeam = await this.db.createTeam(user.id, 'My Own Team'); | ||
|
||
const teams = await this.db.findTeamsByUserAsSoleOwner(user.id); | ||
|
||
expect(teams.length).to.eq(1); | ||
expect(teams[0].id).to.eq(ownTeam.id); | ||
|
||
} | ||
|
||
@test(timeout(10000)) | ||
public async findTeamWhenUserIsSoleOwnerWithMembers() { | ||
const user = await this.userDb.newUser(); | ||
user.identities.push({ authProviderId: 'GitHub', authId: '2345', authName: 'Nana', primaryEmail: '[email protected]' }); | ||
await this.userDb.storeUser(user); | ||
const user2 = await this.userDb.newUser(); | ||
user.identities.push({ authProviderId: 'GitLab', authId: '4567', authName: 'Dudu', primaryEmail: '[email protected]' }); | ||
await this.userDb.storeUser(user2); | ||
|
||
const ownTeam = await this.db.createTeam(user.id, 'My Own Team With Members'); | ||
await this.db.addMemberToTeam(user2.id, ownTeam.id); | ||
|
||
const teams = await this.db.findTeamsByUserAsSoleOwner(user.id); | ||
|
||
expect(teams.length).to.eq(1); | ||
expect(teams[0].id).to.eq(ownTeam.id); | ||
|
||
} | ||
|
||
@test(timeout(10000)) | ||
public async findNoTeamWhenCoOwned() { | ||
const user = await this.userDb.newUser(); | ||
user.identities.push({ authProviderId: 'GitHub', authId: '2345', authName: 'Nana', primaryEmail: '[email protected]' }); | ||
await this.userDb.storeUser(user); | ||
const user2 = await this.userDb.newUser(); | ||
user.identities.push({ authProviderId: 'GitLab', authId: '4567', authName: 'Dudu', primaryEmail: '[email protected]' }); | ||
await this.userDb.storeUser(user2); | ||
|
||
const jointTeam = await this.db.createTeam(user.id, 'Joint Team'); | ||
await this.db.addMemberToTeam(user2.id, jointTeam.id); | ||
await this.db.setTeamMemberRole(user2.id, jointTeam.id, 'owner'); | ||
|
||
const teams = await this.db.findTeamsByUserAsSoleOwner(user.id); | ||
|
||
expect(teams.length).to.eq(0); | ||
} | ||
} | ||
|
||
module.exports = new TeamDBSpec() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters