Skip to content

Commit

Permalink
(tests) O3-4095 Add tests for configuring encounter table tabs (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
CynthiaKamau authored Oct 28, 2024
1 parent e27909a commit 760102b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ describe('ConfigureDashboardModal', () => {
isLowContrast: true,
subtitle: 'submenuCreated',
});
expect(screen.getByText('tabName')).toBeInTheDocument();
expect(screen.getByText('displayTitle')).toBeInTheDocument();
});

it('shows error snackbar when updateSchema throws an error', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ describe('InteractiveBuilder', () => {
},
};

const mockConfigureTabsSchema: Schema = {
id: 'e0fa849d-34b9-4f09-8f53-b669df28efaa',
'@openmrs/esm-patient-chart-app': {
extensionSlots: {
'patient-chart-dashboard-slot': {
add: ['nav-group#hIVPackage'],
configure: {
'nav-group#hIVPackage': {
title: 'HIV Package',
slotName: 'hiv-package',
isExpanded: true,
},
},
},
'hiv-package': {
add: ['dashboard#hcat-patient-summary'],
configure: {
'dashboard#hcat-patient-summary': {
title: 'Patient Summary',
path: 'hcat-patient-summary',
slot: 'hcat-patient-summary-dashboard-slot',
},
},
},
},
},
};

beforeEach(() => {
jest.clearAllMocks();
});
Expand Down Expand Up @@ -94,4 +122,55 @@ describe('InteractiveBuilder', () => {
}),
);
});

it('enables a user to configure encounter table tabs', async () => {
const user = userEvent.setup();
render(<InteractiveBuilder schema={mockConfigureTabsSchema} onSchemaChange={mockOnSchemaChange} />);

expect(screen.getByText(/Continue adding sub menus and configuring dashboards/i)).toBeInTheDocument();
expect(screen.getByText(/HIV Package/i)).toBeInTheDocument;
expect(screen.getByText(/Clinical View Submenus/i)).toBeInTheDocument;
const accordionButton = screen.getByRole('button', { name: /patient summary/i }); // Adjust based on the accordion's button text
await user.click(accordionButton);
expect(screen.getByText(/Menu Slot : hcat-patient-summary-dashboard-slot/i)).toBeInTheDocument();
expect(
screen.getByText(/Now configure dashboards to show on the patient chart when this submenu is clicked/i),
).toBeInTheDocument();
const configureDashboardButton = screen.getByRole('button', { name: /configure dashboard/i });
expect(configureDashboardButton).toBeInTheDocument();

await user.click(configureDashboardButton);

expect(showModal).toHaveBeenCalledWith(
'configure-dashboard-modal',
expect.objectContaining({
closeModal: expect.any(Function),
onSchemaChange: expect.any(Function),
schema: {
'@openmrs/esm-patient-chart-app': {
extensionSlots: {
'hiv-package': {
add: ['dashboard#hcat-patient-summary'],
configure: {
'dashboard#hcat-patient-summary': {
path: 'hcat-patient-summary',
slot: 'hcat-patient-summary-dashboard-slot',
title: 'Patient Summary',
},
},
},
'patient-chart-dashboard-slot': {
add: ['nav-group#hIVPackage'],
configure: {
'nav-group#hIVPackage': { isExpanded: true, slotName: 'hiv-package', title: 'HIV Package' },
},
},
},
},
id: 'e0fa849d-34b9-4f09-8f53-b669df28efaa',
},
slotName: 'hcat-patient-summary-dashboard-slot',
}),
);
});
});

0 comments on commit 760102b

Please sign in to comment.