Skip to content

Commit 7c9130e

Browse files
committed
fix test
1 parent 3b1f868 commit 7c9130e

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"ci:publish": "yarn workspaces foreach --all --topological --exclude @madiro/openmrs-esm-lime npm publish --access public --tag latest",
1212
"ci:prepublish": "yarn workspaces foreach --all --topological --exclude @madiro/openmrs-esm-lime npm publish --access public --tag next",
1313
"release": "yarn workspaces foreach --all --topological version",
14-
"verify": "turbo run lint typescript test --concurrency=1",
14+
"verify": "turbo run lint typescript test --color --concurrency=2",
1515
"test-e2e": "playwright test",
1616
"postinstall": "husky install"
1717
},

packages/esm-mental-health-app/src/utils/helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { fhirBaseUrl, openmrsFetch, restBaseUrl, userHasAccess, useSession } from '@openmrs/esm-framework';
1+
import { fhirBaseUrl, openmrsFetch, restBaseUrl, userHasAccess } from '@openmrs/esm-framework';
22

3-
export function useHasRequiredPrivilege(privilege: string): boolean {
4-
const session = useSession();
3+
export const useHasRequiredPrivilege = async (privilege: string): Promise<boolean> => {
4+
const response = await openmrsFetch(`${restBaseUrl}/session`, {
5+
method: 'GET',
6+
});
7+
const session = await response.json();
58
const hasPrivilege = userHasAccess(privilege, session?.user);
69
return !!hasPrivilege;
7-
}
10+
};
811

912
export function getTotalPatientEncounters(patientUuid: string, encounterTypeUuid: string, formName?: string) {
1013
let params = `encounterType=${encounterTypeUuid}&patient=${patientUuid}`;

packages/esm-nutrition-app/src/clinical-views/clinical-view-divider.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useEffect } from 'react';
2-
import { useTranslation } from 'react-i18next';
3-
import { Information } from '@carbon/react/icons';
4-
import { Tooltip } from '@carbon/react';
52
import { ExtensionSlot } from '@openmrs/esm-framework';
63
import { type DashboardGroupExtensionProps, registerNavGroup } from '@openmrs/esm-patient-common-lib';
4+
import { useTranslation } from 'react-i18next';
5+
import { Tooltip } from '@carbon/react';
6+
import { Information } from '@carbon/react/icons';
77
import styles from './clinical-view-divider.scss';
88

99
export const ClinicalViewDivider: React.FC<DashboardGroupExtensionProps> = ({ title, basePath }) => {

packages/esm-nutrition-app/src/utils/helpers.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import { openmrsFetch } from '@openmrs/esm-framework';
2-
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
1+
import { launchWorkspace, openmrsFetch } from '@openmrs/esm-framework';
32
import dayjs from 'dayjs';
43
import { launchClinicalViewForm, mealSymbol, getPatientEncounterDates } from './helpers';
54
import { dateFormat } from '../constants';
65

76
jest.mock('@openmrs/esm-patient-common-lib', () => ({
8-
launchPatientWorkspace: jest.fn(),
7+
launchWorkspace: jest.fn(),
98
}));
109

1110
jest.mock('@openmrs/esm-framework', () => ({
1211
openmrsFetch: jest.fn(),
12+
launchWorkspace: jest.fn(),
1313
restBaseUrl: 'http://localhost:8080/openmrs/ws/rest/v1',
1414
}));
1515

1616
describe('launchClinicalViewForm', () => {
17-
it('should call launchPatientWorkspace with correct parameters', () => {
17+
it('should call launchWorkspace with correct parameters', () => {
1818
const form = { name: 'Test Form' } as any;
1919
const patientUuid = 'patient-uuid';
2020
const onFormSave = jest.fn();
2121
const action = 'add';
2222

2323
launchClinicalViewForm(form, patientUuid, onFormSave, action);
2424

25-
expect(launchPatientWorkspace).toHaveBeenCalledWith('patient-form-entry-workspace', {
25+
expect(launchWorkspace).toHaveBeenCalledWith('patient-form-entry-workspace', {
2626
workspaceTitle: form.name,
2727
mutateForm: onFormSave,
2828
formInfo: {

packages/esm-nutrition-app/src/utils/helpers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
import { launchWorkspace, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
12
import { type FormSchema } from '@openmrs/esm-form-engine-lib';
2-
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
3-
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
43
import dayjs from 'dayjs';
54
import { dateFormat } from '../constants';
65

@@ -14,7 +13,7 @@ export function launchClinicalViewForm(
1413
encounterUuid?: string,
1514
workspaceWindowSize?: 'minimized' | 'maximized',
1615
) {
17-
launchPatientWorkspace('patient-form-entry-workspace', {
16+
launchWorkspace('patient-form-entry-workspace', {
1817
workspaceTitle: form.name,
1918
mutateForm: onFormSave,
2019
formInfo: {

0 commit comments

Comments
 (0)