11import { vi , beforeAll } from 'vitest' ;
22import { render , waitFor } from '@testing-library/react' ;
3- import { AboriginalForm } from './aboriginalFormUtils' ;
3+ import { AboriginalForm , terminologyServerUrl } from './aboriginalFormUtils' ;
44import { nonSnomedCondition , patient } from './aboriginalFormIntegrationData' ;
55import { findByLinkIdOrLabel , inputDate , inputText , invokeExtract , selectTab } from './testUtils' ;
66import { FhirResource } from 'fhir/r4' ;
77
8- vi . mock ( 'fhirclient' , ( ) => ( {
9- client : ( ) => ( { } )
10- } ) ) ;
8+ vi . mock ( 'fhirclient' , async ( ) => {
9+ const actual = await vi . importActual < typeof import ( 'fhirclient' ) > ( 'fhirclient' ) ;
10+ const mockedRequest = vi . fn ( ( ) => Promise . resolve ( { } ) ) ;
11+
12+ return {
13+ ...actual ,
14+ client : ( input : string | { serverUrl ?: string } ) => {
15+ const actualClient = actual . client ( input as never ) ;
16+ const serverUrl = typeof input === 'string' ? input : input ?. serverUrl ;
17+
18+ if ( serverUrl === terminologyServerUrl ) {
19+ return actualClient ;
20+ }
21+
22+ return {
23+ ...actualClient ,
24+ request : mockedRequest
25+ } ;
26+ }
27+ } ;
28+ } ) ;
1129
1230beforeAll ( ( ) => {
1331 globalThis . ResizeObserver = class ResizeObserver {
@@ -31,7 +49,7 @@ describe('Extraction workflow for', () => {
3149 await inputText ( newDiagnosisContainer , 'Condition' , 'Non-SNOMED condition' ) ;
3250 await inputDate ( newDiagnosisContainer , 'Onset date' , '10/10/2025' ) ;
3351 await inputText ( newDiagnosisContainer , 'Comment' , 'Test comment' ) ;
34-
52+
3553 const extractedBundle = await invokeExtract ( container , onExtractResult ) ;
3654 expect ( extractedBundle . entry ) . toHaveLength ( 1 ) ;
3755 // Verification status is not extracted
0 commit comments