-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: unified users page header content into a single component (#…
- Loading branch information
1 parent
956bf61
commit 72c6101
Showing
5 changed files
with
137 additions
and
69 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
24 changes: 0 additions & 24 deletions
24
apps/meteor/client/views/admin/users/UserPageHeaderContentWithSeatsCap.spec.tsx
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
apps/meteor/client/views/admin/users/UsersPageHeaderContent.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,96 @@ | ||
import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
import { render, screen } from '@testing-library/react'; | ||
import React from 'react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import UsersPageHeaderContent from './UsersPageHeaderContent'; | ||
|
||
it('should render "Associate Extension" button when VoIP_TeamCollab_Enabled setting is enabled', async () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
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(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withSetting('VoIP_TeamCollab_Enabled', false).build(), | ||
}); | ||
|
||
expect(screen.queryByRole('button', { name: 'Assign_extension' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should show "Invite" button if has build-register-user permission', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withPermission('bulk-register-user').build(), | ||
}); | ||
|
||
expect(screen.getByRole('button', { name: 'Invite' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide "Invite" button if user doesnt have build-register-user permission', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().build(), | ||
}); | ||
|
||
expect(screen.queryByRole('button', { name: 'Invite' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should show "New User" button if has create-user permission', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withPermission('create-user').build(), | ||
}); | ||
|
||
expect(screen.getByRole('button', { name: 'New_user' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide "New User" button if user doesnt have create-user permission', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().withPermission('create-user').build(), | ||
}); | ||
|
||
expect(screen.getByRole('button', { name: 'New_user' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should show "Buy more seats" button if seats caps is exceeded', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().build(), | ||
}); | ||
|
||
expect(screen.getByRole('link', { name: 'Buy_more_seats' })).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide "Buy more seats" button if seats caps is within limits', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 1 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().build(), | ||
}); | ||
|
||
expect(screen.queryByRole('link', { name: 'Buy_more_seats' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should show seats available progress bar', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: 10 }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().build(), | ||
}); | ||
|
||
expect(screen.getByTestId('seats-cap-progress-bar')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should hide seats available progress bar if theres no limit', () => { | ||
render(<UsersPageHeaderContent isSeatsCapExceeded={false} seatsCap={{ activeUsers: 1, maxActiveUsers: Number.POSITIVE_INFINITY }} />, { | ||
legacyRoot: true, | ||
wrapper: mockAppRoot().withJohnDoe().build(), | ||
}); | ||
|
||
expect(screen.queryByTestId('seats-cap-progress-bar')).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