@argusoft/medplat-app-shell 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +139 -141
- package/src/GlobalErrorBoundary.jsx +31 -0
- package/src/SilentErrorFallback.jsx +68 -0
- package/src/TrackingProviderWrapper.jsx +40 -0
- package/src/_tests_/__mocks__/MockTranslationProvider.jsx +21 -0
- package/src/_tests_/__mocks__/ckeditor.js +45 -0
- package/src/_tests_/__mocks__/fileMock.js +1 -0
- package/src/_tests_/__mocks__/useranalytics.js +5 -0
- package/src/_tests_/views/components/Dashboard/DashboardUI.test.jsx +137 -0
- package/src/_tests_/views/components/Dashboard/DashboardUIMock.js +877 -0
- package/src/_tests_/views/components/ForgotPassword/ForgotPassword.test.jsx +314 -0
- package/src/_tests_/views/components/LocationDirective/LocationDirective.test.jsx.disable +229 -0
- package/src/_tests_/views/components/LocationDirective/mockLocationDirective.js +810 -0
- package/src/_tests_/views/components/LocationType/MockLocationType.js +42259 -0
- package/src/_tests_/views/components/LocationType/addlocationtype.test.jsx.disable +276 -0
- package/src/_tests_/views/components/LocationType/editlocationtype.test.jsx.disable +262 -0
- package/src/_tests_/views/components/LocationType/locationtype.test.jsx.disable +148 -0
- package/src/_tests_/views/components/Profile/UpdateProfileModalData.js +4396 -0
- package/src/_tests_/views/components/Profile/updateprofilemodal.test.jsx +282 -0
- package/src/_tests_/views/components/SideBar/MockSideBar.js +1379 -0
- package/src/_tests_/views/components/SideBar/SideBar.test.jsx +98 -0
- package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/AddManageSystemConfig.test.jsx.disable +164 -0
- package/src/_tests_/views/components/SystemConfig/ManageSystemConfig/UpdateManageSystemConfig.test.jsx.disable +157 -0
- package/src/_tests_/views/components/SystemConfig/MockSystemConfig.js +1280 -0
- package/src/_tests_/views/components/SystemConfig/SystemConfig.test.jsx.disable +165 -0
- package/src/_tests_/views/components/login/Login.test.jsx +276 -0
- package/src/_tests_/views/components/login/MockAuthorise.js +2414 -0
- package/src/_tests_/views/components/login/ServiceResponse.js +595 -0
- package/src/_tests_/views/components/user/MockManageUser.js +7965 -0
- package/src/_tests_/views/components/user/manageuser.test.jsx.disable +989 -0
- package/src/_tests_/views/components/user/mockUsersData.js +582 -0
- package/src/assets/img/OASISLogin.png +0 -0
- package/src/assets/img/bahaarNew.png +0 -0
- package/src/assets/img/dnhdd4K.png +0 -0
- package/src/assets/img/govtofup.png +0 -0
- package/src/assets/img/sewarural4K.png +0 -0
- package/src/assets/img/techo4K.png +0 -0
- package/src/assets/img/up4K.png +0 -0
- package/src/common/HolidayList.jsx +573 -0
- package/src/common/MalaciaousInputUtil.js +23 -0
- package/src/common/SafeHtml.jsx +17 -0
- package/src/common/VersionManager.jsx +109 -0
- package/src/common/constants/PerformanceDashboard.js +514 -0
- package/src/common/constants/app.constant.js +781 -0
- package/src/common/constants/cccVerificationConstants.js +18 -0
- package/src/common/constants/fhsrConstant.js +33 -0
- package/src/common/constants/gvk-verification.constant.js +76 -0
- package/src/common/constants/search.constant.js +23 -0
- package/src/common/constants/teleconsulatationConstant.jsx +1339 -0
- package/src/common/directives/SearchTemplate.jsx +784 -0
- package/src/common/directives/SearchTemplate.scss +14 -0
- package/src/common/dynamicView/DynamicView.jsx +353 -0
- package/src/common/dynamicView/InputFieldComponent.jsx +1501 -0
- package/src/common/dynamicView/InputViewComponent.jsx +298 -0
- package/src/common/dynamicView/InputViewComponent.scss +15 -0
- package/src/common/env.js +5 -0
- package/src/common/filters/locationNameFilter.js +26 -0
- package/src/common/fontAwesomeIcons/FontAwesomeIcons.jsx +27 -0
- package/src/common/fontAwesomeIcons/FontAwesomeIconsNames.js +1968 -0
- package/src/common/fontPreferences/fontSizeProvider.jsx +34 -0
- package/src/common/fontPreferences/fontSizeSelector.jsx +116 -0
- package/src/common/getAssignedFeature/getAssignedFeature.js +32 -0
- package/src/common/interceptors/AxiosInterceptor.js +216 -0
- package/src/common/languageTranslator/TranslationContext.js +5 -0
- package/src/common/languageTranslator/TranslationProvider.jsx +24 -0
- package/src/common/languageTranslator/i18n.js +49 -0
- package/src/common/services/AuthenticateService.js +116 -0
- package/src/common/services/DownloadFile.js +35 -0
- package/src/common/services/ForgotPassword.js +18 -0
- package/src/common/services/FormConfiguratorService.js +195 -0
- package/src/common/services/GlobalApis.js +84 -0
- package/src/common/services/InterceptorNavigationService.js +17 -0
- package/src/common/services/LocationService.js +65 -0
- package/src/common/services/LocationType.js +11 -0
- package/src/common/services/QueryBuilder.js +36 -0
- package/src/common/services/Roles.js +28 -0
- package/src/common/services/SyncWithServer.js +15 -0
- package/src/common/services/SystemConfig.js +15 -0
- package/src/common/services/TranslationService.js +70 -0
- package/src/common/services/TwoFactorService.js +7 -0
- package/src/common/services/Users.js +91 -0
- package/src/common/services/Webtasks.js +27 -0
- package/src/common/services/util/Convert-pad-data-to-API-format.jsx +167 -0
- package/src/common/services/util/Convert-to-UI-format.jsx +82 -0
- package/src/common/services/util/EmptyPrescriptionPadData.jsx +11 -0
- package/src/common/services/util/GeneralUtil.js +456 -0
- package/src/common/services/util/Prescription-pad-util.js +339 -0
- package/src/common/services/util/PrescriptionPadData.js +67 -0
- package/src/common/services/util/PrescriptionpadCommonUtil.js +96 -0
- package/src/common/services/util/ReportFieldUtil.jsx +398 -0
- package/src/common/services/util/WebSocketContext.jsx +261 -0
- package/src/common/syncWithServer/SyncWithServerDialog.jsx +170 -0
- package/src/common/syncWithServer/SyncWithServerDialogSkeleton.jsx +67 -0
- package/src/common/tests/CustomWrapper.jsx +49 -0
- package/src/common/tests/TranslationWrapper.jsx +38 -0
- package/src/common/themeProvider/ColorInputs.jsx +97 -0
- package/src/common/themeProvider/EditableColorInput.jsx +128 -0
- package/src/common/themeProvider/ThemeEditor.jsx +319 -0
- package/src/common/themeProvider/ThemeProvider.jsx +210 -0
- package/src/common/themeProvider/themeConfig.js +558 -0
- package/src/common/toaster/toaster.jsx +30 -0
- package/src/firebaseConfig.js +24 -0
- package/src/global.scss +221 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/hooks/useAESEncryption.js +56 -0
- package/src/hooks/useCaching.js +43 -0
- package/src/hooks/useDebounce.js +34 -0
- package/src/hooks/useDebounceFn.js +50 -0
- package/src/hooks/useDownloadPdf.js +358 -0
- package/src/hooks/useDownloadXlsx.js +55 -0
- package/src/hooks/useListValueFieldValues.js +30 -0
- package/src/hooks/useLocationHierarchies.js +63 -0
- package/src/hooks/useLocationHierarchyTranslate.js +16 -0
- package/src/hooks/useOnline.js +27 -0
- package/src/hooks/usePagination.js +63 -0
- package/src/hooks/useRefreshToken.js +87 -0
- package/src/hooks/useScript.js +25 -0
- package/src/hooks/useStopwatch.js +75 -0
- package/src/hooks/useTrackEvent.js +22 -0
- package/src/hooks/useWebAudioRecorder.js +115 -0
- package/src/layout/LoaderComponet.jsx +22 -0
- package/src/layout/LoaderContext.jsx +29 -0
- package/src/layout/mainLayout/AdaptiveZoom.jsx +27 -0
- package/src/layout/mainLayout/Chatbot.jsx +243 -0
- package/src/layout/mainLayout/Layout.jsx +445 -0
- package/src/layout/mainLayout/Profile/UpdateProfileModal.jsx +684 -0
- package/src/layout/mainLayout/header/LogoutModal.jsx +131 -0
- package/src/layout/mainLayout/header/Navbar.jsx +1677 -0
- package/src/layout/mainLayout/header/Navbar.scss +4 -0
- package/src/layout/mainLayout/header/index.js +0 -0
- package/src/layout/mainLayout/sidebar/SideBar.jsx +1402 -0
- package/src/layout/mainLayout/sidebar/Sidebar.css +159 -0
- package/src/layout/mainLayout/sidebar/index.js +0 -0
- package/src/logo.svg +1 -0
- package/src/reportWebVitals.js +13 -0
- package/src/setupFirebaseMessaging.js +28 -0
- package/src/setupTests.js +8 -0
- package/src/store/actions/AuthenticationActions.js +0 -0
- package/src/store/actions/ReportsActions.js +0 -0
- package/src/store/actions/TranslationAction.js +0 -0
- package/src/store/index.js +8 -0
- package/src/store/reducer.js +46 -0
- package/src/store/reducers/AuthenticationReducer.js +50 -0
- package/src/store/reducers/CalendarEventReducer.js +41 -0
- package/src/store/reducers/ConditionClipboardReducer.js +45 -0
- package/src/store/reducers/FeatureReducer.js +27 -0
- package/src/store/reducers/FormConfiguratorReducer.js +38 -0
- package/src/store/reducers/LoadingReducer.js +20 -0
- package/src/store/reducers/MembersAuthenticationReducer.js +28 -0
- package/src/store/reducers/PrescriptionPadReducer.js +329 -0
- package/src/store/reducers/QuestionaireReducer.js +29 -0
- package/src/store/reducers/ReportsReducer.js +24 -0
- package/src/store/reducers/SkeletonReducer.js +20 -0
- package/src/store/reducers/ThemeReducer.js +106 -0
- package/src/store/reducers/TranslationReducer.js +126 -0
- package/src/store/reducers/dashboardEditorSlice.js +77 -0
- package/src/store/reducers/districtHealthDashboardSlice.js +58 -0
- package/src/store/reducers/immunizationSlice.js +234 -0
- package/src/store/slices/dashboardPagesSlice.js +51 -0
- package/src/utils/.gitkeep +0 -0
- package/src/utils/FormConstants.js +2629 -0
- package/src/utils/GujaratTopoChart.jsx +483 -0
- package/src/utils/UUIDgenerator.js +8 -0
- package/src/utils/appointment-utils/appointment-utils.js +123 -0
- package/src/utils/feature.js +42 -0
- package/src/utils/getThemeColor.js +12 -0
- package/src/utils/localStorageHelper.js +11 -0
- package/src/utils/notifications/enable-push-notifications.js +27 -0
- package/src/utils/resolveAppliedStyle.js +11 -0
- package/src/utils/themeConfigs.js +1483 -0
- package/src/views/custom-components/.gitkeep +0 -0
- package/src/views/custom-components/AgIconButton/RIf.jsx +14 -0
- package/src/views/custom-components/AgIconButton/button.jsx +108 -0
- package/src/views/custom-components/AgIconButton/waterDrop.jsx +95 -0
- package/src/views/custom-components/AgIconButton/waterDrop.scss +37 -0
- package/src/views/custom-components/AlertPlaceholder.jsx +32 -0
- package/src/views/custom-components/AllFaIconsSelector.jsx +56 -0
- package/src/views/custom-components/CkEditor/CkEditor.js +102 -0
- package/src/views/custom-components/CustomAccordion.jsx +72 -0
- package/src/views/custom-components/CustomActionIcons.jsx +118 -0
- package/src/views/custom-components/CustomAutoComplete.jsx +188 -0
- package/src/views/custom-components/CustomCheckBox.jsx +60 -0
- package/src/views/custom-components/CustomConfirmationModal.jsx +118 -0
- package/src/views/custom-components/CustomCountrySelect.jsx +129 -0
- package/src/views/custom-components/CustomDatePicker.jsx +122 -0
- package/src/views/custom-components/CustomDropdown.jsx +191 -0
- package/src/views/custom-components/CustomFileUpload.jsx +387 -0
- package/src/views/custom-components/CustomFullCalendar.jsx +514 -0
- package/src/views/custom-components/CustomInfiniteScroll.jsx +126 -0
- package/src/views/custom-components/CustomRadioComponent.jsx +65 -0
- package/src/views/custom-components/CustomStatsComponent.jsx +114 -0
- package/src/views/custom-components/CustomSvgUpload.jsx +170 -0
- package/src/views/custom-components/CustomSwitch.jsx +37 -0
- package/src/views/custom-components/CustomTabPanel.jsx +19 -0
- package/src/views/custom-components/CustomTextArea.jsx +62 -0
- package/src/views/custom-components/CustomTextArea.scss +27 -0
- package/src/views/custom-components/CustomTextField.jsx +116 -0
- package/src/views/custom-components/CustomToggleSwitch.jsx +138 -0
- package/src/views/custom-components/CustomTooltip.jsx +51 -0
- package/src/views/custom-components/CustomZoomImage.jsx +134 -0
- package/src/views/custom-components/CustomizedTable/CustomizedTableV2.jsx +1407 -0
- package/src/views/custom-components/CustomizedTable/VirtualizeTableBody.jsx +295 -0
- package/src/views/custom-components/CustomizedTable/helper.jsx +159 -0
- package/src/views/custom-components/CustomizedTable.jsx +532 -0
- package/src/views/custom-components/EditInputField.jsx +174 -0
- package/src/views/custom-components/FieldDescription.jsx +22 -0
- package/src/views/custom-components/FileDisplayComponent.jsx +138 -0
- package/src/views/custom-components/FormItem.jsx +53 -0
- package/src/views/custom-components/GenericChart.jsx +80 -0
- package/src/views/custom-components/InfoBadge.jsx +60 -0
- package/src/views/custom-components/PostgresEditor.jsx +801 -0
- package/src/views/custom-components/ResizableEditAutocompleteField.jsx +249 -0
- package/src/views/custom-components/ResizableEditInputField.jsx +215 -0
- package/src/views/custom-components/ResizeableEditSelectField.jsx +197 -0
- package/src/views/custom-components/SideOverlay.jsx +113 -0
- package/src/views/custom-components/SideOverlay.scss +42 -0
- package/src/views/custom-components/calendar.scss +571 -0
- package/src/views/feature-components/.gitkeep +0 -0
- package/src/views/feature-components/Dashboard/DashboardUI.jsx +1043 -0
- package/src/views/feature-components/Dashboard/DhnddModal/AshaDataQualityVerificationModal.jsx +278 -0
- package/src/views/feature-components/Dashboard/PinFeatureModal.jsx +143 -0
- package/src/views/feature-components/Dashboard/QuickLinks.jsx +163 -0
- package/src/views/feature-components/Dashboard/Taskbar.jsx +56 -0
- package/src/views/feature-components/Dashboard/WebtasksFilterForm.jsx +109 -0
- package/src/views/feature-components/Dashboard/WidgetCard.jsx +161 -0
- package/src/views/feature-components/Dashboard/actionModal.jsx +263 -0
- package/src/views/feature-components/Dashboard/ekavachModal/HealthWorkerIncorrectDetailsModal.jsx +332 -0
- package/src/views/feature-components/Dashboard/ekavachModal/MoMaternalDeathVerifcationModal.jsx +275 -0
- package/src/views/feature-components/Dashboard/ekavachModal/MoVerficationForChildScreeningMoadal.jsx +566 -0
- package/src/views/feature-components/FeatureUsageAnalytics/FeatureUsageAnalytics.jsx +989 -0
- package/src/views/feature-components/Features/NewServerManagement.jsx +217 -0
- package/src/views/feature-components/Features/ServerManagement.scss +120 -0
- package/src/views/feature-components/ForgotPassword/ForgotPassword.jsx +226 -0
- package/src/views/feature-components/LocationDirective/LocationDirective.jsx +992 -0
- package/src/views/feature-components/LocationDirective/LocationDirectiveV2.jsx +909 -0
- package/src/views/feature-components/NotFound.jsx +66 -0
- package/src/views/feature-components/Onboarding/Onboarding.jsx +1400 -0
- package/src/views/feature-components/Skeletons.js +115 -0
- package/src/views/feature-components/Unauthorized.jsx +48 -0
- package/src/views/feature-components/VerifyRoute.jsx +88 -0
- package/src/views/feature-components/YearlyRecap/YearlyRecap.jsx +357 -0
- package/src/views/feature-components/YearlyRecap/components/RecapSlide.jsx +183 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationContext.js +5 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/TranslationProvider.jsx +26 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/i18n.js +46 -0
- package/src/views/feature-components/YearlyRecap/languageTranslator/translations.json +167 -0
- package/src/views/feature-components/YearlyRecap/slides/IntroSlide.jsx +233 -0
- package/src/views/feature-components/YearlyRecap/slides/MaternalHealthSlide.jsx +146 -0
- package/src/views/feature-components/YearlyRecap/slides/MetricSlide.jsx +227 -0
- package/src/views/feature-components/YearlyRecap/slides/OutroSlide.jsx +701 -0
- package/src/views/feature-components/YearlyRecap/slides/ReachSlide.jsx +273 -0
- package/src/views/feature-components/login/Login.jsx +840 -0
- package/src/views/feature-components/login/Login.scss +154 -0
- package/src/views/feature-components/login/LoginConfigurator.jsx +1149 -0
- package/src/views/feature-components/login/TwoFactorSetupModal.jsx +411 -0
- package/src/views/feature-components/login/simplifyMenu.js +45 -0
- package/src/views/feature-components/system-config/ManageSystemConfigs.jsx +284 -0
- package/src/views/feature-components/system-config/SystemConfig.jsx +299 -0
- package/src/views/feature-components/users/ChangePasswordModal.jsx +243 -0
- package/src/views/feature-components/users/PasswordField.jsx +56 -0
- package/dist/index.css +0 -1
- package/dist/index.js +0 -32001
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
import React, { act } from 'react';
|
|
2
|
+
|
|
3
|
+
import { screen, fireEvent, waitFor, cleanup, render } from '@testing-library/react';
|
|
4
|
+
import ManageUser from '@/views/feature-components/users/ManageUser.jsx';
|
|
5
|
+
import {
|
|
6
|
+
getRoles,
|
|
7
|
+
getRoleDetails,
|
|
8
|
+
getPreferredLanguage,
|
|
9
|
+
retrieveInfraByRoleLocation,
|
|
10
|
+
updateUser,
|
|
11
|
+
checkUserAction,
|
|
12
|
+
getLocationTypes,
|
|
13
|
+
getUserDetails,
|
|
14
|
+
validateAOI,
|
|
15
|
+
} from '@/common/services/Users.js';
|
|
16
|
+
import { useSelector } from 'react-redux';
|
|
17
|
+
|
|
18
|
+
import { getAssignedFeatures } from '@/utils/feature.js';
|
|
19
|
+
import {
|
|
20
|
+
mockArgusAdminResponse,
|
|
21
|
+
mockArgusAdminRetrieveHealthInfraResponse,
|
|
22
|
+
mockASHARoleDetailsResponse,
|
|
23
|
+
mockGetAssignedFeatureResponse,
|
|
24
|
+
mockGetRoleDetailsResponse,
|
|
25
|
+
mockGetRolesResponse,
|
|
26
|
+
mockGetUserDetailsResponse,
|
|
27
|
+
mockPrefferedLanguageResponse,
|
|
28
|
+
mockRetrieveHealthInfraResponse,
|
|
29
|
+
} from '@/_tests_/views/components/user/MockManageUser.js';
|
|
30
|
+
import { mockLoggeinUser } from '@/_tests_/views/components/features/mockFeaturesData';
|
|
31
|
+
import MockTranslationProvider from '@/_tests_/__mocks__/MockTranslationProvider';
|
|
32
|
+
import { MemoryRouter, Route, Routes } from 'react-router';
|
|
33
|
+
|
|
34
|
+
// Mocking service functions
|
|
35
|
+
jest.mock('../../../../common/services/Users', () => ({
|
|
36
|
+
getRoles: jest.fn(),
|
|
37
|
+
getRoleDetails: jest.fn(),
|
|
38
|
+
getUserDetails: jest.fn(),
|
|
39
|
+
getPreferredLanguage: jest.fn(),
|
|
40
|
+
retrieveInfraByRoleLocation: jest.fn(),
|
|
41
|
+
updateUser: jest.fn(),
|
|
42
|
+
checkUserAction: jest.fn(),
|
|
43
|
+
getResource: jest.fn(),
|
|
44
|
+
getLocationTypes: jest.fn(),
|
|
45
|
+
validateHealthInfra: jest.fn(),
|
|
46
|
+
validateAOI: jest.fn(),
|
|
47
|
+
}));
|
|
48
|
+
jest.mock('../../../../common/services/LocationType', () => ({
|
|
49
|
+
retriveLocationType: jest.fn(),
|
|
50
|
+
}));
|
|
51
|
+
jest.mock('../../../../common/services/LocationService', () => ({
|
|
52
|
+
retrieveNextLevel: jest.fn(),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
jest.mock('../../../../utils/feature', () => ({
|
|
56
|
+
getAssignedFeatures: jest.fn(),
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
jest.mock('../../../../common/services/AuthenticateService', () => ({
|
|
60
|
+
getKeyAndIV: jest.fn(),
|
|
61
|
+
loginService: jest.fn(),
|
|
62
|
+
getLoggedInUser: jest.fn(),
|
|
63
|
+
getFeatures: jest.fn(),
|
|
64
|
+
}));
|
|
65
|
+
jest.mock('react-i18next', () => ({
|
|
66
|
+
useTranslation: () => ({
|
|
67
|
+
t: (key) => key,
|
|
68
|
+
i18n: { changeLanguage: () => new Promise(() => {}) },
|
|
69
|
+
}),
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
jest.mock('react-redux', () => ({
|
|
73
|
+
useSelector: jest.fn(),
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const mockedUseNavigate = jest.fn();
|
|
77
|
+
jest.mock('react-router-dom', () => ({
|
|
78
|
+
...jest.requireActual('react-router-dom'),
|
|
79
|
+
useNavigate: () => mockedUseNavigate,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
describe('User Component', () => {
|
|
83
|
+
const renderComponent = async (params = {}) => {
|
|
84
|
+
await act(async () => {
|
|
85
|
+
const url = params.id ? `${params.url}/${params.id}` : params.url;
|
|
86
|
+
const routePath = params.id ? `${params.url}/:id` : params.url;
|
|
87
|
+
render(
|
|
88
|
+
<MockTranslationProvider>
|
|
89
|
+
<MemoryRouter initialEntries={[url]} future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
|
90
|
+
<Routes>
|
|
91
|
+
<Route path={routePath} element={<ManageUser />} />
|
|
92
|
+
</Routes>
|
|
93
|
+
</MemoryRouter>
|
|
94
|
+
</MockTranslationProvider>
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
// await customRender(<ManageUser />, params);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
beforeEach(async () => {
|
|
101
|
+
// Set up mock implementations for service functions
|
|
102
|
+
useSelector.mockImplementation((callback) => callback({ Authenticate: { user: mockLoggeinUser } }));
|
|
103
|
+
getRoles.mockResolvedValue(mockGetRolesResponse);
|
|
104
|
+
getAssignedFeatures.mockResolvedValue(mockGetAssignedFeatureResponse);
|
|
105
|
+
getRoleDetails.mockResolvedValue(mockGetRoleDetailsResponse);
|
|
106
|
+
getPreferredLanguage.mockResolvedValue(mockPrefferedLanguageResponse);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
afterEach(() => {
|
|
110
|
+
jest.clearAllMocks();
|
|
111
|
+
cleanup();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe('Add User', () => {
|
|
115
|
+
beforeEach(async () => {
|
|
116
|
+
await act(async () => {
|
|
117
|
+
await renderComponent({ url: '/ui/manage/user' });
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
it('renders the User component in ADD mode', async () => {
|
|
121
|
+
expect(screen.getByTestId('ManageUserForm')).toBeInTheDocument();
|
|
122
|
+
await waitFor(() => {
|
|
123
|
+
expect(screen.getByTestId('form-header')).toHaveTextContent('Add User');
|
|
124
|
+
expect(getUserDetails).not.toHaveBeenCalled();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
it('Initial API Calls For add Mode', async () => {
|
|
128
|
+
await waitFor(() => {
|
|
129
|
+
expect(getRoles).toHaveBeenCalled();
|
|
130
|
+
expect(getAssignedFeatures).toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
it('Validation on empty form and behavior of userForm on selection of role', async () => {
|
|
134
|
+
jest.setTimeout(100000);
|
|
135
|
+
let errorMessages;
|
|
136
|
+
let options;
|
|
137
|
+
// submit empty form
|
|
138
|
+
const onSubmit = jest.fn();
|
|
139
|
+
fireEvent.click(screen.getByTestId('submit-button'));
|
|
140
|
+
|
|
141
|
+
// validation error on Submit
|
|
142
|
+
await waitFor(() => {
|
|
143
|
+
expect(onSubmit).not.toHaveBeenCalled();
|
|
144
|
+
errorMessages = screen.getAllByTestId('custom-error-message');
|
|
145
|
+
errorMessages = errorMessages.map((msg) => msg.textContent.trim());
|
|
146
|
+
expect(errorMessages).toHaveLength(6);
|
|
147
|
+
expect(errorMessages).toContain('UserRole is required');
|
|
148
|
+
expect(errorMessages).toContain('First Name is required');
|
|
149
|
+
expect(errorMessages).toContain('Last Name is required');
|
|
150
|
+
expect(errorMessages).toContain('User Name is required');
|
|
151
|
+
expect(errorMessages).toContain('Password is required');
|
|
152
|
+
expect(errorMessages).toContain('Confirm Password is required');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// Get the dropdown element
|
|
156
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
157
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
158
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
159
|
+
options = screen.getAllByRole('option');
|
|
160
|
+
const argusAdminRole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-96');
|
|
161
|
+
act(() => {
|
|
162
|
+
argusAdminRole.click();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
//Selection of ArgusAdmin userRole
|
|
166
|
+
await waitFor(() => {
|
|
167
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
168
|
+
expect(userRoleSelect).toHaveValue('Argus Admin');
|
|
169
|
+
errorMessages = screen.getAllByTestId('custom-error-message');
|
|
170
|
+
errorMessages = errorMessages.map((msg) => msg.textContent.trim());
|
|
171
|
+
expect(errorMessages).toHaveLength(5);
|
|
172
|
+
expect(errorMessages).not.toContain('UserRole is required');
|
|
173
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: 96 }, { showLoader: false });
|
|
174
|
+
expect(screen.getByTestId('latitude-input')).toBeInTheDocument();
|
|
175
|
+
expect(screen.getByTestId('longitude-input')).toBeInTheDocument();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('Behavior of userForm onChange of userRole', async () => {
|
|
180
|
+
let options;
|
|
181
|
+
const aadharNumberLabel = screen.getByTestId('aadhaar-number-label');
|
|
182
|
+
const emailLabel = screen.getByTestId('email-label');
|
|
183
|
+
const phoneNumberLabel = screen.getByTestId('phone-number-label');
|
|
184
|
+
|
|
185
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
186
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
187
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
188
|
+
options = screen.getAllByRole('option');
|
|
189
|
+
const argusAdminRole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-96');
|
|
190
|
+
act(() => {
|
|
191
|
+
argusAdminRole.click();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
let latitudeInput;
|
|
195
|
+
let longitudeInput;
|
|
196
|
+
|
|
197
|
+
await waitFor(() => {
|
|
198
|
+
latitudeInput = screen.getByTestId('latitude-input');
|
|
199
|
+
longitudeInput = screen.getByTestId('longitude-input');
|
|
200
|
+
expect(latitudeInput).toBeInTheDocument();
|
|
201
|
+
expect(longitudeInput).toBeInTheDocument();
|
|
202
|
+
expect(aadharNumberLabel.textContent).not.toContain('*');
|
|
203
|
+
expect(phoneNumberLabel.textContent).not.toContain('*');
|
|
204
|
+
expect(emailLabel.textContent).not.toContain('*');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
208
|
+
options = screen.getAllByRole('option');
|
|
209
|
+
const AHARole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-201');
|
|
210
|
+
act(() => {
|
|
211
|
+
AHARole.click();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Selection of AHA userRole
|
|
215
|
+
await waitFor(() => {
|
|
216
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
217
|
+
expect(userRoleSelect).toHaveValue('AHA');
|
|
218
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: 201 }, { showLoader: false });
|
|
219
|
+
expect(latitudeInput).not.toBeInTheDocument();
|
|
220
|
+
expect(longitudeInput).not.toBeInTheDocument();
|
|
221
|
+
expect(aadharNumberLabel.textContent).toContain('*');
|
|
222
|
+
expect(phoneNumberLabel.textContent).toContain('*');
|
|
223
|
+
expect(emailLabel.textContent).toContain('*');
|
|
224
|
+
});
|
|
225
|
+
}, 100000);
|
|
226
|
+
|
|
227
|
+
it('Behavior of gender field and userForm on Change of Title ', async () => {
|
|
228
|
+
let options;
|
|
229
|
+
const maleRadioButton = screen.getByTestId('gender-male').querySelector('input');
|
|
230
|
+
const femaleRadioButton = screen.getByTestId('gender-female').querySelector('input');
|
|
231
|
+
expect(maleRadioButton).not.toBeDisabled();
|
|
232
|
+
expect(femaleRadioButton).not.toBeDisabled();
|
|
233
|
+
expect(maleRadioButton).toBeChecked();
|
|
234
|
+
expect(femaleRadioButton).not.toBeChecked();
|
|
235
|
+
fireEvent.click(femaleRadioButton);
|
|
236
|
+
expect(femaleRadioButton).toBeChecked();
|
|
237
|
+
|
|
238
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
239
|
+
const titleSelect = allSelect.find((option) => option.getAttribute('id') === 'title');
|
|
240
|
+
fireEvent.mouseDown(titleSelect);
|
|
241
|
+
options = screen.getAllByRole('option');
|
|
242
|
+
|
|
243
|
+
const mrOption = options.find((option) => option.getAttribute('data-testid') === 'title-dropdown-option-Mr');
|
|
244
|
+
act(() => {
|
|
245
|
+
mrOption.click();
|
|
246
|
+
});
|
|
247
|
+
// Selection of MR Title
|
|
248
|
+
await waitFor(() => {
|
|
249
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
250
|
+
expect(titleSelect).toHaveValue('Mr');
|
|
251
|
+
expect(maleRadioButton).toBeChecked();
|
|
252
|
+
expect(maleRadioButton).toBeDisabled();
|
|
253
|
+
expect(femaleRadioButton).toBeDisabled();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
fireEvent.mouseDown(titleSelect);
|
|
257
|
+
options = screen.getAllByRole('option');
|
|
258
|
+
const msOption = options.find((option) => option.getAttribute('data-testid') === 'title-dropdown-option-Ms');
|
|
259
|
+
act(() => {
|
|
260
|
+
msOption.click();
|
|
261
|
+
});
|
|
262
|
+
// Selection of MR Title
|
|
263
|
+
await waitFor(() => {
|
|
264
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
265
|
+
expect(titleSelect).toHaveValue('Ms');
|
|
266
|
+
expect(femaleRadioButton).toBeChecked();
|
|
267
|
+
expect(maleRadioButton).toBeDisabled();
|
|
268
|
+
expect(femaleRadioButton).toBeDisabled();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
fireEvent.mouseDown(titleSelect);
|
|
272
|
+
options = screen.getAllByRole('option');
|
|
273
|
+
const drOption = options.find((option) => option.getAttribute('data-testid') === 'title-dropdown-option-Dr');
|
|
274
|
+
act(() => {
|
|
275
|
+
drOption.click();
|
|
276
|
+
});
|
|
277
|
+
// Selection of MR Title
|
|
278
|
+
await waitFor(() => {
|
|
279
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
280
|
+
expect(titleSelect).toHaveValue('Dr');
|
|
281
|
+
expect(maleRadioButton).toBeChecked();
|
|
282
|
+
expect(maleRadioButton).not.toBeDisabled();
|
|
283
|
+
expect(femaleRadioButton).not.toBeDisabled();
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it('Behavior of password and confirm password', async () => {
|
|
288
|
+
let errorMessages;
|
|
289
|
+
|
|
290
|
+
const passwordInput = screen.getByTestId('password-input').querySelector('input');
|
|
291
|
+
// Assert that the password field is of type 'password' (hidden)
|
|
292
|
+
expect(passwordInput).toHaveAttribute('type', 'password');
|
|
293
|
+
expect(passwordInput).toHaveValue('');
|
|
294
|
+
|
|
295
|
+
const confirmPasswordInput = screen.getByTestId('confirm-password-input').querySelector('input');
|
|
296
|
+
// Assert that the password field is of type 'password' (hidden)
|
|
297
|
+
expect(confirmPasswordInput).toHaveAttribute('type', 'password');
|
|
298
|
+
expect(passwordInput).toHaveValue('');
|
|
299
|
+
|
|
300
|
+
const passwordVisibilityOnButton = screen.getByTestId('password-input-visibility-on-button');
|
|
301
|
+
fireEvent.click(passwordVisibilityOnButton);
|
|
302
|
+
expect(passwordInput).toHaveAttribute('type', 'text');
|
|
303
|
+
const passwordVisibilityOffButton = screen.getByTestId('password-input-visibility-off-button');
|
|
304
|
+
fireEvent.click(passwordVisibilityOffButton);
|
|
305
|
+
expect(passwordInput).toHaveAttribute('type', 'password');
|
|
306
|
+
|
|
307
|
+
const confirmPasswordVisibilityOnButton = screen.getByTestId('confirm-password-input-visibility-on-button');
|
|
308
|
+
fireEvent.click(confirmPasswordVisibilityOnButton);
|
|
309
|
+
expect(confirmPasswordInput).toHaveAttribute('type', 'text');
|
|
310
|
+
const confirmPasswordVisibilityOffButton = screen.getByTestId('confirm-password-input-visibility-off-button');
|
|
311
|
+
fireEvent.click(confirmPasswordVisibilityOffButton);
|
|
312
|
+
expect(confirmPasswordInput).toHaveAttribute('type', 'password');
|
|
313
|
+
|
|
314
|
+
fireEvent.change(passwordInput, { target: { value: 'Abcd@1234' } });
|
|
315
|
+
expect(passwordInput).toHaveValue('Abcd@1234');
|
|
316
|
+
|
|
317
|
+
await waitFor(() => {
|
|
318
|
+
errorMessages = screen.getAllByTestId('custom-error-message');
|
|
319
|
+
errorMessages = errorMessages.map((msg) => msg.textContent.trim());
|
|
320
|
+
expect(errorMessages).toHaveLength(1);
|
|
321
|
+
expect(errorMessages).toContain('Passwords do not match');
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
fireEvent.change(confirmPasswordInput, { target: { value: 'Abcd@1234' } });
|
|
325
|
+
expect(confirmPasswordInput).toHaveValue('Abcd@1234');
|
|
326
|
+
expect(passwordInput).toHaveValue('Abcd@1234');
|
|
327
|
+
|
|
328
|
+
await waitFor(() => {
|
|
329
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('Validation for Username field', async () => {
|
|
334
|
+
checkUserAction.mockImplementation(
|
|
335
|
+
() => new Promise((resolve) => setTimeout(() => resolve({ data: true }), 100))
|
|
336
|
+
);
|
|
337
|
+
const userNameInput = screen.getByTestId('username-input').querySelector('input');
|
|
338
|
+
fireEvent.change(userNameInput, { target: { value: 'testuser' } });
|
|
339
|
+
expect(checkUserAction).toHaveBeenCalledWith({
|
|
340
|
+
action: 'checkusername',
|
|
341
|
+
username: 'testuser',
|
|
342
|
+
});
|
|
343
|
+
await waitFor(() => {
|
|
344
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
345
|
+
expect(screen.getByTestId('custom-success-message').textContent).toBe('testuser User Name is available');
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
checkUserAction.mockImplementation(
|
|
349
|
+
() => new Promise((resolve) => setTimeout(() => resolve({ data: false }), 100))
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
fireEvent.change(userNameInput, { target: { value: 'testuser2' } });
|
|
353
|
+
|
|
354
|
+
await waitFor(() => {
|
|
355
|
+
expect(checkUserAction).toHaveBeenCalledWith({
|
|
356
|
+
action: 'checkusername',
|
|
357
|
+
username: 'testuser2',
|
|
358
|
+
});
|
|
359
|
+
expect(screen.queryByTestId('custom-success-message')).not.toBeInTheDocument();
|
|
360
|
+
expect(screen.getByTestId('custom-error-message')).toHaveTextContent('Username already exists');
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('Validation for PhoneNumber', async () => {
|
|
365
|
+
const phoneNumberInput = screen.getByTestId('phone-number-input').querySelector('input');
|
|
366
|
+
fireEvent.change(phoneNumberInput, { target: { value: 1234567 } });
|
|
367
|
+
|
|
368
|
+
await waitFor(() => {
|
|
369
|
+
expect(phoneNumberInput).toHaveValue('1234567');
|
|
370
|
+
expect(screen.getByTestId('custom-error-message')).toHaveTextContent('Phone number must be 10 digits');
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
checkUserAction.mockImplementation(
|
|
374
|
+
() => new Promise((resolve) => setTimeout(() => resolve({ data: false }), 100))
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
fireEvent.change(phoneNumberInput, { target: { value: '1234567890' } });
|
|
378
|
+
fireEvent.blur(phoneNumberInput);
|
|
379
|
+
|
|
380
|
+
expect(checkUserAction).toHaveBeenCalledWith({
|
|
381
|
+
action: 'checkphone',
|
|
382
|
+
phone: '1234567890',
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
await waitFor(() => {
|
|
386
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
checkUserAction.mockImplementation(
|
|
390
|
+
() =>
|
|
391
|
+
new Promise((resolve, reject) =>
|
|
392
|
+
setTimeout(
|
|
393
|
+
() =>
|
|
394
|
+
reject({
|
|
395
|
+
response: {
|
|
396
|
+
data: {
|
|
397
|
+
message: 'Phone Number is already Linked to another User',
|
|
398
|
+
data: 'test user',
|
|
399
|
+
errorcode: 101,
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
}),
|
|
403
|
+
100
|
|
404
|
+
)
|
|
405
|
+
)
|
|
406
|
+
);
|
|
407
|
+
fireEvent.change(phoneNumberInput, { target: { value: '0987654321' } });
|
|
408
|
+
fireEvent.blur(phoneNumberInput);
|
|
409
|
+
|
|
410
|
+
expect(checkUserAction).toHaveBeenCalledWith({
|
|
411
|
+
action: 'checkphone',
|
|
412
|
+
phone: '0987654321',
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
await waitFor(() => {
|
|
416
|
+
expect(screen.getByTestId('custom-error-message')).toHaveTextContent(
|
|
417
|
+
'Phone Number is already Linked to another User test user'
|
|
418
|
+
);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('Validation for email', async () => {
|
|
423
|
+
const emailInput = screen.getByTestId('email-id-input').querySelector('input');
|
|
424
|
+
fireEvent.change(emailInput, { target: { value: 'abc' } });
|
|
425
|
+
await waitFor(() => {
|
|
426
|
+
expect(emailInput).toHaveValue('abc');
|
|
427
|
+
expect(screen.getByTestId('custom-error-message')).toHaveTextContent('Enter a valid email address');
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
fireEvent.change(emailInput, { target: { value: 'abc@gmail.com' } });
|
|
431
|
+
expect(emailInput).toHaveValue('abc@gmail.com');
|
|
432
|
+
|
|
433
|
+
await waitFor(() => {
|
|
434
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('Validation for aadhaar number', async () => {
|
|
439
|
+
const aadharNumberInput = screen.getByTestId('aadhaar-number-input').querySelector('input');
|
|
440
|
+
fireEvent.change(aadharNumberInput, { target: { value: '123' } });
|
|
441
|
+
|
|
442
|
+
await waitFor(() => {
|
|
443
|
+
expect(aadharNumberInput).toHaveValue('123');
|
|
444
|
+
expect(screen.getByTestId('custom-error-message')).toHaveTextContent('Aadhaar number must be 12 digits');
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
fireEvent.change(aadharNumberInput, { target: { value: '123456789012' } });
|
|
448
|
+
expect(aadharNumberInput).toHaveValue('123456789012');
|
|
449
|
+
|
|
450
|
+
await waitFor(() => {
|
|
451
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('Validation for firstname', async () => {
|
|
456
|
+
const firstNameInput = screen.getByTestId('first-name-input').querySelector('input');
|
|
457
|
+
fireEvent.change(firstNameInput, { target: { value: 'test' } });
|
|
458
|
+
|
|
459
|
+
await waitFor(() => {
|
|
460
|
+
expect(firstNameInput).toHaveValue('test');
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('Validation for lastname', async () => {
|
|
465
|
+
const lastNameInput = screen.getByTestId('last-name-input').querySelector('input');
|
|
466
|
+
fireEvent.change(lastNameInput, { target: { value: 'user' } });
|
|
467
|
+
|
|
468
|
+
await waitFor(() => {
|
|
469
|
+
expect(lastNameInput).toHaveValue('user');
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it('Validation for preffered language', async () => {
|
|
474
|
+
let options;
|
|
475
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
476
|
+
const languageSelect = allSelect.find((option) => option.getAttribute('id') === 'prefferedLanguage');
|
|
477
|
+
fireEvent.mouseDown(languageSelect);
|
|
478
|
+
|
|
479
|
+
options = screen.getAllByRole('option');
|
|
480
|
+
|
|
481
|
+
const guLanguage = options.find(
|
|
482
|
+
(option) => option.getAttribute('data-testid') === 'preferred-language-dropdown-option-gu'
|
|
483
|
+
);
|
|
484
|
+
act(() => {
|
|
485
|
+
guLanguage.click();
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
await waitFor(() => {
|
|
489
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it.skip('Area Of Intervention first', async () => {
|
|
494
|
+
let options;
|
|
495
|
+
getRoleDetails.mockResolvedValueOnce(mockASHARoleDetailsResponse);
|
|
496
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
497
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
498
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
499
|
+
options = screen.getAllByRole('option');
|
|
500
|
+
const ASHARole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-24');
|
|
501
|
+
act(() => {
|
|
502
|
+
ASHARole.click();
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// Selection of AHA userRole
|
|
506
|
+
await waitFor(() => {
|
|
507
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
508
|
+
expect(userRoleSelect).toHaveTextContent('ASHA');
|
|
509
|
+
expect(userRoleSelect).toHaveFocus();
|
|
510
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: 24 });
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
await waitFor(() => {
|
|
514
|
+
const addAreaButton = screen.getByTestId('add-area-button');
|
|
515
|
+
fireEvent.click(addAreaButton);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
await waitFor(() => {
|
|
519
|
+
const errorElement = screen.getByTestId('custom-error-message'); // Wait for the element to appear
|
|
520
|
+
expect(errorElement).toHaveTextContent('Please select a role to add area of intervention');
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it.skip('Area Of Intervention', async () => {
|
|
525
|
+
getLocationTypes.mockImplementationOnce(
|
|
526
|
+
() =>
|
|
527
|
+
new Promise((resolve) =>
|
|
528
|
+
setTimeout(
|
|
529
|
+
() =>
|
|
530
|
+
resolve({
|
|
531
|
+
data: [
|
|
532
|
+
{
|
|
533
|
+
id: 1,
|
|
534
|
+
type: 'S',
|
|
535
|
+
name: 'State',
|
|
536
|
+
level: 1,
|
|
537
|
+
isActive: true,
|
|
538
|
+
sohEnable: true,
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
id: 21,
|
|
542
|
+
type: 'Test',
|
|
543
|
+
name: 'Test',
|
|
544
|
+
level: 1,
|
|
545
|
+
isActive: false,
|
|
546
|
+
sohEnable: true,
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
id: 22,
|
|
550
|
+
type: 'TEST1',
|
|
551
|
+
name: 'TEST1',
|
|
552
|
+
level: 1,
|
|
553
|
+
isActive: false,
|
|
554
|
+
sohEnable: true,
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
id: 4,
|
|
558
|
+
type: 'R',
|
|
559
|
+
name: 'Region',
|
|
560
|
+
level: 2,
|
|
561
|
+
isActive: true,
|
|
562
|
+
sohEnable: false,
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
id: 24,
|
|
566
|
+
type: 'Test2',
|
|
567
|
+
name: 'Test2',
|
|
568
|
+
level: 2,
|
|
569
|
+
isActive: false,
|
|
570
|
+
sohEnable: true,
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
id: 5,
|
|
574
|
+
type: 'C',
|
|
575
|
+
name: 'Corporation',
|
|
576
|
+
level: 3,
|
|
577
|
+
isActive: true,
|
|
578
|
+
sohEnable: true,
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: 6,
|
|
582
|
+
type: 'D',
|
|
583
|
+
name: 'District',
|
|
584
|
+
level: 3,
|
|
585
|
+
isActive: true,
|
|
586
|
+
sohEnable: true,
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
id: 2,
|
|
590
|
+
type: 'B',
|
|
591
|
+
name: 'Block',
|
|
592
|
+
level: 4,
|
|
593
|
+
isActive: true,
|
|
594
|
+
sohEnable: true,
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
id: 3,
|
|
598
|
+
type: 'Z',
|
|
599
|
+
name: 'Zone',
|
|
600
|
+
level: 4,
|
|
601
|
+
isActive: true,
|
|
602
|
+
sohEnable: true,
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
id: 23,
|
|
606
|
+
type: 'Block',
|
|
607
|
+
name: 'B',
|
|
608
|
+
level: 4,
|
|
609
|
+
isActive: true,
|
|
610
|
+
sohEnable: true,
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
id: 15,
|
|
614
|
+
type: 'CHC',
|
|
615
|
+
name: 'CHC',
|
|
616
|
+
level: 5,
|
|
617
|
+
isActive: false,
|
|
618
|
+
sohEnable: true,
|
|
619
|
+
},
|
|
620
|
+
{
|
|
621
|
+
id: 13,
|
|
622
|
+
type: 'P',
|
|
623
|
+
name: 'PHC',
|
|
624
|
+
level: 5,
|
|
625
|
+
isActive: true,
|
|
626
|
+
sohEnable: true,
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
id: 14,
|
|
630
|
+
type: 'U',
|
|
631
|
+
name: 'UPHC',
|
|
632
|
+
level: 5,
|
|
633
|
+
isActive: true,
|
|
634
|
+
sohEnable: true,
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
id: 11,
|
|
638
|
+
type: 'SC',
|
|
639
|
+
name: 'Sub Center',
|
|
640
|
+
level: 6,
|
|
641
|
+
isActive: true,
|
|
642
|
+
sohEnable: true,
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
id: 12,
|
|
646
|
+
type: 'ANM',
|
|
647
|
+
name: 'ANM Area',
|
|
648
|
+
level: 6,
|
|
649
|
+
isActive: true,
|
|
650
|
+
sohEnable: true,
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
id: 9,
|
|
654
|
+
type: 'V',
|
|
655
|
+
name: 'Village',
|
|
656
|
+
level: 7,
|
|
657
|
+
isActive: true,
|
|
658
|
+
sohEnable: true,
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
id: 10,
|
|
662
|
+
type: 'ANG',
|
|
663
|
+
name: 'Anganwadi Area',
|
|
664
|
+
level: 7,
|
|
665
|
+
isActive: true,
|
|
666
|
+
sohEnable: true,
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
id: 7,
|
|
670
|
+
type: 'A',
|
|
671
|
+
name: 'Area',
|
|
672
|
+
level: 8,
|
|
673
|
+
isActive: true,
|
|
674
|
+
sohEnable: true,
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
id: 8,
|
|
678
|
+
type: 'AA',
|
|
679
|
+
name: 'Asha Area',
|
|
680
|
+
level: 8,
|
|
681
|
+
isActive: true,
|
|
682
|
+
sohEnable: true,
|
|
683
|
+
},
|
|
684
|
+
],
|
|
685
|
+
}),
|
|
686
|
+
100
|
|
687
|
+
)
|
|
688
|
+
)
|
|
689
|
+
);
|
|
690
|
+
|
|
691
|
+
getRoleDetails.mockImplementationOnce(
|
|
692
|
+
() => new Promise((resolve) => setTimeout(() => resolve(mockASHARoleDetailsResponse), 100))
|
|
693
|
+
);
|
|
694
|
+
|
|
695
|
+
validateAOI.mockImplementationOnce(
|
|
696
|
+
() =>
|
|
697
|
+
new Promise((resolve) =>
|
|
698
|
+
setTimeout(
|
|
699
|
+
() =>
|
|
700
|
+
resolve({
|
|
701
|
+
data: {
|
|
702
|
+
message: 'Gujarat',
|
|
703
|
+
data: null,
|
|
704
|
+
errorcode: 1,
|
|
705
|
+
},
|
|
706
|
+
}),
|
|
707
|
+
100
|
|
708
|
+
)
|
|
709
|
+
)
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
// Find all select boxes and identify the role dropdown by its 'id'
|
|
713
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
714
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
715
|
+
|
|
716
|
+
// Open the dropdown menu for roles
|
|
717
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
718
|
+
|
|
719
|
+
// Get the list of options displayed in the dropdown
|
|
720
|
+
let options = screen.getAllByRole('option');
|
|
721
|
+
|
|
722
|
+
// Find and select the ASHA role based on 'data-testid'
|
|
723
|
+
const ASHARole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-24');
|
|
724
|
+
|
|
725
|
+
// Trigger the role selection
|
|
726
|
+
act(() => {
|
|
727
|
+
ASHARole.click();
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
// Wait for the dropdown to close and check if role details were fetched
|
|
731
|
+
await waitFor(() => {
|
|
732
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
733
|
+
expect(userRoleSelect).toHaveTextContent('ASHA');
|
|
734
|
+
expect(userRoleSelect).toHaveFocus();
|
|
735
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: 24 });
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
// Find and click the 'add area' button
|
|
739
|
+
|
|
740
|
+
const addAreaButton = screen.getByTestId('add-area-button');
|
|
741
|
+
await waitFor(() => {
|
|
742
|
+
fireEvent.click(addAreaButton);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
// Wait for the error message to appear
|
|
746
|
+
await waitFor(() => {
|
|
747
|
+
const errorElement = screen.getByTestId('custom-error-message');
|
|
748
|
+
expect(errorElement).toHaveTextContent('Please select a role to add area of intervention');
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
it.skip('healthInfraStructure', async () => {
|
|
753
|
+
const mockSetAddedAreas = jest.fn();
|
|
754
|
+
jest.spyOn(React, 'useState').mockImplementation((initial) => [initial, mockSetAddedAreas]);
|
|
755
|
+
mockSetAddedAreas([
|
|
756
|
+
{
|
|
757
|
+
locationId: 2,
|
|
758
|
+
type: 'S',
|
|
759
|
+
name: 'Gujarat',
|
|
760
|
+
level: 1,
|
|
761
|
+
locationFullName: 'Gujarat',
|
|
762
|
+
},
|
|
763
|
+
]);
|
|
764
|
+
await waitFor(() => {
|
|
765
|
+
const healthInfraSelect = screen.getByTestId('health-infra-select');
|
|
766
|
+
expect(healthInfraSelect).toBeInTheDocument();
|
|
767
|
+
});
|
|
768
|
+
});
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
describe('Update User', () => {
|
|
772
|
+
beforeEach(async () => {
|
|
773
|
+
getUserDetails.mockResolvedValue(mockGetUserDetailsResponse);
|
|
774
|
+
retrieveInfraByRoleLocation.mockResolvedValue(mockRetrieveHealthInfraResponse);
|
|
775
|
+
|
|
776
|
+
await act(async () => {
|
|
777
|
+
await renderComponent({ url: '/ui/manage/user', id: '38' });
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
it('renders the User component in the Edit Mode ', async () => {
|
|
782
|
+
expect(screen.getByTestId('ManageUserForm')).toBeInTheDocument();
|
|
783
|
+
await waitFor(() => {
|
|
784
|
+
expect(screen.getByTestId('form-header')).toHaveTextContent('Update User');
|
|
785
|
+
expect(getUserDetails).toHaveBeenCalled();
|
|
786
|
+
expect(screen.getByTestId('submit-button')).toHaveTextContent('Update');
|
|
787
|
+
});
|
|
788
|
+
});
|
|
789
|
+
it('Initial API Calls For Edit Mode', async () => {
|
|
790
|
+
await waitFor(() => {
|
|
791
|
+
expect(getRoles).toHaveBeenCalled();
|
|
792
|
+
expect(getAssignedFeatures).toHaveBeenCalled();
|
|
793
|
+
expect(getUserDetails).toHaveBeenCalledWith('38');
|
|
794
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: '38' });
|
|
795
|
+
expect(retrieveInfraByRoleLocation).toHaveBeenCalledWith({
|
|
796
|
+
code: 'retrieve_infra_by_role_location',
|
|
797
|
+
parameters: {
|
|
798
|
+
roleId: 38,
|
|
799
|
+
locationIds: [364243],
|
|
800
|
+
},
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
});
|
|
804
|
+
it('Behavior of userForm onChange of userRole', async () => {
|
|
805
|
+
let options;
|
|
806
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
807
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
808
|
+
|
|
809
|
+
expect(userRoleSelect).toHaveValue('ASHA');
|
|
810
|
+
|
|
811
|
+
const aadharNumberLabel = screen.getByTestId('aadhaar-number-label');
|
|
812
|
+
const emailLabel = screen.getByTestId('email-label');
|
|
813
|
+
const phoneNumberLabel = screen.getByTestId('phone-number-label');
|
|
814
|
+
|
|
815
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
816
|
+
options = screen.getAllByRole('option');
|
|
817
|
+
const argusAdminRole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-96');
|
|
818
|
+
act(() => {
|
|
819
|
+
argusAdminRole.click();
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
let latitudeInput;
|
|
823
|
+
let longitudeInput;
|
|
824
|
+
|
|
825
|
+
await waitFor(() => {
|
|
826
|
+
latitudeInput = screen.getByTestId('latitude-input');
|
|
827
|
+
longitudeInput = screen.getByTestId('longitude-input');
|
|
828
|
+
expect(aadharNumberLabel.textContent).not.toContain('*');
|
|
829
|
+
expect(phoneNumberLabel.textContent).not.toContain('*');
|
|
830
|
+
expect(emailLabel.textContent).not.toContain('*');
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
fireEvent.mouseDown(userRoleSelect);
|
|
834
|
+
options = screen.getAllByRole('option');
|
|
835
|
+
const AHARole = options.find((option) => option.getAttribute('data-testid') === 'role-dropdown-option-201');
|
|
836
|
+
act(() => {
|
|
837
|
+
AHARole.click();
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
// Selection of AHA userRole
|
|
841
|
+
await waitFor(() => {
|
|
842
|
+
expect(screen.queryByRole('listbox')).toBeNull();
|
|
843
|
+
expect(userRoleSelect).toHaveValue('AHA');
|
|
844
|
+
expect(getRoleDetails).toHaveBeenCalledWith({ role_id: 201 }, { showLoader: false });
|
|
845
|
+
expect(latitudeInput).not.toBeInTheDocument();
|
|
846
|
+
expect(longitudeInput).not.toBeInTheDocument();
|
|
847
|
+
expect(aadharNumberLabel.textContent).toContain('*');
|
|
848
|
+
expect(phoneNumberLabel.textContent).toContain('*');
|
|
849
|
+
expect(emailLabel.textContent).toContain('*');
|
|
850
|
+
});
|
|
851
|
+
}, 100000);
|
|
852
|
+
it('auto filled field in edit form', async () => {
|
|
853
|
+
const allSelect = screen.getAllByRole('combobox');
|
|
854
|
+
const userRoleSelect = allSelect.find((option) => option.getAttribute('id') === 'roleId');
|
|
855
|
+
expect(userRoleSelect).toHaveValue('ASHA');
|
|
856
|
+
|
|
857
|
+
const titleSelect = allSelect.find((option) => option.getAttribute('id') === 'title');
|
|
858
|
+
expect(titleSelect).toHaveValue('Mr');
|
|
859
|
+
|
|
860
|
+
expect(screen.getByTestId('first-name-input').querySelector('input')).toHaveValue('TEST');
|
|
861
|
+
expect(screen.getByTestId('last-name-input').querySelector('input')).toHaveValue('USER');
|
|
862
|
+
expect(screen.getByTestId('middle-name-input').querySelector('input')).toHaveValue('MED');
|
|
863
|
+
|
|
864
|
+
const maleRadioButton = screen.getByTestId('gender-male').querySelector('input');
|
|
865
|
+
const femaleRadioButton = screen.getByTestId('gender-female').querySelector('input');
|
|
866
|
+
expect(maleRadioButton).toBeDisabled();
|
|
867
|
+
expect(femaleRadioButton).toBeDisabled();
|
|
868
|
+
expect(maleRadioButton).toBeChecked();
|
|
869
|
+
expect(femaleRadioButton).not.toBeChecked();
|
|
870
|
+
|
|
871
|
+
expect(screen.getByTestId('username-input').querySelector('input')).toHaveValue('bvvasava4');
|
|
872
|
+
expect(screen.getByTestId('phone-number-input').querySelector('input')).toHaveValue('6354986451');
|
|
873
|
+
expect(screen.getByTestId('email-id-input').querySelector('input')).toHaveValue('abcd@gmail.com');
|
|
874
|
+
expect(screen.getByTestId('aadhaar-number-input').querySelector('input')).toBeEmptyDOMElement();
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
it('unlock user button', async () => {
|
|
878
|
+
const unlockUserButton = screen.getByTestId('unlock-user-button');
|
|
879
|
+
expect(unlockUserButton).toBeInTheDocument();
|
|
880
|
+
fireEvent.click(unlockUserButton);
|
|
881
|
+
|
|
882
|
+
await waitFor(() => {
|
|
883
|
+
expect(screen.getByTestId('unlock-user-modal')).toBeInTheDocument();
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
it('change password button', async () => {
|
|
887
|
+
const changePasswordButton = screen.getByTestId('change-password-button');
|
|
888
|
+
expect(changePasswordButton).toBeInTheDocument();
|
|
889
|
+
fireEvent.click(changePasswordButton);
|
|
890
|
+
await waitFor(() => {
|
|
891
|
+
expect(screen.getByTestId('change-password-modal')).toBeInTheDocument();
|
|
892
|
+
});
|
|
893
|
+
});
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
describe('successful submission with argusAdmin Role', () => {
|
|
897
|
+
beforeEach(async () => {
|
|
898
|
+
getUserDetails.mockResolvedValue(mockArgusAdminResponse);
|
|
899
|
+
retrieveInfraByRoleLocation.mockResolvedValue(mockArgusAdminRetrieveHealthInfraResponse);
|
|
900
|
+
await act(async () => {
|
|
901
|
+
await renderComponent({ url: '/ui/manage/user', id: '38' });
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
it('Successful Edit submission after changes', async () => {
|
|
906
|
+
getUserDetails.mockResolvedValueOnce(mockArgusAdminResponse);
|
|
907
|
+
retrieveInfraByRoleLocation.mockResolvedValueOnce(mockArgusAdminRetrieveHealthInfraResponse);
|
|
908
|
+
|
|
909
|
+
await waitFor(() => {
|
|
910
|
+
expect(screen.getByTestId('added-areas-select')).toBeInTheDocument();
|
|
911
|
+
expect(screen.getByTestId('health-infra-select')).toBeInTheDocument();
|
|
912
|
+
});
|
|
913
|
+
|
|
914
|
+
const emailInput = screen.getByTestId('email-id-input').querySelector('input');
|
|
915
|
+
|
|
916
|
+
fireEvent.change(emailInput, { target: { value: 'abc@gmail.com' } });
|
|
917
|
+
expect(emailInput).toHaveValue('abc@gmail.com');
|
|
918
|
+
|
|
919
|
+
const submitButton = screen.getByTestId('submit-button');
|
|
920
|
+
fireEvent.click(submitButton);
|
|
921
|
+
|
|
922
|
+
await waitFor(() => {
|
|
923
|
+
expect(updateUser).toHaveBeenCalledWith({
|
|
924
|
+
id: 97084,
|
|
925
|
+
fullName: 'Pratham Prajapati',
|
|
926
|
+
userName: 'ppratham',
|
|
927
|
+
firstName: 'Pratham',
|
|
928
|
+
lastName: 'Prajapati',
|
|
929
|
+
middlename: undefined,
|
|
930
|
+
loginCode: undefined,
|
|
931
|
+
isUserSmagTrained: undefined,
|
|
932
|
+
gender: 'M',
|
|
933
|
+
prefferedLanguage: 'en',
|
|
934
|
+
state: 'ACTIVE',
|
|
935
|
+
roleId: 96,
|
|
936
|
+
createdBy: 97080,
|
|
937
|
+
createdOn: 1720691528671,
|
|
938
|
+
roleName: 'Argus Admin',
|
|
939
|
+
addedLocations: [
|
|
940
|
+
{
|
|
941
|
+
id: 338897,
|
|
942
|
+
userId: 97084,
|
|
943
|
+
locationId: 2,
|
|
944
|
+
type: 'S',
|
|
945
|
+
name: 'Gujarat',
|
|
946
|
+
level: 1,
|
|
947
|
+
state: 'ACTIVE',
|
|
948
|
+
createdBy: 97080,
|
|
949
|
+
createdOn: 1720691528792,
|
|
950
|
+
locationFullName: 'Gujarat',
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
id: 338902,
|
|
954
|
+
userId: 97084,
|
|
955
|
+
locationId: 550515,
|
|
956
|
+
type: 'R',
|
|
957
|
+
name: 'ભાવનગર ઝોન',
|
|
958
|
+
level: 2,
|
|
959
|
+
state: 'ACTIVE',
|
|
960
|
+
createdBy: 97080,
|
|
961
|
+
createdOn: 1725023866078,
|
|
962
|
+
locationFullName: 'Gujarat,ભાવનગર ઝોન',
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
id: 338903,
|
|
966
|
+
userId: 97084,
|
|
967
|
+
locationId: 550513,
|
|
968
|
+
type: 'R',
|
|
969
|
+
name: 'ગાંધીનગર ઝોન',
|
|
970
|
+
level: 2,
|
|
971
|
+
state: 'ACTIVE',
|
|
972
|
+
createdBy: 97080,
|
|
973
|
+
createdOn: 1725024001806,
|
|
974
|
+
locationFullName: 'Gujarat,ગાંધીનગર ઝોન',
|
|
975
|
+
},
|
|
976
|
+
],
|
|
977
|
+
title: 'Dr',
|
|
978
|
+
noOfAttempts: 0,
|
|
979
|
+
infrastructureIds: [15457],
|
|
980
|
+
latitude: '8989',
|
|
981
|
+
longitude: '898989898989.0999',
|
|
982
|
+
bankAccNo: '',
|
|
983
|
+
ifscCode: '',
|
|
984
|
+
emailId: 'abc@gmail.com',
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
});
|
|
989
|
+
});
|