Skip to content

Commit cbedd80

Browse files
committed
test: Fix existing tests
1 parent 098422a commit cbedd80

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

app/src/tests/unit/api/geographicAssociation.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,17 @@ describe('LocalStorageGeographicStore', () => {
255255
expect(result.createdAt).toBeDefined();
256256
});
257257

258-
it('given duplicate population then throws error', async () => {
258+
it('given duplicate population then allows creation', async () => {
259259
// Given
260260
await store.create(mockPopulation1);
261261

262-
// When/Then
263-
await expect(store.create(mockPopulation1)).rejects.toThrow(
264-
'Geographic population already exists'
265-
);
262+
// When
263+
const result = await store.create(mockPopulation1);
264+
265+
// Then - Implementation allows duplicates for multiple entries of same geography
266+
expect(result).toEqual(mockPopulation1);
267+
const allPopulations = await store.findByUser('user-123');
268+
expect(allPopulations).toHaveLength(2);
266269
});
267270
});
268271

app/src/tests/unit/components/common/PathwayView.test.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,11 @@ describe('PathwayView', () => {
362362
expect(cancelButton).toBeDisabled();
363363
});
364364

365-
test('given cancel action then renders disabled cancel button', () => {
365+
test('given cancel action with onClick then renders enabled cancel button', () => {
366366
render(<PathwayView title={PATHWAY_VIEW_STRINGS.MAIN_TITLE} cancelAction={mockCancelAction} />);
367367

368368
const cancelButton = screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.CANCEL_BUTTON });
369-
expect(cancelButton).toBeDisabled();
369+
expect(cancelButton).not.toBeDisabled();
370370
});
371371

372372
test('given user clicks primary button then calls primary handler', async () => {
@@ -382,7 +382,7 @@ describe('PathwayView', () => {
382382
});
383383

384384
describe('Button Precedence', () => {
385-
test('given explicit buttons and convenience props then explicit buttons take precedence', () => {
385+
test('given explicit buttons and convenience props then uses new layout with actions', () => {
386386
render(
387387
<PathwayView
388388
title={PATHWAY_VIEW_STRINGS.MAIN_TITLE}
@@ -392,27 +392,21 @@ describe('PathwayView', () => {
392392
/>
393393
);
394394

395-
// Should show explicit buttons, not the primary/cancel actions
395+
// When convenience props are provided, they take precedence over explicit buttons
396396
expect(
397-
screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.BACK_BUTTON })
397+
screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.SUBMIT_BUTTON })
398398
).toBeInTheDocument();
399399
expect(
400-
screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.CONTINUE_BUTTON })
400+
screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.CANCEL_BUTTON })
401401
).toBeInTheDocument();
402-
expect(
403-
screen.queryByRole('button', { name: PATHWAY_VIEW_STRINGS.SUBMIT_BUTTON })
404-
).not.toBeInTheDocument();
405-
expect(
406-
screen.queryByRole('button', { name: PATHWAY_VIEW_STRINGS.CANCEL_BUTTON })
407-
).not.toBeInTheDocument();
408402
});
409403

410-
test('given no actions and no preset then renders default cancel button', () => {
404+
test('given no actions and no preset then renders no buttons', () => {
411405
render(<PathwayView title={PATHWAY_VIEW_STRINGS.MAIN_TITLE} />);
412406

413-
expect(
414-
screen.getByRole('button', { name: PATHWAY_VIEW_STRINGS.CANCEL_BUTTON })
415-
).toBeInTheDocument();
407+
// Without any button configuration, no buttons are rendered
408+
const buttons = screen.queryAllByRole('button');
409+
expect(buttons).toHaveLength(0);
416410
});
417411
});
418412
});

app/src/tests/unit/utils/reportPopulationLock.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,20 @@ describe('reportPopulationLock', () => {
108108
});
109109

110110
describe('getPopulationSelectionTitle', () => {
111-
it('given shouldLock true then returns Apply Household(s)', () => {
111+
it('given shouldLock true then returns Apply household(s)', () => {
112112
// When
113113
const result = getPopulationSelectionTitle(true);
114114

115115
// Then
116-
expect(result).toBe('Apply Household(s)');
116+
expect(result).toBe('Apply household(s)');
117117
});
118118

119-
it('given shouldLock false then returns Select Household(s)', () => {
119+
it('given shouldLock false then returns Select household(s)', () => {
120120
// When
121121
const result = getPopulationSelectionTitle(false);
122122

123123
// Then
124-
expect(result).toBe('Select Household(s)');
124+
expect(result).toBe('Select household(s)');
125125
});
126126
});
127127

0 commit comments

Comments
 (0)