import { mockAppRoot } from '@rocket.chat/mock-providers'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; import UsersPageHeaderContent from './UsersPageHeaderContent'; it('should show "Invite" button if has build-register-user permission', () => { render(, { 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(, { wrapper: mockAppRoot().withJohnDoe().build(), }); expect(screen.queryByRole('button', { name: 'Invite' })).not.toBeInTheDocument(); }); it('should show "New User" button if has create-user permission', () => { render(, { 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(, { 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(, { 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(, { wrapper: mockAppRoot().withJohnDoe().build(), }); expect(screen.queryByRole('link', { name: 'Buy_more_seats' })).not.toBeInTheDocument(); }); it('should show seats available progress bar', () => { render(, { wrapper: mockAppRoot().withJohnDoe().build(), }); expect(screen.getByTestId('seats-cap-progress-bar')).toBeInTheDocument(); }); it('should hide seats available progress bar if theres no limit', () => { render(, { wrapper: mockAppRoot().withJohnDoe().build(), }); expect(screen.queryByTestId('seats-cap-progress-bar')).not.toBeInTheDocument(); });