-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): improve team invite (#9092)
- Loading branch information
1 parent
671c41c
commit 9b0f1bb
Showing
14 changed files
with
146 additions
and
46 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
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
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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ import { | |
acceptInviteById, | ||
createTestingApp, | ||
createWorkspace, | ||
getInviteInfo, | ||
grantMember, | ||
inviteLink, | ||
inviteUser, | ||
|
@@ -95,11 +96,14 @@ const init = async (app: INestApplication, memberLimit = 10) => { | |
|
||
const createInviteLink = async () => { | ||
const inviteId = await inviteLink(app, owner.token.token, ws.id, 'OneDay'); | ||
return async (email: string): Promise<UserAuthedType> => { | ||
const member = await signUp(app, email.split('@')[0], email, '123456'); | ||
await acceptInviteById(app, ws.id, inviteId, false, member.token.token); | ||
return member; | ||
}; | ||
return [ | ||
inviteId, | ||
async (email: string): Promise<UserAuthedType> => { | ||
const member = await signUp(app, email.split('@')[0], email, '123456'); | ||
await acceptInviteById(app, ws.id, inviteId, false, member.token.token); | ||
return member; | ||
}, | ||
] as const; | ||
}; | ||
|
||
const admin = await invite('[email protected]', 'Admin'); | ||
|
@@ -237,8 +241,15 @@ test('should be able to leave workspace', async t => { | |
|
||
test('should be able to invite by link', async t => { | ||
const { app, permissions, quotaManager } = t.context; | ||
const { createInviteLink, ws } = await init(app, 4); | ||
const invite = await createInviteLink(); | ||
const { createInviteLink, owner, ws } = await init(app, 4); | ||
const [inviteId, invite] = await createInviteLink(); | ||
|
||
{ | ||
// check invite link | ||
const info = await getInviteInfo(app, owner.token.token, inviteId); | ||
t.is(info.workspace.id, ws.id, 'should be able to get invite info'); | ||
} | ||
|
||
{ | ||
// invite link | ||
const members: UserAuthedType[] = []; | ||
|
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
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
4 changes: 2 additions & 2 deletions
4
packages/frontend/graphql/src/graphql/workspace-invite-link.gql
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
mutation inviteLink( | ||
mutation createInviteLink( | ||
$workspaceId: String! | ||
$expireTime: WorkspaceInviteLinkExpireTime! | ||
) { | ||
inviteLink(workspaceId: $workspaceId, expireTime: $expireTime) | ||
createInviteLink(workspaceId: $workspaceId, expireTime: $expireTime) | ||
} |
Oops, something went wrong.