Skip to content

Commit

Permalink
Export suites
Browse files Browse the repository at this point in the history
Ref: #7
  • Loading branch information
projkov committed Sep 10, 2024
1 parent ac67fe2 commit e6f9727
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 75 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"packages/client-testing-helpers",
"packages/client-testing-proxy-helpers",
"packages/fhir-validator",
"packages/app",
"packages/client-testing-demo-tests-standard",
"packages/client-testing-demo-tests-db"
"packages/client-testing-demo-tests-db",
"packages/app"
],
"scripts": {
"build": "nest build",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { patientDemoTestDB } from '@beda.software/client-testing-demo-tests-db';

patientDemoTestDB();

This file was deleted.

3 changes: 3 additions & 0 deletions packages/app/src/suites/1.0.0-ballot/Patient/patient.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { patientDemoTest } from '@beda.software/client-testing-demo-tests-standard';

patientDemoTest();
2 changes: 1 addition & 1 deletion packages/client-testing-demo-tests-db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "dist/index.js",
"scripts": {
"prepare": "tsc"
"prepare": "tsc || true"
},
"author": "",
"license": "ISC"
Expand Down
93 changes: 47 additions & 46 deletions packages/client-testing-demo-tests-db/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,58 @@ async function patientRequestCreateValidPatient(requests: Request[]): Promise<bo
return falseValidations.length === 0;
}

describe('Patients test', () => {
let requests: Request[];
export function patientDemoTestDB() {
describe('Patients test', () => {
let requests: Request[];

beforeAll(async () => {
requests = await global.RequestsRepository.find({
where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' },
relations: ['session'],
beforeAll(async () => {
requests = await global.RequestsRepository.find({
where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' },
relations: ['session'],
});
});
});

test('Should only have available interactions', async () => {
requests = await global.RequestsRepository.find({
where: {
session: { id: global.SESSION_ID },
resourceType: 'Patient',
fhirAction: Not(In(['READ', 'SEARCH', 'CREATE', 'UPDATE'])),
},
relations: ['session'],
test('Should only have available interactions', async () => {
requests = await global.RequestsRepository.find({
where: {
session: { id: global.SESSION_ID },
resourceType: 'Patient',
fhirAction: Not(In(['READ', 'SEARCH', 'CREATE', 'UPDATE'])),
},
relations: ['session'],
});
expect(requests.length).toBe(0);
});
expect(requests.length).toBe(0);
});

test('Should only have available search params', async () => {
const requests = await getRequestsWithUnavailableSearchParams(
global.RequestsRepository,
global.SESSION_ID,
'Patient',
['_id', 'birthdate', 'family', 'gender', 'identifier', 'name', 'gender-identity', 'indigenous-status'],
);
expect(requests.length).toBe(0);
});
test('Should only have available search params', async () => {
const requests = await getRequestsWithUnavailableSearchParams(
global.RequestsRepository,
global.SESSION_ID,
'Patient',
['_id', 'birthdate', 'family', 'gender', 'identifier', 'name', 'gender-identity', 'indigenous-status'],
);
expect(requests.length).toBe(0);
});

test('Should only have available combo search params', async () => {
const requests = await getRequestsWithUnavailableComboSearchParams(
global.RequestsRepository,
global.SESSION_ID,
'Patient',
[
['birthdate', 'family'],
['birthdate', 'name'],
['gender', 'name'],
['family', 'gender'],
],
);
expect(requests.length).toBe(0);
});
test('Should only have available combo search params', async () => {
const requests = await getRequestsWithUnavailableComboSearchParams(
global.RequestsRepository,
global.SESSION_ID,
'Patient',
[
['birthdate', 'family'],
['birthdate', 'name'],
['gender', 'name'],
['family', 'gender'],
],
);
expect(requests.length).toBe(0);
});

test('Should only have valid resources in CREATE action', async () => {
expect(
await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')),
).toBe(true);
test('Should only have valid resources in CREATE action', async () => {
expect(
await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')),
).toBe(true);
});
});
});

}
2 changes: 1 addition & 1 deletion packages/client-testing-demo-tests-standard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "dist/index.js",
"scripts": {
"prepare": "tsc"
"prepare": "tsc || true"
},
"author": "",
"license": "ISC"
Expand Down
47 changes: 24 additions & 23 deletions packages/client-testing-demo-tests-standard/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,33 @@ async function patientRequestCreateValidPatient(requests: Request[]): Promise<bo
return falseValidations.length === 0;
}

describe('Patients test (2nd version)', () => {
let requests: Request[];

beforeAll(async () => {
requests = await global.RequestsRepository.find({
where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' },
relations: ['session'],
export function patientDemoTest() {
describe('Patients test (2nd version)', () => {
let requests: Request[];

beforeAll(async () => {
requests = await global.RequestsRepository.find({
where: { session: { id: global.SESSION_ID }, resourceType: 'Patient' },
relations: ['session'],
});
});
});

test('Should only have available interactions', async () => {
expect(patientRequestsOnlyAvailableInteractionsExists(requests)).toBe(true);
});
test('Should only have available interactions', async () => {
expect(patientRequestsOnlyAvailableInteractionsExists(requests)).toBe(true);
});

test('Should only have available search params', async () => {
expect(patientRequestsOnlyAvailableSearchParamsExists(requests)).toBe(true);
});
test('Should only have available search params', async () => {
expect(patientRequestsOnlyAvailableSearchParamsExists(requests)).toBe(true);
});

test('Should only have available combo search params', async () => {
expect(patientRequestsOnlyAvailableComboSearchParamsExists(requests)).toBe(true);
});
test('Should only have available combo search params', async () => {
expect(patientRequestsOnlyAvailableComboSearchParamsExists(requests)).toBe(true);
});

test('Should only have valid resources in CREATE action', async () => {
expect(
await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')),
).toBe(true);
test('Should only have valid resources in CREATE action', async () => {
expect(
await patientRequestCreateValidPatient(requests.filter((request) => request.fhirAction === 'CREATE')),
).toBe(true);
});
});
});

}

0 comments on commit e6f9727

Please sign in to comment.