Skip to content

Commit 85ae2b8

Browse files
committed
CR feedback, remove redundant tests
1 parent 8b74e65 commit 85ae2b8

1 file changed

Lines changed: 24 additions & 104 deletions

File tree

labkey-ui-ehr/src/ParticipantHistory/ParticipantReports.test.tsx

Lines changed: 24 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ describe('ParticipantReports', () => {
560560

561561
// Act
562562
renderWithServerContext(<ParticipantReports fetchReports={mockFetchReports} />, defaultServerContext());
563-
await waitFor(() => {
564-
expect(screen.getByText('General')).toBeVisible();
565-
});
563+
await waitForReportsToLoad();
566564

567565
// Assert - Alive at Center button is initially enabled
568566
const aliveBtn = screen.getByRole('button', { name: /all alive at center/i });
@@ -778,9 +776,7 @@ describe('ParticipantReports', () => {
778776

779777
// Act
780778
renderWithServerContext(<ParticipantReports fetchReports={mockFetchReports} />, defaultServerContext());
781-
await waitFor(() => {
782-
expect(screen.getByText('General')).toBeVisible();
783-
});
779+
await waitForReportsToLoad();
784780

785781
// Assert - no filter unsupported error message is shown
786782
expect(
@@ -791,49 +787,29 @@ describe('ParticipantReports', () => {
791787
});
792788

793789
describe('dependency injection', () => {
794-
test.each([
795-
{
796-
name: 'single category',
797-
reports: [
798-
{
799-
id: 'injected-report',
800-
title: 'Injected Report',
801-
reportType: 'query',
802-
supportsnonidfilters: true,
803-
visible: true,
804-
category: 'Injected',
805-
schemaName: 'ehr',
806-
queryName: 'testQuery',
807-
},
808-
],
809-
expectedCategories: ['Injected'],
810-
},
811-
{
812-
name: 'multiple categories',
813-
reports: [
814-
{
815-
id: 'report-1',
816-
title: 'Report One',
817-
reportType: 'query',
818-
supportsnonidfilters: true,
819-
category: 'Category A',
820-
schemaName: 'ehr',
821-
queryName: 'query1',
822-
},
823-
{
824-
id: 'report-2',
825-
title: 'Report Two',
826-
reportType: 'query',
827-
supportsnonidfilters: true,
828-
category: 'Category B',
829-
schemaName: 'ehr',
830-
queryName: 'query2',
831-
},
832-
],
833-
expectedCategories: ['Category A', 'Category B'],
834-
},
835-
])('accepts injected fetchReports for $name', async ({ reports, expectedCategories }) => {
790+
test('accepts injected fetchReports for multiple categories', async () => {
836791
// Arrange
792+
const reports = [
793+
{
794+
id: 'report-1',
795+
title: 'Report One',
796+
reportType: 'query',
797+
supportsnonidfilters: true,
798+
category: 'Category A',
799+
schemaName: 'ehr',
800+
queryName: 'query1',
801+
},
802+
{
803+
id: 'report-2',
804+
title: 'Report Two',
805+
reportType: 'query',
806+
supportsnonidfilters: true,
807+
category: 'Category B',
808+
schemaName: 'ehr',
809+
queryName: 'query2',
810+
},
811+
];
812+
const expectedCategories = ['Category A', 'Category B'];
837813
const injectedFetchReports: FetchReportsFn = jest.fn().mockResolvedValue({ reports } as FetchReportsResult);
838814

839815
// Act
@@ -849,61 +825,5 @@ describe('ParticipantReports', () => {
849825
expect(screen.getByText(category)).toBeVisible();
850826
});
851827
});
852-
853-
test('uses default fetchReports when prop not provided', async () => {
854-
// Arrange
855-
const defaultFetchReports = jest.fn().mockResolvedValue({
856-
reports: [
857-
{
858-
id: 'default-report',
859-
title: 'Default Report',
860-
reportType: 'query',
861-
supportsnonidfilters: true,
862-
category: 'Default Category',
863-
schemaName: 'ehr',
864-
queryName: 'defaultQuery',
865-
},
866-
],
867-
});
868-
const apiWrapperSpy = jest
869-
.spyOn(APIWrapperModule, 'getDefaultParticipantHistoryAPIWrapper')
870-
.mockReturnValue({
871-
fetchReports: defaultFetchReports,
872-
} as any);
873-
874-
try {
875-
// Act
876-
renderWithServerContext(<ParticipantReports />, defaultServerContext());
877-
878-
// Act & Assert - default fetchReports from API wrapper was called exactly once
879-
await waitFor(() => {
880-
expect(defaultFetchReports).toHaveBeenCalledTimes(1);
881-
});
882-
883-
// Assert - default report category 'Default Category' is visible
884-
expect(screen.getByText('Default Category')).toBeVisible();
885-
} finally {
886-
apiWrapperSpy.mockRestore();
887-
}
888-
});
889-
890-
test('injected fetchReports handles errors', async () => {
891-
// Arrange
892-
const errorFetchReports: FetchReportsFn = jest.fn().mockResolvedValue({
893-
reports: [],
894-
error: 'Injected error for testing',
895-
});
896-
897-
// Act
898-
renderWithServerContext(<ParticipantReports fetchReports={errorFetchReports} />, defaultServerContext());
899-
900-
// Act & Assert - injected fetchReports was called
901-
await waitFor(() => {
902-
expect(errorFetchReports).toHaveBeenCalled();
903-
});
904-
905-
// Assert - empty state message is shown
906-
expect(screen.queryByText('No reports configuration provided.')).toBeInTheDocument();
907-
});
908828
});
909829
});

0 commit comments

Comments
 (0)