Skip to content

Commit

Permalink
Merge branch 'main' into 1470-bulk-upload-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki authored Nov 18, 2024
2 parents f31c3c4 + 4fee51b commit 998fcbe
Show file tree
Hide file tree
Showing 19 changed files with 416 additions and 438 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: General OpenSRP web FHIR.
description: Use this to Create issues the are FHIR related.
title: '[FHIR Road Map]: '
labels: [FHIR compatibility]
name: OpenSRP 1 web Support Request.
description: Use this to Create issues related to OpenSRP 1 (None FHIR Version).
title: '[OpenSRP 1 Support]: '
labels: [OpenSRP 1 Support]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
Thanks for taking the time to fill out this support request!
- type: textarea
id: issue_context
attributes:
Expand All @@ -20,19 +20,20 @@ body:
label: Issue Implemetation details?
description: Please write up the implementation details of the issue/feature.
validations:
required: true
required: false
- type: textarea
id: issue_acceptance
attributes:
label: Issue Acceptance criteria?
description: Please provide an acceptance criteria on the issue/feature?.
validations:
required: true
- type: textarea
id: issue_fhir_resources
- type: input
id: project_contact
attributes:
label: FHIR resources to be used?
description: Please provide a list of FHIR resources to be used for this issue/feature.
label: Project Contact
description: Who is the technical lead on this project?
placeholder: John Doe
validations:
required: false
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/opensrp-web-bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: General OpenSRP web Bug Report.
name: OpenSRP web Bug Report.
description: Use this to Report a bug experienced on an OpenSRP web instance.
title: '[Bug Report]: '
labels: [Bug Report]
Expand Down
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/opensrp-web-new-feature-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: OpenSRP web new Feature request.
description: Use this to request for a new feature that is not available in the current application.
title: '[New Feature Request]: '
labels: [New Feature Request]
name: OpenSRP web Enhancement/Feature request.
description: Use this to request for an enhancement or new feature that is not available in the current application.
title: '[Enhancement/Feature Request]: '
labels: [Feature Request]
body:
- type: markdown
attributes:
Expand All @@ -10,9 +10,9 @@ body:
- type: textarea
id: use_case
attributes:
label: Feature Use Case
label: Use case/Problem Statement
description: Give a detailed use case of how this feature is to be used?
placeholder: Needed to dispaly what teams practitioners are assigned to
placeholder: Needed to display what teams practitioners are assigned to
validations:
required: true
- type: textarea
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
FormFields,
PRACTITIONER_USER_TYPE_CODE,
SUPERVISOR_USER_TYPE_CODE,
commonFhirFields,
userTypeField,
FormFieldsKey,
} from '@opensrp/user-management';
import {
practitionerResourceType,
Expand Down Expand Up @@ -356,13 +359,20 @@ export const practitionerUpdater =
* @param props - component props
*/
export function CreateEditUser(props: CreateEditPropTypes) {
const extraFormFields = getConfig('projectCode') === 'giz' ? renderExtraFields : [];
let renderFormFields: FormFieldsKey[] = [...commonFhirFields];
const projectCode = getConfig('projectCode');
if (projectCode === 'giz') {
renderFormFields = [...commonFhirFields, ...renderExtraFields] as FormFieldsKey[];
} else if (projectCode === 'eusm') {
renderFormFields = renderFormFields.filter((field) => field !== userTypeField);
}

const baseCompProps = {
...props,
getPractitionerFun: getPractitioner,
getPractitionerRoleFun: getPractitionerRole,
postPutPractitionerFactory: practitionerUpdater,
extraFormFields: extraFormFields,
userFormRenderFields: renderFormFields,
};

return <BaseCreateEditUser {...baseCompProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Provider } from 'react-redux';
import { store } from '@opensrp/store';
import nock from 'nock';
import { cleanup, fireEvent, render } from '@testing-library/react';
import { waitFor } from '@testing-library/dom';
import { waitFor, within } from '@testing-library/dom';
import { createMemoryHistory } from 'history';
import { authenticateUser } from '@onaio/session-reducer';
import fetch from 'jest-fetch-mock';
Expand All @@ -35,6 +35,9 @@ import { practitionerResourceType, practitionerRoleResourceType } from '../../..
import { fetchKeycloakUsers } from '@opensrp/user-management';
import { history } from '@onaio/connected-reducer-registry';
import { opensrpI18nInstance } from '@opensrp/i18n';
import { setConfig } from '@opensrp/pkg-config';

setConfig('projectCode', 'giz');

jest.mock('fhirclient', () => {
return jest.requireActual('fhirclient/lib/entry/browser');
Expand Down Expand Up @@ -245,11 +248,11 @@ test('renders correctly for edit user', async () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
userEvent.type(usernameInput!, 'flopo');

// change mark as practitioner to tue
const yesMarkPractitioner = document.querySelectorAll('input[name="active"]')[0];
const enabledFieldGroup = document.querySelector('#active') as HTMLElement;
const yesMarkPractitioner = within(enabledFieldGroup).getByRole('radio', { name: /yes/i });
userEvent.click(yesMarkPractitioner);

const markSupervisor = document.querySelectorAll('input[name="userType"]')[1];
const markSupervisor = document.querySelector('input[value="supervisor"]') as HTMLElement;
userEvent.click(markSupervisor);

const submitButton = document.querySelector('button[type="submit"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const newPractitioner = {
name: [{ use: 'official', family: 'plotus', given: ['flotus', ''] }],
telecom: [{ system: 'email', value: '[email protected]' }],
};

export const newPractitionerRole = {
resourceType: 'PractitionerRole',
id: 'acb9d47e-7247-448f-be93-7a193a5312da',
Expand All @@ -88,7 +89,11 @@ export const newPractitionerRole = {
code: [
{
coding: [
{ system: 'http://snomed.info/sct', code: '236321002', display: 'Supervisor (occupation)' },
{
system: 'http://snomed.info/sct',
code: '405623001',
display: 'Assigned practitioner',
},
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ test('renders correctly for edit user', async () => {
const yesMarkPractitioner = document.querySelectorAll('input[name="active"]')[0];
userEvent.click(yesMarkPractitioner);

const markSupervisor = document.querySelectorAll('input[name="userType"]')[1];
const markSupervisor = document.querySelector('input[value="supervisor"]') as HTMLElement;
userEvent.click(markSupervisor);

const submitButton = document.querySelector('button[type="submit"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ test('renders correctly for new user', async () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
userEvent.type(usernameInput!, 'flopo');

const markSupervisor = document.querySelectorAll('input[name="userType"]')[1];
userEvent.click(markSupervisor);

const submitButton = document.querySelector('button[type="submit"]');

// find antd Select with id 'fhirCoreAppId' in the 'Form' component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export interface CreateEditUserProps {
getPractitionerFun: (baseUrl: string, userId: string) => Promise<Practitioner | IPractitioner>;
getPractitionerRoleFun?: (baseUrl: string, userId: string) => Promise<IPractitionerRole>;
postPutPractitionerFactory: UserFormProps['practitionerUpdaterFactory'];
extraFormFields: string[];
}

const getOpenSrpPractitioner = (baseUrl: string, userId: string) => {
Expand Down Expand Up @@ -95,7 +94,6 @@ const CreateEditUser: React.FC<CreateEditPropTypes> = (props: CreateEditPropType
getPractitionerFun,
postPutPractitionerFactory,
getPractitionerRoleFun,
extraFormFields,
} = props;

const userId = props.match.params[ROUTE_PARAM_USER_ID];
Expand Down Expand Up @@ -215,8 +213,6 @@ const CreateEditUser: React.FC<CreateEditPropTypes> = (props: CreateEditPropType
hiddenFields={userFormHiddenFields}
renderFields={userFormRenderFields}
practitionerUpdaterFactory={postPutPractitionerFactory}
isFHIRInstance={!!getPractitionerRoleFun}
extraFormFields={extraFormFields}
/>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`components/CreateEditUser loads edit user page without breaking if user is not a practitioner 1`] = `"Edit User | opensrpFirst NameLast NameEmailUsernameUser TypePractitionerSupervisorEnable userYesNoMark as PractitionerYesNoKeycloak User GroupAdminAdmin 2New Group Application IDSaveCancel"`;

exports[`components/CreateEditUser renders correctly 1`] = `
Object {
"children": <Col
span={24}
>
<UserForm
extraData={Object {}}
extraFormFields={Array []}
initialValues={
Object {
"active": true,
"contact": undefined,
"enabled": true,
"fhirCoreAppId": undefined,
"firstName": "",
Expand All @@ -25,9 +25,21 @@ Object {
"username": "",
}
}
isFHIRInstance={false}
keycloakBaseURL="https://keycloak-stage.smartregister.org/auth/admin/realms/opensrp-web-stage"
practitionerUpdaterFactory={[Function]}
renderFields={
Array [
"firstName",
"lastName",
"email",
"username",
"userType",
"enabled",
"active",
"userGroups",
"fhirCoreAppId",
]
}
userGroups={
Array [
Object {
Expand Down
Loading

0 comments on commit 998fcbe

Please sign in to comment.