@argusoft/medplat-app-shell 1.0.6 → 1.0.8
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/store/slices/dashboardSlice.js +14 -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,314 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import ForgotPassword from '@/views/feature-components/ForgotPassword/ForgotPassword';
|
|
4
|
+
import { showToast } from '@/common/toaster/toaster';
|
|
5
|
+
import { forgotPasswordGenerateOTP, forgotPasswordVerifyOTP } from '@/common/services/ForgotPassword';
|
|
6
|
+
|
|
7
|
+
jest.useFakeTimers();
|
|
8
|
+
jest.mock('../../../../assets/img/medplat-highres.png', () => 'test-image-path');
|
|
9
|
+
|
|
10
|
+
jest.mock('../../../../common/toaster/toaster', () => ({
|
|
11
|
+
showToast: jest.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('../../../../common/services/ForgotPassword.js', () => ({
|
|
15
|
+
forgotPasswordGenerateOTP: jest.fn(),
|
|
16
|
+
forgotPasswordVerifyOTP: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe('ForgotPassword Component', () => {
|
|
20
|
+
let unmountComponent;
|
|
21
|
+
const renderComponent = async () => {
|
|
22
|
+
await act(async () => {
|
|
23
|
+
const renderResult = render(<ForgotPassword />);
|
|
24
|
+
unmountComponent = renderResult.unmount;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
beforeEach(async () => {
|
|
29
|
+
await renderComponent();
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
forgotPasswordGenerateOTP.mockImplementation(() => Promise.resolve({ status: 200, data: '******2209' }));
|
|
32
|
+
forgotPasswordVerifyOTP.mockImplementation(() => Promise.resolve({ status: 200 }));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
cleanup();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should render the ForgotPassword form', () => {
|
|
40
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
41
|
+
expect(otpButton).toBeInTheDocument();
|
|
42
|
+
expect(otpButton).toHaveTextContent('Get OTP');
|
|
43
|
+
|
|
44
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
45
|
+
expect(usernameTextField).toBeInTheDocument();
|
|
46
|
+
|
|
47
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
48
|
+
expect(usernameInput).toHaveAttribute('name', 'username');
|
|
49
|
+
|
|
50
|
+
const heading = screen.getByText(/Forgot Password/i);
|
|
51
|
+
expect(heading).toBeInTheDocument();
|
|
52
|
+
|
|
53
|
+
expect(screen.getByTestId('forgot-pssword-form')).toBeInTheDocument();
|
|
54
|
+
expect(screen.getByTestId('login-logo')).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should call invalid username toast and render username required', async () => {
|
|
58
|
+
forgotPasswordGenerateOTP.mockRejectedValue({
|
|
59
|
+
response: {
|
|
60
|
+
data: {
|
|
61
|
+
message: 'Invalid Username',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
66
|
+
fireEvent.click(otpButton);
|
|
67
|
+
|
|
68
|
+
await waitFor(() => {
|
|
69
|
+
expect(screen.getByText('Username is required')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
73
|
+
expect(usernameTextField).toBeInTheDocument();
|
|
74
|
+
|
|
75
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
76
|
+
fireEvent.change(usernameInput, { target: { value: 'test123' } });
|
|
77
|
+
|
|
78
|
+
await act(async () => {
|
|
79
|
+
fireEvent.click(otpButton);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await waitFor(() => {
|
|
83
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
84
|
+
message: 'Invalid Username',
|
|
85
|
+
type: 'error',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should call generateOTP function', async () => {
|
|
91
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
92
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
93
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
94
|
+
|
|
95
|
+
await act(async () => {
|
|
96
|
+
fireEvent.change(usernameInput, { target: { value: 'ajvasava2' } });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await act(async () => {
|
|
100
|
+
fireEvent.click(otpButton);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
await act(async () => {
|
|
104
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
await waitFor(() => {
|
|
108
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledWith({
|
|
109
|
+
username: 'ajvasava2',
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should toast retry after 30 sec for second time', async () => {
|
|
115
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
116
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
117
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
118
|
+
|
|
119
|
+
await act(async () => {
|
|
120
|
+
fireEvent.change(usernameInput, { target: { value: 'ajvasava2' } });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
await act(async () => {
|
|
124
|
+
fireEvent.click(otpButton);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await act(async () => {
|
|
128
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await waitFor(() => {
|
|
132
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledWith({
|
|
133
|
+
username: 'ajvasava2',
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
unmountComponent();
|
|
138
|
+
render(<ForgotPassword />);
|
|
139
|
+
|
|
140
|
+
forgotPasswordGenerateOTP.mockRejectedValue({
|
|
141
|
+
response: {
|
|
142
|
+
data: {
|
|
143
|
+
message: 'Try after 30 Seconds',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const otpButton1 = screen.getByTestId('forgot-password-get-otp-button');
|
|
149
|
+
const usernameInput1 = within(screen.getByTestId('forgot-password-username-textfield')).getByRole('textbox');
|
|
150
|
+
|
|
151
|
+
await act(async () => {
|
|
152
|
+
fireEvent.change(usernameInput1, { target: { value: 'ajvasava2' } });
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
await act(async () => {
|
|
156
|
+
fireEvent.click(otpButton1);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
await act(async () => {
|
|
160
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
await waitFor(() => {
|
|
164
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledWith({
|
|
165
|
+
username: 'ajvasava2',
|
|
166
|
+
});
|
|
167
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
168
|
+
message: 'Try after 30 Seconds',
|
|
169
|
+
type: 'error',
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should call generateOTP function and change button text to Submit', async () => {
|
|
175
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
176
|
+
expect(otpButton).toBeInTheDocument();
|
|
177
|
+
|
|
178
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
179
|
+
expect(usernameTextField).toBeInTheDocument();
|
|
180
|
+
|
|
181
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
182
|
+
await act(async () => {
|
|
183
|
+
fireEvent.change(usernameInput, { target: { value: 'ajvasava2' } });
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
await act(async () => {
|
|
187
|
+
fireEvent.click(otpButton);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
await act(async () => {
|
|
191
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
await waitFor(() => {
|
|
195
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledWith({
|
|
196
|
+
username: 'ajvasava2',
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const getSumbitButton = screen.getByTestId('forgot-password-verify-otp-button');
|
|
201
|
+
expect(screen.getByText(/Please enter OTP received on Mobile Number/)).toBeInTheDocument();
|
|
202
|
+
|
|
203
|
+
const userEle = within(screen.getByTestId('forgot-password-username-textfield')).getByRole('textbox');
|
|
204
|
+
expect(userEle).toHaveValue('ajvasava2');
|
|
205
|
+
|
|
206
|
+
const otpEle = within(screen.getByTestId('forgot-password-otp-textfield')).getByRole('textbox');
|
|
207
|
+
expect(otpEle).toHaveAttribute('placeholder', 'Enter OTP');
|
|
208
|
+
|
|
209
|
+
expect(screen.getByText(/Resend OTP in \d+ seconds/)).toBeInTheDocument();
|
|
210
|
+
expect(getSumbitButton).toHaveTextContent('Submit');
|
|
211
|
+
|
|
212
|
+
await act(async () => {
|
|
213
|
+
fireEvent.click(getSumbitButton);
|
|
214
|
+
});
|
|
215
|
+
//Checking for the wrong otp
|
|
216
|
+
await act(async () => {
|
|
217
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
let errorEle = screen.getByTestId('custom-error-message');
|
|
221
|
+
expect(errorEle).toHaveTextContent('OTP is required');
|
|
222
|
+
|
|
223
|
+
for (let i = 1; i <= 3; i++) {
|
|
224
|
+
await act(async () => {
|
|
225
|
+
fireEvent.change(otpEle, { target: { value: '1'.repeat(i) } });
|
|
226
|
+
});
|
|
227
|
+
await waitFor(() => {
|
|
228
|
+
errorEle = screen.getByTestId('custom-error-message');
|
|
229
|
+
expect(errorEle).toHaveTextContent('OTP should be of 4 digits');
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
await act(async () => {
|
|
234
|
+
fireEvent.change(otpEle, { target: { value: '1234' } });
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
await waitFor(() => {
|
|
238
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
await act(async () => {
|
|
242
|
+
fireEvent.click(screen.getByTestId('forgot-password-verify-otp-button'));
|
|
243
|
+
});
|
|
244
|
+
await act(async () => {
|
|
245
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await waitFor(async () => {
|
|
249
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledTimes(1);
|
|
250
|
+
expect(forgotPasswordVerifyOTP).toHaveBeenCalledTimes(2);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('should render error and also call verify otp', async () => {
|
|
255
|
+
const otpButton = screen.getByTestId('forgot-password-get-otp-button');
|
|
256
|
+
const usernameTextField = screen.getByTestId('forgot-password-username-textfield');
|
|
257
|
+
const usernameInput = within(usernameTextField).getByRole('textbox');
|
|
258
|
+
|
|
259
|
+
await act(async () => {
|
|
260
|
+
fireEvent.change(usernameInput, { target: { value: 'ajvasava2' } });
|
|
261
|
+
fireEvent.click(otpButton);
|
|
262
|
+
});
|
|
263
|
+
await act(async () => {
|
|
264
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
await waitFor(() => {
|
|
268
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledWith({ username: 'ajvasava2' });
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const otpField = within(screen.getByTestId('forgot-password-otp-textfield')).getByRole('textbox');
|
|
272
|
+
const submitButton = screen.getByTestId('forgot-password-verify-otp-button');
|
|
273
|
+
|
|
274
|
+
await act(async () => {
|
|
275
|
+
fireEvent.click(submitButton);
|
|
276
|
+
});
|
|
277
|
+
await act(async () => {
|
|
278
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
let errorEle = screen.getByTestId('custom-error-message');
|
|
282
|
+
expect(errorEle).toHaveTextContent('OTP is required');
|
|
283
|
+
|
|
284
|
+
for (let i = 1; i <= 3; i++) {
|
|
285
|
+
await act(async () => {
|
|
286
|
+
fireEvent.change(otpField, { target: { value: '1'.repeat(i) } });
|
|
287
|
+
});
|
|
288
|
+
await waitFor(() => {
|
|
289
|
+
errorEle = screen.getByTestId('custom-error-message');
|
|
290
|
+
expect(errorEle).toHaveTextContent('OTP should be of 4 digits');
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
await act(async () => {
|
|
295
|
+
fireEvent.change(otpField, { target: { value: '1234' } });
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
await waitFor(() => {
|
|
299
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
await act(async () => {
|
|
303
|
+
fireEvent.click(screen.getByTestId('forgot-password-verify-otp-button'));
|
|
304
|
+
});
|
|
305
|
+
await act(async () => {
|
|
306
|
+
fireEvent.submit(screen.getByTestId('forgot-pssword-form'));
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
await waitFor(async () => {
|
|
310
|
+
expect(forgotPasswordGenerateOTP).toHaveBeenCalledTimes(1);
|
|
311
|
+
expect(forgotPasswordVerifyOTP).toHaveBeenCalledTimes(2);
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
});
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { act, cleanup, render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import LocationDirective from '@/views/feature-components/LocationDirective/LocationDirective';
|
|
4
|
+
import { retriveLocationType } from '@/common/services/LocationType';
|
|
5
|
+
import { getParent, retrieveNextLevel } from '@/common/services/LocationService';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
7
|
+
import { authenticatedUser, mockLocations, mockLocationTypes } from './mockLocationDirective';
|
|
8
|
+
|
|
9
|
+
jest.mock('@/common/languageTranslator/TranslationContext', () => ({
|
|
10
|
+
useTranslateProvider: () => ({
|
|
11
|
+
translate: (key) => key,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.mock('react-redux', () => ({
|
|
16
|
+
useSelector: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock('@/common/services/LocationType', () => ({
|
|
20
|
+
retriveLocationType: jest.fn(),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
jest.mock('@/common/services/LocationService', () => ({
|
|
24
|
+
retrieveNextLevel: jest.fn(),
|
|
25
|
+
getParent: jest.fn(),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
describe('LocationDirective Component', () => {
|
|
29
|
+
const mockSelectedLocationRef = { current: {} };
|
|
30
|
+
const mockSelectedIdRef = { current: null };
|
|
31
|
+
const mockSetSelectedLocation = jest.fn();
|
|
32
|
+
const mockSetSelectedId = jest.fn();
|
|
33
|
+
|
|
34
|
+
beforeEach(async () => {
|
|
35
|
+
cleanup();
|
|
36
|
+
|
|
37
|
+
retriveLocationType.mockResolvedValue({ data: mockLocationTypes });
|
|
38
|
+
|
|
39
|
+
retrieveNextLevel.mockImplementation((locationIds, level) => {
|
|
40
|
+
// Initial state level
|
|
41
|
+
if (!locationIds || locationIds.length === 0) {
|
|
42
|
+
return Promise.resolve([
|
|
43
|
+
{
|
|
44
|
+
level: 1,
|
|
45
|
+
locationLabel: 'State',
|
|
46
|
+
locationDetails: mockLocations.level1,
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (locationIds.includes(2) && level === 2) {
|
|
52
|
+
return Promise.resolve([
|
|
53
|
+
{
|
|
54
|
+
level: 2,
|
|
55
|
+
locationLabel: 'Region',
|
|
56
|
+
locationDetails: mockLocations.level2,
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (level === 3) {
|
|
62
|
+
return Promise.resolve([
|
|
63
|
+
{
|
|
64
|
+
level: 3,
|
|
65
|
+
locationLabel: 'District/Corporation',
|
|
66
|
+
locationDetails: mockLocations.level3,
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (level === 4) {
|
|
72
|
+
return Promise.resolve([
|
|
73
|
+
{
|
|
74
|
+
level: 4,
|
|
75
|
+
locationLabel: 'Block',
|
|
76
|
+
locationDetails: mockLocations.level4,
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (level === 5) {
|
|
82
|
+
return Promise.resolve([
|
|
83
|
+
{
|
|
84
|
+
level: 5,
|
|
85
|
+
locationLabel: 'PHC/UPHC',
|
|
86
|
+
locationDetails: mockLocations.level5,
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (level === 6) {
|
|
92
|
+
return Promise.resolve([
|
|
93
|
+
{
|
|
94
|
+
level: 6,
|
|
95
|
+
locationLabel: 'ANM Area',
|
|
96
|
+
locationDetails: mockLocations.level6,
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
if (level === 7) {
|
|
101
|
+
return Promise.resolve([
|
|
102
|
+
{
|
|
103
|
+
level: 7,
|
|
104
|
+
locationLabel: 'Anganwadi Area',
|
|
105
|
+
locationDetails: mockLocations.level7,
|
|
106
|
+
},
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
if (level === 8) {
|
|
110
|
+
return Promise.resolve([
|
|
111
|
+
{
|
|
112
|
+
level: 8,
|
|
113
|
+
locationLabel: 'Asha Area',
|
|
114
|
+
locationDetails: mockLocations.level8,
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return Promise.resolve([]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
useSelector.mockImplementation((selector) => selector(authenticatedUser));
|
|
123
|
+
await act(async () => {
|
|
124
|
+
render(
|
|
125
|
+
<LocationDirective
|
|
126
|
+
selectedLocationRef={mockSelectedLocationRef}
|
|
127
|
+
selectedIdRef={mockSelectedIdRef}
|
|
128
|
+
setSelectedLocation={mockSetSelectedLocation}
|
|
129
|
+
setSelectedId={mockSetSelectedId}
|
|
130
|
+
templateType="inline"
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should render correctly', async () => {
|
|
137
|
+
const stateLabel = screen.getByTestId('locationdirective-inline-location-label-0');
|
|
138
|
+
expect(stateLabel).toHaveTextContent('State');
|
|
139
|
+
const stateInput = screen.getByTestId('locationdirective-inline-dropdown-1').querySelector('input');
|
|
140
|
+
expect(stateInput).toBeInTheDocument();
|
|
141
|
+
expect(stateInput).toHaveValue('Gujarat');
|
|
142
|
+
|
|
143
|
+
const regionLabel = screen.getByTestId('locationdirective-inline-location-label-1');
|
|
144
|
+
expect(regionLabel).toHaveTextContent('Region');
|
|
145
|
+
const regionInput = screen.getByTestId('locationdirective-inline-dropdown-2').querySelector('input');
|
|
146
|
+
expect(regionInput).toBeInTheDocument();
|
|
147
|
+
fireEvent.mouseDown(regionInput);
|
|
148
|
+
const regionOption = screen.getByTestId('locationdirective-inline-dropdown-2-option-550513');
|
|
149
|
+
await act(async () => {
|
|
150
|
+
fireEvent.click(regionOption);
|
|
151
|
+
});
|
|
152
|
+
expect(regionInput).toHaveValue('ગાંધીનગર ઝોન');
|
|
153
|
+
|
|
154
|
+
getParent.mockResolvedValue({
|
|
155
|
+
data: {
|
|
156
|
+
id: 550513,
|
|
157
|
+
name: 'ગાંધીનગર ઝોન',
|
|
158
|
+
type: 'R',
|
|
159
|
+
locType: 'Region',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const districtLabel = screen.getByTestId('locationdirective-inline-location-label-2');
|
|
164
|
+
expect(districtLabel).toHaveTextContent('District/Corporation');
|
|
165
|
+
const districtInput = screen.getByTestId('locationdirective-inline-dropdown-3').querySelector('input');
|
|
166
|
+
expect(districtInput).toBeInTheDocument();
|
|
167
|
+
fireEvent.mouseDown(districtInput);
|
|
168
|
+
const districtOption = screen.getByTestId('locationdirective-inline-dropdown-3-option-161926');
|
|
169
|
+
await act(async () => {
|
|
170
|
+
fireEvent.click(districtOption);
|
|
171
|
+
});
|
|
172
|
+
expect(districtInput).toHaveValue('બનાસકાંઠા');
|
|
173
|
+
|
|
174
|
+
const blockLabel = screen.getByTestId('locationdirective-inline-location-label-3');
|
|
175
|
+
expect(blockLabel).toHaveTextContent('Block');
|
|
176
|
+
const blockInput = screen.getByTestId('locationdirective-inline-dropdown-4').querySelector('input');
|
|
177
|
+
expect(blockInput).toBeInTheDocument();
|
|
178
|
+
fireEvent.mouseDown(blockInput);
|
|
179
|
+
const blockOption = screen.getByTestId('locationdirective-inline-dropdown-4-option-163434');
|
|
180
|
+
await act(async () => {
|
|
181
|
+
fireEvent.click(blockOption);
|
|
182
|
+
});
|
|
183
|
+
expect(blockInput).toHaveValue('પાલનપુર');
|
|
184
|
+
|
|
185
|
+
const uphcLabel = screen.getByTestId('locationdirective-inline-location-label-4');
|
|
186
|
+
expect(uphcLabel).toHaveTextContent('PHC/UPHC');
|
|
187
|
+
const uphcInput = screen.getByTestId('locationdirective-inline-dropdown-5').querySelector('input');
|
|
188
|
+
expect(uphcInput).toBeInTheDocument();
|
|
189
|
+
fireEvent.mouseDown(uphcInput);
|
|
190
|
+
const uphcOption = screen.getByTestId('locationdirective-inline-dropdown-5-option-453439');
|
|
191
|
+
await act(async () => {
|
|
192
|
+
fireEvent.click(uphcOption);
|
|
193
|
+
});
|
|
194
|
+
expect(uphcInput).toHaveValue('યુપીએચસી પાલનપુર-૧');
|
|
195
|
+
|
|
196
|
+
const anmAreaLabel = screen.getByTestId('locationdirective-inline-location-label-5');
|
|
197
|
+
expect(anmAreaLabel).toHaveTextContent('ANM Area');
|
|
198
|
+
const anmAreaInput = screen.getByTestId('locationdirective-inline-dropdown-6').querySelector('input');
|
|
199
|
+
expect(anmAreaInput).toBeInTheDocument();
|
|
200
|
+
fireEvent.mouseDown(anmAreaInput);
|
|
201
|
+
const anmAreaOption = screen.getByTestId('locationdirective-inline-dropdown-6-option-453860');
|
|
202
|
+
await act(async () => {
|
|
203
|
+
fireEvent.click(anmAreaOption);
|
|
204
|
+
});
|
|
205
|
+
expect(anmAreaInput).toHaveValue('આકેશણ હાઇવે');
|
|
206
|
+
|
|
207
|
+
const anganwadiAreaLabel = screen.getByTestId('locationdirective-inline-location-label-6');
|
|
208
|
+
expect(anganwadiAreaLabel).toHaveTextContent('Anganwadi Area');
|
|
209
|
+
const anganwadiAreaInput = screen.getByTestId('locationdirective-inline-dropdown-7').querySelector('input');
|
|
210
|
+
expect(anganwadiAreaInput).toBeInTheDocument();
|
|
211
|
+
fireEvent.mouseDown(anganwadiAreaInput);
|
|
212
|
+
const anganwadiAreaOption = screen.getByTestId('locationdirective-inline-dropdown-7-option-453869');
|
|
213
|
+
await act(async () => {
|
|
214
|
+
fireEvent.click(anganwadiAreaOption);
|
|
215
|
+
});
|
|
216
|
+
expect(anganwadiAreaInput).toHaveValue('૩૦-સ્રધ્ધા સોસાયટી');
|
|
217
|
+
|
|
218
|
+
const ashaAreaLabel = screen.getByTestId('locationdirective-inline-location-label-7');
|
|
219
|
+
expect(ashaAreaLabel).toHaveTextContent('Asha Area');
|
|
220
|
+
const ashaAreaInput = screen.getByTestId('locationdirective-inline-dropdown-8').querySelector('input');
|
|
221
|
+
expect(ashaAreaInput).toBeInTheDocument();
|
|
222
|
+
fireEvent.mouseDown(ashaAreaInput);
|
|
223
|
+
const ashaAreaOption = screen.getByTestId('locationdirective-inline-dropdown-8-option-453870');
|
|
224
|
+
await act(async () => {
|
|
225
|
+
fireEvent.click(ashaAreaOption);
|
|
226
|
+
});
|
|
227
|
+
expect(ashaAreaInput).toHaveValue('સ્રધ્ધા સોસાયટી');
|
|
228
|
+
});
|
|
229
|
+
});
|