Skip to content

Commit

Permalink
Update user management tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterMuriuki committed Feb 11, 2025
1 parent 0566bdc commit 290c103
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Object {
"active",
"userGroups",
"fhirCoreAppId",
"password",
]
}
userGroups={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,42 +61,7 @@ Object {
}
}
>
<InternalFormItem
hasFeedback={true}
label="Password"
name="password"
rules={
Array [
Object {
"message": "Password is required",
"required": true,
},
]
}
>
<Password />
</InternalFormItem>
<InternalFormItem
dependencies={
Array [
"password",
]
}
hasFeedback={true}
label="Confirm Password"
name="confirm"
rules={
Array [
Object {
"message": "Confirm Password is required",
"required": true,
},
[Function],
]
}
>
<Password />
</InternalFormItem>
<CredentialsFieldsRender />
<InternalFormItem
wrapperCol={
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,6 @@ export const createdUser = {
username: 'TestOne',
email: '[email protected]',
enabled: true,
credentials: [{ type: 'password', value: 'passwoord!!', temporary: false }],
attributes: { fhir_core_app_id: ['cha'] },
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { act } from 'react-dom/test-utils';
import { OPENSRP_API_BASE_URL } from '@opensrp/server-service';
import { Router } from 'react-router';
import { fhirCoreAppIdField, URL_USER } from '../../../../constants';
import { fhirCoreAppIdField, passwordField, URL_USER } from '../../../../constants';
import { UserFormProps } from '../types';
import { getFormValues, postPutPractitioner } from '../utils';
import { QueryClientProvider, QueryClient } from 'react-query';
Expand Down Expand Up @@ -61,7 +61,7 @@ jest.mock('antd', () => {
describe('components/forms/UserForm', () => {
const nonFhirFields = commonFhirFields.filter((field) => field !== fhirCoreAppIdField);
const props: UserFormProps = {
renderFields: nonFhirFields,
renderFields: nonFhirFields.filter((x) => x !== passwordField),
initialValues: defaultUserFormInitialValues,
keycloakBaseURL: 'https://keycloak-stage.smartregister.org/auth/admin/realms/opensrp-web-stage',
baseUrl: OPENSRP_API_BASE_URL,
Expand Down Expand Up @@ -156,7 +156,6 @@ describe('components/forms/UserForm', () => {
it('adds user', async () => {
const wrapper = mount(
<QueryClientProvider client={client}>
{' '}
<UserForm {...{ ...props }} />
</QueryClientProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ describe('forms/userForm', () => {
const usernameInput = document.querySelector('input#username') as Element;
userEvent.type(usernameInput, 'TestOne');

//set password
const passwordInput = screen.getByLabelText('Password');
userEvent.type(passwordInput, 'passwoord!!');
// confirm set password
const confirmPasswordInput = screen.getByLabelText('Confirm Password');
userEvent.type(confirmPasswordInput, 'passwoord!!');

// set user email
const emailInput = document.querySelector('input#email') as Element;
userEvent.type(emailInput, '[email protected]');
Expand Down

0 comments on commit 290c103

Please sign in to comment.