Skip to content

Commit

Permalink
Remove testing and proxy helpers
Browse files Browse the repository at this point in the history
Ref: #7
  • Loading branch information
projkov committed Sep 10, 2024
1 parent e6f9727 commit a2bea0b
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 125 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"private": true,
"license": "UNLICENSED",
"workspaces": [
"packages/client-testing-helpers",
"packages/client-testing-proxy-helpers",
"packages/fhir-validator",
"packages/client-testing-demo-tests-standard",
"packages/client-testing-demo-tests-db",
Expand Down
4 changes: 1 addition & 3 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
"rxjs": "^7.8.1",
"swagger-ui-express": "^5.0.1",
"typeorm": "^0.3.20",
"@beda.software/client-testing-helpers": "0.0.1",
"@beda.software/fhir-validator": "0.0.1",
"@beda.software/client-testing-proxy-helpers": "0.0.1"
"@beda.software/fhir-validator": "0.0.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/modules/proxyapp/proxyapp.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { All, Controller, Param, Req, Res } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiParam } from '@nestjs/swagger';
import { captureResponseBody } from '@beda.software/client-testing-proxy-helpers';
import { RequestService } from '../requests/request.service';
import { SessionService } from '../sessions/session.service';
import { Request, Response } from 'express';
import { createRequestObject } from '../../utils/data';
import { captureResponseBody } from '../../utils/proxyHelpers';

@ApiTags('proxy')
@Controller('proxy')
Expand Down
18 changes: 17 additions & 1 deletion packages/app/src/utils/data.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import { createTestListObject } from './data';
import { createTestListObject, getFHIRAction } from './data';

describe('getFHIRAction', () => {
test.each([
['READ', 'GET', '/Patient/123'],
['VREAD', 'GET', '/Patient/123/_history/1'],
['CREATE', 'POST', '/Patient'],
['UPDATE', 'PUT', '/Patient/123'],
['DELETE', 'DELETE', '/Patient/123'],
['SEARCH', 'GET', '/Patient?name=Smith'],
['SEARCH', 'POST', '/Patient/_search'],
['HISTORY', 'GET', '/Patient/_history'],
['PATCH', 'PATCH', '/Patient/123'],
])('should return correct FHIR action for %s', (expectedAction, method, url) => {
expect(getFHIRAction(method, url)).toBe(expectedAction);
});
});

describe('Data utilities', () => {
it('Should return correct test list from test result object', async () => {
Expand Down
35 changes: 34 additions & 1 deletion packages/app/src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,40 @@ import { parseSearchRequest } from '@medplum/core';
import { Request, Response } from 'express';
import { CreateRequestDto } from '../modules/requests/request.dto';
import { Session } from '../modules/sessions/session.entity';
import { getFHIRAction } from '@beda.software/client-testing-helpers';

export function getFHIRAction(requestType: Request['method'], url: Request['url']) {
const mapSimpleRequest = {
DELETE: 'DELETE',
PATCH: 'PATCH',
PUT: 'UPDATE',
};

if (Object.keys(mapSimpleRequest).includes(requestType)) {
return mapSimpleRequest[requestType];
}

if (requestType === 'POST') {
if (url.includes('_search')) {
return 'SEARCH';
}
return 'CREATE';
}

if (requestType === 'GET') {
if (url.includes('_history')) {
if (url.match(/\/_history\/\d+$/)) {
return 'VREAD';
}
return 'HISTORY';
}

if (url.includes('?')) {
return 'SEARCH';
}

return 'READ';
}
}

export function createRequestObject(
id: string,
Expand Down
File renamed without changes.
11 changes: 0 additions & 11 deletions packages/client-testing-helpers/package.json

This file was deleted.

35 changes: 0 additions & 35 deletions packages/client-testing-helpers/src/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions packages/client-testing-helpers/src/tests.spec.ts

This file was deleted.

21 changes: 0 additions & 21 deletions packages/client-testing-helpers/tsconfig.json

This file was deleted.

11 changes: 0 additions & 11 deletions packages/client-testing-proxy-helpers/package.json

This file was deleted.

22 changes: 0 additions & 22 deletions packages/client-testing-proxy-helpers/tsconfig.json

This file was deleted.

0 comments on commit a2bea0b

Please sign in to comment.