-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Resend invite operation on users list (#11351)
Co-authored-by: Danny Martini <[email protected]>
- Loading branch information
1 parent
f495875
commit e4218de
Showing
6 changed files
with
44 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ export class UserService { | |
email, | ||
inviteAcceptUrl, | ||
emailSent: false, | ||
role, | ||
}, | ||
error: '', | ||
}; | ||
|
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 |
---|---|---|
|
@@ -2,17 +2,22 @@ import type { CurrentUserResponse } from '@/Interface'; | |
import { useUsersStore } from './users.store'; | ||
import { createPinia, setActivePinia } from 'pinia'; | ||
|
||
const { loginCurrentUser, identify } = vi.hoisted(() => { | ||
const { loginCurrentUser, identify, inviteUsers } = vi.hoisted(() => { | ||
return { | ||
loginCurrentUser: vi.fn(), | ||
identify: vi.fn(), | ||
inviteUsers: vi.fn(), | ||
}; | ||
}); | ||
|
||
vi.mock('@/api/users', () => ({ | ||
loginCurrentUser, | ||
})); | ||
|
||
vi.mock('@/api/invitation', () => ({ | ||
inviteUsers, | ||
})); | ||
|
||
vi.mock('@/composables/useTelemetry', () => ({ | ||
useTelemetry: vi.fn(() => ({ | ||
identify, | ||
|
@@ -58,4 +63,31 @@ describe('users.store', () => { | |
expect(identify).toHaveBeenCalledWith('test-instance-id', mockUser.id); | ||
}); | ||
}); | ||
|
||
describe('inviteUsers', () => { | ||
it('should add pending user to the store', async () => { | ||
const usersStore = useUsersStore(); | ||
|
||
inviteUsers.mockResolvedValueOnce([ | ||
{ | ||
user: { id: 'random-id', email: '[email protected]', emailSent: true, role: 'global:member' }, | ||
}, | ||
]); | ||
|
||
await usersStore.inviteUsers([{ email: '[email protected]', role: 'global:member' }]); | ||
|
||
expect(usersStore.allUsers[0]).toMatchObject( | ||
expect.objectContaining({ | ||
id: 'random-id', | ||
email: '[email protected]', | ||
role: 'global:member', | ||
isPending: true, | ||
isDefaultUser: false, | ||
isPendingUser: true, | ||
fullName: undefined, | ||
emailSent: true, | ||
}), | ||
); | ||
}); | ||
}); | ||
}); |
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