Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build_test_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ jobs:
- name: Build workspace packages
run: |
npm run build -w packages/sdc-populate
npm run build -w packages/testing-toolkit

- name: Install Playwright browsers
run: npx playwright install --with-deps
Expand Down
5 changes: 0 additions & 5 deletions apps/smart-forms-app/jest.config.js

This file was deleted.

73 changes: 0 additions & 73 deletions apps/smart-forms-app/jest.config.ts

This file was deleted.

4 changes: 3 additions & 1 deletion apps/smart-forms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "vite",
"start": "vite",
"build": "tsc && CI=false vite build",
"test": "TZ=Australia/Sydney jest --config ./jest.config.ts --coverage",
"test": "vitest run",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be
TZ=Australia/Sydney vitest run for backward compatibility

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

"preview": "vite preview --port 4173",
"playwright": "npx playwright test",
"playwright-ui": "npx playwright test --ui"
Expand Down Expand Up @@ -95,13 +95,15 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"eslint-plugin-storybook": "^9.1.6",
"expect-type": "^1.2.2",
"jest": "^29.7.0",
"jsdom": "^26.1.0",
"prettier": "^3.6.2",
"ts-jest": "^29.4.2",
"typescript": "^5.8.3",
"vite": "^5.4.19",
"vite-plugin-svgr": "^4.3.0",
"vitest": "^3.2.4",
"yui-lint": "^0.2.0"
},
"eslintConfig": {
Expand Down
74 changes: 74 additions & 0 deletions apps/smart-forms-app/src/test/questionnaireRenderer.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { render } from '@testing-library/react';
import { evaluate } from 'fhirpath';
import type { Questionnaire, QuestionnaireResponse } from 'fhir/r4';
import aboriginalForm from '../data/resources/Questionnaire/Questionnaire-AboriginalTorresStraitIslanderHealthCheckAssembled-0.1.0.json';
import { QueryClientProvider } from '@tanstack/react-query';
import { testUtils } from '@aehrc/smart-forms-renderer';
import { vi } from 'vitest';

import {
BaseRenderer,
questionnaireResponseStore,
RendererThemeProvider,
useBuildForm,
useRendererQueryClient
} from '@aehrc/smart-forms-renderer';

const { inputText, inputDate, inputInteger, checkRadioOption } = testUtils;
vi.mock('fhirclient', () => ({
client: () => ({
request: vi.fn(() => Promise.resolve({}))
})
}));

export async function getAnswerRecursiveByLabel(text: string) {
const qr = questionnaireResponseStore.getState().updatableResponse;
console.log(1);
const result = await evaluate(
qr,
`QuestionnaireResponse.repeat(item).where((text = '${text}')).answer`
);
return result;
}

test('behaviour-test-example', async () => {
const form = aboriginalForm as Questionnaire;

const { container } = render(<BuildFormWrapperForStorybook questionnaire={form} />);
await new Promise((resolve) => setTimeout(resolve, 1000));
expect(container.innerHTML).toContain('Patient Details');
Comment thread
ruscoder marked this conversation as resolved.

await inputText(container, 'Name', 'David');
await inputDate(container, 'Date of birth', '11/11/2021');
await inputInteger(container, 'Age', 24);
await checkRadioOption(container, 'Registered for NDIS', 'Yes');
await inputText(container, 'NDIS Number', 'Some text');
});

interface BuildFormWrapperForStorybookProps {
questionnaire: Questionnaire;
questionnaireResponse?: QuestionnaireResponse;
}

function BuildFormWrapperForStorybook(props: BuildFormWrapperForStorybookProps) {
const { questionnaire, questionnaireResponse } = props;
const queryClient = useRendererQueryClient();
const isBuilding = useBuildForm(
questionnaire,
questionnaireResponse,
undefined,
'https://r4.ontoserver.csiro.au/fhir'
);

if (isBuilding) {
return <div>Loading...</div>;
}

return (
<RendererThemeProvider>
<QueryClientProvider client={queryClient}>
<BaseRenderer />
</QueryClientProvider>
</RendererThemeProvider>
);
}
1 change: 1 addition & 0 deletions apps/smart-forms-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"types": ["vitest", "node"],
"target": "ESNext",
"module": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
Expand Down
16 changes: 16 additions & 0 deletions apps/smart-forms-app/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
globals: true,
testTimeout:40000,
environment: 'jsdom',
include: ['**/__tests__/**/*.{test,spec}.{js,ts,jsx,tsx}', '**/*.{test,spec}.{js,ts,jsx,tsx}'],
exclude: ['**/e2e/**', '**/node_modules/**'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: ['**/e2e/**', '**/node_modules/**'],
},
},
});
Loading
Loading