Skip to content

Commit

Permalink
chore: Add extra tests on tools/drawer alias behavior (#3052)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris authored Nov 25, 2024
1 parent 31c8885 commit ea46162
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app-layout/__tests__/common.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jest.mock('@cloudscape-design/component-toolkit', () => ({
useContainerQuery: () => [100, () => {}],
}));

describeEachAppLayout({ themes: ['classic', 'refresh', 'refresh-toolbar'] }, ({ theme, size }) => {
describeEachAppLayout(({ theme, size }) => {
test('Default state', () => {
const { wrapper } = renderComponent(<AppLayout />);

Expand All @@ -38,6 +38,12 @@ describeEachAppLayout({ themes: ['classic', 'refresh', 'refresh-toolbar'] }, ({
expect(wrapper.findBreadcrumbs()).toBeTruthy();
});

test('should not find tools slot as findActiveDrawer utility', () => {
const { wrapper } = renderComponent(<AppLayout toolsOpen={true} tools="test content" />);
expect(wrapper.findTools()!.getElement()).toHaveTextContent('test content');
expect(wrapper.findActiveDrawer()).toBeFalsy();
});

[
{
openProp: 'navigationOpen',
Expand Down
14 changes: 14 additions & 0 deletions src/app-layout/__tests__/runtime-drawers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ describeEachAppLayout(({ theme, size }) => {
expect(wrapper.findDrawersTriggers()).toHaveLength(2);
});

test('should find tools slot as findActiveDrawer when local runtime drawers are present', async () => {
awsuiPlugins.appLayout.registerDrawer(drawerDefaults);
const { wrapper } = await renderComponent(<AppLayout toolsOpen={true} tools="test content" />);
expect(wrapper.findActiveDrawer()!.getElement()).toEqual(wrapper.findTools()!.getElement());
expect(wrapper.findActiveDrawer()!.getElement()).toHaveTextContent('test content');
});

test('should not find tools slot as findActiveDrawer when only global runtime drawers are present', async () => {
awsuiPlugins.appLayout.registerDrawer({ ...drawerDefaults, type: 'global' });
const { wrapper } = await renderComponent(<AppLayout toolsOpen={true} tools="test content" />);
expect(wrapper.findTools().getElement()).toHaveTextContent('test content');
expect(wrapper.findActiveDrawer()).toBeFalsy();
});

test('update rendered drawers via runtime config', async () => {
awsuiPlugins.appLayout.registerDrawer({ ...drawerDefaults, resizable: true });
const { wrapper } = await renderComponent(<AppLayout />);
Expand Down

0 comments on commit ea46162

Please sign in to comment.