-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: VoIP freeswitch UI admin (#33004)
* feat: Add options to view and assign voice call extensions on the admin's user's list * chore: changed Roles import to not use index * chore: added ee/views to unit test build * test: added VoIP unit tests for UsersTable * test: added VoIP unit tests for UsersPageHeader * test: added VoIP unit tests for AssignExtensionModal * test: added legacyRoot to tests * test: added await to userEvent.click * chore: added meteor imports coming from global namespace * test: added mock for meteor methods * test: removed module mocks from UsersTable * test: get by role instead of testId on AssignExtensionModal * chore: imported Meteor.users not compatible with global Meteor.users type * Use fake data helpers in unit tests * feat: improved the user interface * test: adjusted UserTable unit tests * Adjust type names * Replace `voiceCall` with `voip` --------- Co-authored-by: Tasso <[email protected]>
- Loading branch information
1 parent
ae54a18
commit 8389ec1
Showing
22 changed files
with
719 additions
and
29 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
24 changes: 24 additions & 0 deletions
24
apps/meteor/client/views/admin/users/UserPageHeaderContentWithSeatsCap.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import UserPageHeaderContent from './UserPageHeaderContentWithSeatsCap'; | ||
|
||
it('should render "Associate Extension" button when VoIP_TeamCollab_Enabled setting is enabled', async () => { | ||
render(<UserPageHeaderContent activeUsers={1} maxActiveUsers={1} isSeatsCapExceeded={false} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', true).build(), | ||
}); | ||
|
||
expect(screen.getByRole('button', { name: 'Assign_extension' })).toBeEnabled(); | ||
}); | ||
|
||
it('should not render "Associate Extension" button when VoIP_TeamCollab_Enabled setting is disabled', async () => { | ||
render(<UserPageHeaderContent activeUsers={1} maxActiveUsers={1} isSeatsCapExceeded={false} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', false).build(), | ||
}); | ||
|
||
expect(screen.queryByRole('button', { name: 'Assign_extension' })).not.toBeInTheDocument(); | ||
}); |
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
98 changes: 98 additions & 0 deletions
98
apps/meteor/client/views/admin/users/UsersTable/UsersTable.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { createFakeUser } from '../../../../../tests/mocks/data'; | ||
import UsersTable from './UsersTable'; | ||
|
||
const createFakeAdminUser = (freeSwitchExtension?: string) => | ||
createFakeUser({ | ||
active: true, | ||
roles: ['admin'], | ||
type: 'user', | ||
freeSwitchExtension, | ||
}); | ||
|
||
it('should not render "Voice call extension" column when voice call is disabled', async () => { | ||
const user = createFakeAdminUser('1000'); | ||
|
||
render( | ||
<UsersTable | ||
filteredUsersQueryResult={{ isSuccess: true, data: { users: [user], count: 1, offset: 1, total: 1 } } as any} | ||
setUserFilters={() => undefined} | ||
tab='all' | ||
onReload={() => undefined} | ||
paginationData={{} as any} | ||
sortData={{} as any} | ||
isSeatsCapExceeded={false} | ||
roleData={undefined} | ||
/>, | ||
{ | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withUser(user).withSetting('VoIP_TeamCollab_Enabled', false).build(), | ||
}, | ||
); | ||
|
||
expect(screen.queryByText('Voice_call_extension')).not.toBeInTheDocument(); | ||
|
||
screen.getByRole('button', { name: 'More_actions' }).click(); | ||
expect(await screen.findByRole('listbox')).toBeInTheDocument(); | ||
expect(screen.queryByRole('option', { name: /Assign_extension/ })).not.toBeInTheDocument(); | ||
expect(screen.queryByRole('option', { name: /Unassign_extension/ })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render "Unassign_extension" button when user has a associated extension', async () => { | ||
const user = createFakeAdminUser('1000'); | ||
|
||
render( | ||
<UsersTable | ||
filteredUsersQueryResult={{ isSuccess: true, data: { users: [user], count: 1, offset: 1, total: 1 } } as any} | ||
setUserFilters={() => undefined} | ||
tab='all' | ||
onReload={() => undefined} | ||
paginationData={{} as any} | ||
sortData={{} as any} | ||
isSeatsCapExceeded={false} | ||
roleData={undefined} | ||
/>, | ||
{ | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withUser(user).withSetting('VoIP_TeamCollab_Enabled', true).build(), | ||
}, | ||
); | ||
|
||
expect(screen.getByText('Voice_call_extension')).toBeInTheDocument(); | ||
|
||
screen.getByRole('button', { name: 'More_actions' }).click(); | ||
expect(await screen.findByRole('listbox')).toBeInTheDocument(); | ||
expect(screen.queryByRole('option', { name: /Assign_extension/ })).not.toBeInTheDocument(); | ||
expect(screen.getByRole('option', { name: /Unassign_extension/ })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render "Assign_extension" button when user has no associated extension', async () => { | ||
const user = createFakeAdminUser(); | ||
|
||
render( | ||
<UsersTable | ||
filteredUsersQueryResult={{ isSuccess: true, data: { users: [user], count: 1, offset: 1, total: 1 } } as any} | ||
setUserFilters={() => undefined} | ||
tab='all' | ||
onReload={() => undefined} | ||
paginationData={{} as any} | ||
sortData={{} as any} | ||
isSeatsCapExceeded={false} | ||
roleData={undefined} | ||
/>, | ||
{ | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withUser(user).withSetting('VoIP_TeamCollab_Enabled', true).build(), | ||
}, | ||
); | ||
|
||
expect(screen.getByText('Voice_call_extension')).toBeInTheDocument(); | ||
|
||
screen.getByRole('button', { name: 'More_actions' }).click(); | ||
expect(await screen.findByRole('listbox')).toBeInTheDocument(); | ||
expect(screen.getByRole('option', { name: /Assign_extension/ })).toBeInTheDocument(); | ||
expect(screen.queryByRole('option', { name: /Unassign_extension/ })).not.toBeInTheDocument(); | ||
}); |
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
Oops, something went wrong.