Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriellsh committed Sep 26, 2024
1 parent f681fce commit 26ebd54
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
24 changes: 12 additions & 12 deletions apps/meteor/client/sidebar/sections/BannerSection.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ describe('Sidebar -> BannerSection -> Airgapped restriction', () => {
it('Should render null if admin and not restricted or warning', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 8)
.build(),
wrapper: mockAppRoot().withJohnDoe().withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 8).build(),
});

expect(screen.queryByText('air-gapped', { exact: false })).not.toBeInTheDocument();
Expand All @@ -34,36 +31,39 @@ describe('Sidebar -> BannerSection -> Airgapped restriction', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.build(),
});

expect(screen.queryByText('will enter read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('will enter read-only', { exact: false })).toBeInTheDocument();
});

it('Should render restriction message if admin and restricted phase', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 0)
.build(),
});

expect(screen.queryByText('is in read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('is in read-only', { exact: false })).toBeInTheDocument();
});

it('Should render restriction message instead of another banner', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 0)
.withSetting('Presence_broadcast_disabled', true)
.build(),
});

expect(screen.queryByText('is in read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('is in read-only', { exact: false })).toBeInTheDocument();
});
});
24 changes: 12 additions & 12 deletions apps/meteor/client/sidebarv2/sections/BannerSection.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ describe('Sidebar -> BannerSection -> Airgapped restriction', () => {
it('Should render null if admin and not restricted or warning', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 8)
.build(),
wrapper: mockAppRoot().withJohnDoe().withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 8).build(),
});

expect(screen.queryByText('air-gapped', { exact: false })).not.toBeInTheDocument();
Expand All @@ -34,36 +31,39 @@ describe('Sidebar -> BannerSection -> Airgapped restriction', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.build(),
});

expect(screen.queryByText('will enter read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('will enter read-only', { exact: false })).toBeInTheDocument();
});

it('Should render restriction message if admin and restricted phase', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 0)
.build(),
});

expect(screen.queryByText('is in read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('is in read-only', { exact: false })).toBeInTheDocument();
});

it('Should render restriction message instead of another banner', () => {
render(<BannerSection />, {
legacyRoot: true,
wrapper: mockAppRoot()
.withJohnDoe({ roles: ['user'] })
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 7)
.withJohnDoe()
.withRole('admin')
.withSetting('Cloud_Workspace_AirGapped_Restrictions_Remaining_Days', 0)
.withSetting('Presence_broadcast_disabled', true)
.build(),
});

expect(screen.queryByText('is in read-only', { exact: false })).not.toBeInTheDocument();
expect(screen.getByText('is in read-only', { exact: false })).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { useMessageComposerIsArchived } from './hooks/useMessageComposerIsArchiv
import { useMessageComposerIsBlocked } from './hooks/useMessageComposerIsBlocked';
import { useMessageComposerIsReadOnly } from './hooks/useMessageComposerIsReadOnly';

// TODO unit test this
const ComposerContainer = ({ children, ...props }: ComposerMessageProps): ReactElement => {
const room = useRoom();

Expand Down

0 comments on commit 26ebd54

Please sign in to comment.