@argusoft/medplat-app-shell 1.0.5 → 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,165 @@
|
|
|
1
|
+
import MockTranslationProvider from '@/_tests_/__mocks__/MockTranslationProvider';
|
|
2
|
+
import { mockSystemConfig } from '@/_tests_/views/components/SystemConfig/MockSystemConfig';
|
|
3
|
+
import { getSystemConfigs, updateSystemConfig } from '@/common/services/SystemConfig';
|
|
4
|
+
import SystemConfig from '@/views/feature-components/system-config/SystemConfig';
|
|
5
|
+
import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
|
|
6
|
+
import React, { act } from 'react';
|
|
7
|
+
import { useNavigate } from 'react-router-dom';
|
|
8
|
+
|
|
9
|
+
// Mock the necessary imports
|
|
10
|
+
jest.mock('react-i18next', () => ({
|
|
11
|
+
useTranslation: () => ({
|
|
12
|
+
t: (key) => key,
|
|
13
|
+
i18n: { changeLanguage: () => new Promise(() => {}) },
|
|
14
|
+
}),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('../../../../common/services/SystemConfig', () => ({
|
|
18
|
+
getSystemConfigs: jest.fn(),
|
|
19
|
+
updateSystemConfig: jest.fn(),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
jest.mock('../../../../utils/feature', () => ({
|
|
23
|
+
getAssignedFeatures: jest.fn().mockResolvedValue({
|
|
24
|
+
data: '{"canAdd": true}',
|
|
25
|
+
}),
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
jest.mock('../../../../common/toaster/toaster', () => ({
|
|
29
|
+
showToast: jest.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
jest.mock('react-router', () => ({
|
|
33
|
+
useNavigate: jest.fn(),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
jest.mock('../../../../assets/img/medplat-highres.png', () => 'test-image-path');
|
|
37
|
+
|
|
38
|
+
describe('SystemConfig Component', () => {
|
|
39
|
+
const renderComponent = async () => {
|
|
40
|
+
await act(async () => {
|
|
41
|
+
render(
|
|
42
|
+
<MockTranslationProvider>
|
|
43
|
+
<SystemConfig />
|
|
44
|
+
</MockTranslationProvider>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
let mockedNavigate;
|
|
49
|
+
|
|
50
|
+
beforeEach(async () => {
|
|
51
|
+
mockedNavigate = jest.fn();
|
|
52
|
+
useNavigate.mockImplementation(() => mockedNavigate);
|
|
53
|
+
getSystemConfigs.mockResolvedValue(mockSystemConfig);
|
|
54
|
+
await renderComponent();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
jest.clearAllMocks();
|
|
59
|
+
cleanup();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should render the system config table and match row length', async () => {
|
|
63
|
+
const table = screen.getByTestId('systemconfig-customizedtable-main');
|
|
64
|
+
expect(table).toBeInTheDocument();
|
|
65
|
+
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
const rows = within(table).getAllByRole('row');
|
|
68
|
+
expect(rows.length).toBeGreaterThan(1);
|
|
69
|
+
expect(rows.length).toBe(mockSystemConfig.data.result.length + 1);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should render the add button on screen ', async () => {
|
|
74
|
+
const AddButton = screen.getByTestId('systemconfig-button-add');
|
|
75
|
+
expect(AddButton).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should call the Search field to search the value in Table', async () => {
|
|
79
|
+
const searchInput = screen.getByPlaceholderText(/Search Text/);
|
|
80
|
+
expect(searchInput).toBeInTheDocument();
|
|
81
|
+
|
|
82
|
+
await act(async () => {
|
|
83
|
+
fireEvent.change(searchInput, { target: { value: 'system_v' } });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const table = screen.getByTestId('systemconfig-customizedtable-main');
|
|
87
|
+
const rows = within(table).getAllByRole('row');
|
|
88
|
+
await waitFor(() => {
|
|
89
|
+
expect(table).toBeInTheDocument();
|
|
90
|
+
|
|
91
|
+
expect(rows.length).toBe(2);
|
|
92
|
+
expect(rows[1]).toHaveTextContent('SYSTEM_VERSION');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should call the Add button to add the new Location Type', async () => {
|
|
97
|
+
const addButton = screen.getByTestId('systemconfig-button-add');
|
|
98
|
+
expect(addButton).toBeInTheDocument();
|
|
99
|
+
fireEvent.click(addButton);
|
|
100
|
+
await waitFor(() => {
|
|
101
|
+
expect(mockedNavigate).toHaveBeenCalledWith('/ui/medplat/manage/systemconfigs/managesystemconfig');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
it('should render modal on clicking on menuicon ', async () => {
|
|
105
|
+
const table = screen.getByTestId('systemconfig-customizedtable-main');
|
|
106
|
+
const rows = within(table).getAllByRole('row');
|
|
107
|
+
|
|
108
|
+
const menuIcon = within(rows[1]).getByTestId('MenuIcon');
|
|
109
|
+
await act(async () => {
|
|
110
|
+
fireEvent.click(menuIcon);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const menuDropdown = screen.getByRole('menuitem');
|
|
114
|
+
expect(menuDropdown).toHaveTextContent('Mark as Inactive');
|
|
115
|
+
|
|
116
|
+
await act(async () => {
|
|
117
|
+
fireEvent.click(menuDropdown);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const modal = screen.getByTestId('systemconfig-modal-confirmation');
|
|
121
|
+
|
|
122
|
+
const modalTitle = within(modal).getByTestId('systemconfig-modal-confirmation-title');
|
|
123
|
+
const modalClose = within(modal).getByTestId('systemconfig-modal-confirmation-close-button');
|
|
124
|
+
const modalDescription = within(modal).getByTestId('systemconfig-modal-confirmation-description');
|
|
125
|
+
const modalNoButton = within(modal).getByTestId('systemconfig-modal-confirmation-no-button');
|
|
126
|
+
const modalYesButton = within(modal).getByTestId('systemconfig-modal-confirmation-yes-button');
|
|
127
|
+
|
|
128
|
+
expect(modalTitle).toHaveTextContent('CONFIRMACTION');
|
|
129
|
+
expect(modalClose).toBeInTheDocument();
|
|
130
|
+
expect(modalDescription).toHaveTextContent(
|
|
131
|
+
'Are you sure you want to change the state of this System configuration ?'
|
|
132
|
+
);
|
|
133
|
+
expect(modalNoButton).toHaveTextContent('No');
|
|
134
|
+
expect(modalYesButton).toHaveTextContent('Yes');
|
|
135
|
+
|
|
136
|
+
await act(async () => {
|
|
137
|
+
fireEvent.click(modalYesButton);
|
|
138
|
+
});
|
|
139
|
+
await waitFor(() => {
|
|
140
|
+
expect(updateSystemConfig).toHaveBeenCalled();
|
|
141
|
+
});
|
|
142
|
+
await act(async () => {
|
|
143
|
+
fireEvent.click(menuIcon);
|
|
144
|
+
});
|
|
145
|
+
}, 100000);
|
|
146
|
+
it('should navigate to the on click on the edit button', async () => {
|
|
147
|
+
const searchInput = screen.getByPlaceholderText(/Search Text/);
|
|
148
|
+
expect(searchInput).toBeInTheDocument();
|
|
149
|
+
|
|
150
|
+
await act(async () => {
|
|
151
|
+
fireEvent.change(searchInput, { target: { value: 'system_v' } });
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const table = screen.getByTestId('systemconfig-customizedtable-main');
|
|
155
|
+
const rows = within(table).getAllByRole('row');
|
|
156
|
+
|
|
157
|
+
const editIcon = within(rows[1]).getByTestId('EditIcon');
|
|
158
|
+
await act(async () => {
|
|
159
|
+
fireEvent.click(editIcon);
|
|
160
|
+
});
|
|
161
|
+
await waitFor(() => {
|
|
162
|
+
expect(mockedNavigate).toHaveBeenCalledWith('/ui/medplat/manage/systemconfigs/managesystemconfig/SYSTEM_VERSION');
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent, waitFor, cleanup } from '@testing-library/react';
|
|
3
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
4
|
+
import { useNavigate } from 'react-router-dom';
|
|
5
|
+
import Login from '@/views/feature-components/login/Login.jsx'; // Adjust the path as necessary
|
|
6
|
+
import {
|
|
7
|
+
loginService,
|
|
8
|
+
getLoggedInUser,
|
|
9
|
+
getFeatures,
|
|
10
|
+
getApkInfo,
|
|
11
|
+
getSystemNotice,
|
|
12
|
+
} from '@/common/services/AuthenticateService';
|
|
13
|
+
import { showToast } from '@/common/toaster/toaster';
|
|
14
|
+
import {
|
|
15
|
+
loginServiceResponse,
|
|
16
|
+
mockGetFeatureResponse,
|
|
17
|
+
mockLoggedInUserResponse,
|
|
18
|
+
mockLoggeinUser,
|
|
19
|
+
} from '@/_tests_/views/components/login/ServiceResponse';
|
|
20
|
+
|
|
21
|
+
// jest.mock('../../../../assets/img/medplat-highres.png', () => 'test-image-path');
|
|
22
|
+
|
|
23
|
+
// Mock services and utilities
|
|
24
|
+
jest.mock('@/common/services/AuthenticateService', () => ({
|
|
25
|
+
getKeyAndIV: jest.fn(),
|
|
26
|
+
loginService: jest.fn(),
|
|
27
|
+
getLoggedInUser: jest.fn(),
|
|
28
|
+
getFeatures: jest.fn(),
|
|
29
|
+
getApkInfo: jest.fn(),
|
|
30
|
+
getSystemNotice: jest.fn(),
|
|
31
|
+
}));
|
|
32
|
+
jest.mock('@/common/toaster/toaster', () => ({
|
|
33
|
+
showToast: jest.fn(),
|
|
34
|
+
}));
|
|
35
|
+
jest.mock('react-redux', () => ({
|
|
36
|
+
useSelector: jest.fn(),
|
|
37
|
+
useDispatch: jest.fn(),
|
|
38
|
+
}));
|
|
39
|
+
jest.mock('react-router-dom', () => ({
|
|
40
|
+
...jest.requireActual('react-router-dom'),
|
|
41
|
+
useNavigate: jest.fn(),
|
|
42
|
+
}));
|
|
43
|
+
jest.mock('react-redux', () => ({
|
|
44
|
+
useSelector: jest.fn(),
|
|
45
|
+
useDispatch: jest.fn(),
|
|
46
|
+
}));
|
|
47
|
+
jest.mock('react-router-dom', () => ({
|
|
48
|
+
...jest.requireActual('react-router-dom'),
|
|
49
|
+
useNavigate: jest.fn(),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
describe('Login Component', () => {
|
|
53
|
+
const renderComponent = async () => render(<Login />);
|
|
54
|
+
|
|
55
|
+
beforeEach(async () => {
|
|
56
|
+
const mockNavigate = jest.fn();
|
|
57
|
+
const mockDispatch = jest.fn();
|
|
58
|
+
useSelector.mockImplementation((callback) =>
|
|
59
|
+
callback({
|
|
60
|
+
Authenticate: { user: mockLoggeinUser },
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
useDispatch.mockReturnValue(mockDispatch);
|
|
64
|
+
useNavigate.mockImplementation(() => mockNavigate);
|
|
65
|
+
|
|
66
|
+
getApkInfo.mockResolvedValue({
|
|
67
|
+
data: '',
|
|
68
|
+
status: 200,
|
|
69
|
+
statusText: '',
|
|
70
|
+
headers: {
|
|
71
|
+
'cache-control': 'no-cache, no-store, must-revalidate',
|
|
72
|
+
'content-length': '0',
|
|
73
|
+
expires: 'Wed, 31 Dec 1969 23:59:59 GMT',
|
|
74
|
+
pragma: 'no-cache',
|
|
75
|
+
},
|
|
76
|
+
config: {
|
|
77
|
+
transitional: {
|
|
78
|
+
silentJSONParsing: true,
|
|
79
|
+
forcedJSONParsing: true,
|
|
80
|
+
clarifyTimeoutError: false,
|
|
81
|
+
},
|
|
82
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
83
|
+
transformRequest: [null],
|
|
84
|
+
transformResponse: [null],
|
|
85
|
+
timeout: 0,
|
|
86
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
87
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
88
|
+
maxContentLength: -1,
|
|
89
|
+
maxBodyLength: -1,
|
|
90
|
+
env: {},
|
|
91
|
+
headers: {
|
|
92
|
+
Accept: 'application/json, text/plain, */*',
|
|
93
|
+
},
|
|
94
|
+
baseURL: 'http://localhost:8181/api',
|
|
95
|
+
method: 'get',
|
|
96
|
+
url: '/mobile/systemNotice',
|
|
97
|
+
},
|
|
98
|
+
request: {},
|
|
99
|
+
});
|
|
100
|
+
getSystemNotice.mockResolvedValue({
|
|
101
|
+
data: '',
|
|
102
|
+
status: 200,
|
|
103
|
+
statusText: '',
|
|
104
|
+
headers: {
|
|
105
|
+
'cache-control': 'no-cache, no-store, must-revalidate',
|
|
106
|
+
'content-length': '0',
|
|
107
|
+
expires: 'Wed, 31 Dec 1969 23:59:59 GMT',
|
|
108
|
+
pragma: 'no-cache',
|
|
109
|
+
},
|
|
110
|
+
config: {
|
|
111
|
+
transitional: {
|
|
112
|
+
silentJSONParsing: true,
|
|
113
|
+
forcedJSONParsing: true,
|
|
114
|
+
clarifyTimeoutError: false,
|
|
115
|
+
},
|
|
116
|
+
adapter: ['xhr', 'http', 'fetch'],
|
|
117
|
+
transformRequest: [null],
|
|
118
|
+
transformResponse: [null],
|
|
119
|
+
timeout: 0,
|
|
120
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
121
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
122
|
+
maxContentLength: -1,
|
|
123
|
+
maxBodyLength: -1,
|
|
124
|
+
env: {},
|
|
125
|
+
headers: {
|
|
126
|
+
Accept: 'application/json, text/plain, */*',
|
|
127
|
+
},
|
|
128
|
+
method: 'get',
|
|
129
|
+
url: 'http://localhost:8181/api/mobile/systemNotice',
|
|
130
|
+
},
|
|
131
|
+
request: {},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
await renderComponent();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
afterEach(() => {
|
|
138
|
+
cleanup();
|
|
139
|
+
jest.clearAllMocks(); // Clears any mocks/spies created with jest.fn or jest.spyOn
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('renders the Login component', async () => {
|
|
143
|
+
expect(screen.getByTestId('Login Form')).toBeInTheDocument();
|
|
144
|
+
expect(screen.getByTestId('username')).toBeInTheDocument();
|
|
145
|
+
expect(screen.getByRole('textbox', { id: 'username' })).toBeInTheDocument();
|
|
146
|
+
expect(screen.getByRole('textbox', { id: 'password' })).toBeInTheDocument();
|
|
147
|
+
expect(screen.getByRole('button', { name: 'Login' })).toBeInTheDocument();
|
|
148
|
+
expect(screen.getByRole('link', { name: 'Forgot password?' })).toBeInTheDocument();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('shows validation errors', async () => {
|
|
152
|
+
fireEvent.click(screen.getByRole('button', { name: 'Login' }));
|
|
153
|
+
|
|
154
|
+
let errorMessages;
|
|
155
|
+
await waitFor(() => {
|
|
156
|
+
errorMessages = screen.getAllByTestId('custom-error-message');
|
|
157
|
+
errorMessages = errorMessages.map((msg) => msg.textContent.trim());
|
|
158
|
+
expect(errorMessages).toHaveLength(2);
|
|
159
|
+
|
|
160
|
+
expect(errorMessages).toContain('Username is required');
|
|
161
|
+
expect(errorMessages).toContain('Password is required');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const usernameInput = screen.getByPlaceholderText(/username/i);
|
|
165
|
+
fireEvent.change(usernameInput, { target: { value: 'testuser' } });
|
|
166
|
+
await waitFor(() => {
|
|
167
|
+
expect(usernameInput.value).toBe('testuser');
|
|
168
|
+
errorMessages = screen.getAllByTestId('custom-error-message');
|
|
169
|
+
errorMessages = errorMessages.map((msg) => msg.textContent.trim());
|
|
170
|
+
expect(errorMessages).toHaveLength(1);
|
|
171
|
+
expect(errorMessages).not.toContain('Username is required');
|
|
172
|
+
expect(errorMessages).toContain('Password is required');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const passwordInput = screen.getByPlaceholderText(/password/i);
|
|
176
|
+
fireEvent.change(passwordInput, { target: { value: '123456789' } });
|
|
177
|
+
await waitFor(() => {
|
|
178
|
+
expect(passwordInput.value).toBe('123456789');
|
|
179
|
+
expect(screen.queryByTestId('custom-error-message')).not.toBeInTheDocument();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('calls the loginService and handles successful login', async () => {
|
|
184
|
+
loginService.mockResolvedValue(loginServiceResponse);
|
|
185
|
+
getLoggedInUser.mockResolvedValue(mockLoggedInUserResponse);
|
|
186
|
+
getFeatures.mockResolvedValue(mockGetFeatureResponse);
|
|
187
|
+
|
|
188
|
+
const usernameInput = screen.getByPlaceholderText(/username/i);
|
|
189
|
+
const passwordInput = screen.getByPlaceholderText(/password/i);
|
|
190
|
+
|
|
191
|
+
fireEvent.input(usernameInput, {
|
|
192
|
+
target: { value: 'ppratham' },
|
|
193
|
+
});
|
|
194
|
+
fireEvent.input(passwordInput, {
|
|
195
|
+
target: { value: '12345678' },
|
|
196
|
+
});
|
|
197
|
+
fireEvent.click(screen.getByRole('button', { name: /login/i }));
|
|
198
|
+
|
|
199
|
+
await waitFor(() => {
|
|
200
|
+
expect(loginService).toHaveBeenCalledWith('ppratham', '12345678');
|
|
201
|
+
expect(getLoggedInUser).toHaveBeenCalled();
|
|
202
|
+
expect(getFeatures).toHaveBeenCalled();
|
|
203
|
+
// expect(mockedUseNavigate).toHaveBeenCalled()
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('shows a toast message on failed login', async () => {
|
|
208
|
+
loginService.mockImplementation(
|
|
209
|
+
() =>
|
|
210
|
+
new Promise((resolve, reject) =>
|
|
211
|
+
setTimeout(
|
|
212
|
+
() =>
|
|
213
|
+
reject({
|
|
214
|
+
response: {
|
|
215
|
+
data: {
|
|
216
|
+
error: 'invalid_grant',
|
|
217
|
+
error_description: 'Bad Credentials',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
100
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const usernameInput = screen.getByPlaceholderText(/username/i); // Adjust if necessary
|
|
227
|
+
const passwordInput = screen.getByPlaceholderText(/password/i);
|
|
228
|
+
|
|
229
|
+
// Trigger a change event on the username and password inputs
|
|
230
|
+
fireEvent.change(usernameInput, { target: { value: 'testuser' } });
|
|
231
|
+
fireEvent.change(passwordInput, { target: { value: '123456789' } });
|
|
232
|
+
fireEvent.click(screen.getByRole('button', { name: 'Login' }));
|
|
233
|
+
|
|
234
|
+
await waitFor(() => {
|
|
235
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
236
|
+
message: 'Bad Credentials',
|
|
237
|
+
type: 'error',
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('shows a toast message and lock account on 3rd failed login', async () => {
|
|
243
|
+
loginService.mockImplementation(
|
|
244
|
+
() =>
|
|
245
|
+
new Promise((resolve, reject) =>
|
|
246
|
+
setTimeout(
|
|
247
|
+
() =>
|
|
248
|
+
reject({
|
|
249
|
+
response: {
|
|
250
|
+
data: {
|
|
251
|
+
error: 'invalid_grant',
|
|
252
|
+
error_description: 'Your account is locked for 15 minutes. Please try again later',
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
256
|
+
100
|
|
257
|
+
)
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const usernameInput = screen.getByPlaceholderText(/username/i); // Adjust if necessary
|
|
262
|
+
const passwordInput = screen.getByPlaceholderText(/password/i);
|
|
263
|
+
|
|
264
|
+
// Trigger a change event on the username and password inputs
|
|
265
|
+
fireEvent.change(usernameInput, { target: { value: 'testuser' } });
|
|
266
|
+
fireEvent.change(passwordInput, { target: { value: '123456789' } });
|
|
267
|
+
fireEvent.click(screen.getByRole('button', { name: 'Login' }));
|
|
268
|
+
|
|
269
|
+
await waitFor(() => {
|
|
270
|
+
expect(showToast).toHaveBeenCalledWith({
|
|
271
|
+
message: 'Your account is locked for 15 minutes. Please try again later',
|
|
272
|
+
type: 'error',
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
});
|