Skip to content

Commit 083a0df

Browse files
committed
Extract shared behavioural test utilities into @aehrc/questionnaire-test-toolkit
The Aboriginal and Torres Strait Islander Health Check suite's helpers lived in apps/smart-forms-app/src/test/. A form's test suite that lives outside this application cannot reach them there. Move testUtils.ts and behavioralTestUtils.tsx into a package and repoint the suite at it. The package is built with tsup (dual ESM/CJS + declarations), the same line the other four published packages here use, so that entry points reference dist rather than raw TypeScript and an external consumer needs no transform configuration of its own. Notable choices, all made to avoid repeating the @aehrc/testing-toolkit failure in aehrc#1586, where the package was published in name only: - files is ["dist"], not ["src"], so the tarball has a runtime entry point. - vitest is not a dependency at any level. invokeExtract took a Mock<...> and only ever read .mock.lastCall, so it now takes a structural ExtractResultSpy that an untyped vi.fn() or jest.fn() satisfies. No consumer is forced onto a particular test runner. - @types/fhir is a dependency and @types/react a peer, because both appear in the emitted declarations - fhir/r4 for Patient and Questionnaire, react/jsx-runtime for the wrapper's return type. - React, the renderer, TanStack Query and both testing libraries stay external, so no consumer can end up with a second React or a second renderer store. Verified by packing the tarball and installing it into a project outside this workspace, type-checking with skipLibCheck: false, then mounting the harness and running an interaction and an extraction test there. Inside the monorepo the packages/* glob resolves the toolkit locally no matter what is published, which is exactly what made aehrc#1586 look green.
1 parent 55653cb commit 083a0df

24 files changed

Lines changed: 624 additions & 86 deletions

‎apps/smart-forms-app/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"zustand": "^5.0.14"
7474
},
7575
"devDependencies": {
76+
"@aehrc/questionnaire-test-toolkit": "^0.1.0",
7677
"@jest/globals": "^30.3.0",
7778
"@playwright/test": "^1.60.0",
7879
"@sentry/cli": "^2.57.0",

‎apps/smart-forms-app/src/test/aboriginalFormCalculation.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
inputDecimal,
1010
getVisibleTab,
1111
checkRadioOption
12-
} from './testUtils.ts';
12+
} from '@aehrc/questionnaire-test-toolkit';
1313
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1414

1515
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor0To1Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor12To6Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor24To13Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor49To25Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor51Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormCompletedFor5To1Years.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
inputDecimal,
1515
getVisibleTab,
1616
inputDateTime
17-
} from './testUtils.ts';
17+
} from '@aehrc/questionnaire-test-toolkit';
1818
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1919

2020
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormConditions.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
findByLinkIdOrLabel,
1212
checkCheckBox,
1313
checkCheckboxOption
14-
} from './testUtils.ts';
14+
} from '@aehrc/questionnaire-test-toolkit';
1515
import { AboriginalForm } from './aboriginalFormUtils.tsx';
1616

1717
vi.mock('fhirclient', () => ({

‎apps/smart-forms-app/src/test/aboriginalFormExtraction.test.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { vi, beforeAll } from 'vitest';
22
import { render, waitFor } from '@testing-library/react';
3-
import { AboriginalForm, terminologyServerUrl } from './aboriginalFormUtils';
3+
import { AboriginalForm } from './aboriginalFormUtils';
4+
import { terminologyServerUrl } from '@aehrc/questionnaire-test-toolkit';
45
import {
56
nonSnomedCondition,
67
patient,
@@ -30,7 +31,7 @@ import {
3031
selectTab,
3132
chooseSelectOption,
3233
checkRadioOption
33-
} from './testUtils';
34+
} from '@aehrc/questionnaire-test-toolkit';
3435
import { FhirResource, MedicationStatement } from 'fhir/r4';
3536

3637
vi.mock('fhirclient', async () => {

0 commit comments

Comments
 (0)