@openmrs/esm-stock-management-app 3.0.1-pre.845 → 3.0.1-pre.853
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/.husky/pre-commit +4 -1
- package/__mocks__/react-i18next.js +8 -9
- package/dist/10.js +1 -1
- package/dist/10.js.map +1 -1
- package/dist/119.js +1 -1
- package/dist/119.js.map +1 -1
- package/dist/14.js +1 -1
- package/dist/14.js.map +1 -1
- package/dist/172.js +1 -1
- package/dist/172.js.map +1 -1
- package/dist/20.js +1 -1
- package/dist/20.js.map +1 -1
- package/dist/290.js +1 -1
- package/dist/290.js.map +1 -1
- package/dist/33.js +1 -0
- package/dist/33.js.map +1 -0
- package/dist/467.js +1 -1
- package/dist/467.js.map +1 -1
- package/dist/574.js +1 -1
- package/dist/606.js +1 -1
- package/dist/606.js.map +1 -1
- package/dist/642.js +1 -1
- package/dist/642.js.map +1 -1
- package/dist/675.js +1 -1
- package/dist/675.js.map +1 -1
- package/dist/727.js +1 -1
- package/dist/727.js.map +1 -1
- package/dist/842.js +1 -1
- package/dist/842.js.map +1 -1
- package/dist/93.js +1 -1
- package/dist/93.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +70 -70
- package/dist/routes.json +1 -1
- package/jest.config.js +6 -3
- package/package.json +1 -1
- package/src/core/components/overlay/overlay.scss +1 -1
- package/src/core/components/privilages-component/privilages.scss +1 -1
- package/src/core/components/table/table.component.tsx +2 -2
- package/src/core/components/table/table.scss +1 -1
- package/src/core/components/tabs/vertical-tabs.scss +1 -1
- package/src/index.ts +5 -5
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +3 -3
- package/src/stock-items/add-bulk-stock-item/{stock-items-bulk-import.component.tsx → stock-items-bulk-import.modal.tsx} +20 -19
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +1 -1
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.test.tsx +59 -59
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +6 -6
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +6 -4
- package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
- package/src/stock-items/add-stock-item/add-stock-item.test.tsx +28 -43
- package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx +3 -4
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +9 -10
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +4 -4
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +27 -19
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +1 -1
- package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.scss +4 -4
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +15 -9
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +1 -0
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +2 -1
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +14 -16
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +7 -3
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal.tsx +14 -6
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-stockcard-preview.modal.tsx +14 -8
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +2 -2
- package/src/stock-items/stock-item.utils.tsx +3 -5
- package/src/stock-items/stock-items-table.component.tsx +47 -45
- package/src/stock-items/stock-items-table.resource.ts +2 -2
- package/src/stock-items/stock-items-table.scss +9 -8
- package/src/stock-items/stock-items-table.test.tsx +106 -65
- package/src/stock-items/stock-items.component.tsx +1 -1
- package/src/stock-locations/location-admin-form.component.tsx +5 -4
- package/src/stock-locations/stock-locations-table.component.tsx +10 -8
- package/src/stock-locations/stock-locations.component.tsx +1 -1
- package/src/stock-lookups/stock-lookups.resource.ts +3 -2
- package/src/stock-management-header/stock-management-header.scss +1 -1
- package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-operation-expanded-row.scss +1 -1
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +2 -2
- package/src/stock-operations/stock-operations-filters.component.tsx +5 -5
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +11 -11
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +115 -25
- package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +107 -65
- package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +9 -9
- package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.test.tsx +35 -153
- package/src/stock-operations/stock-operations-forms/input-components/user-selector.test.tsx +82 -29
- package/src/stock-operations/stock-operations-forms/step1.test.tsx +204 -69
- package/src/stock-operations/stock-operations-forms/step2.test.tsx +140 -63
- package/src/stock-operations/stock-operations-forms/step3.test.tsx +79 -60
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +6 -5
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +12 -11
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.scss +1 -0
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +20 -12
- package/src/stock-operations/stock-operations-forms/stock-operation-form.scss +1 -0
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stepper.scss +1 -3
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +2 -1
- package/src/stock-operations/stock-operations-table.component.tsx +66 -73
- package/src/stock-operations/stock-operations-table.scss +18 -9
- package/src/stock-operations/stock-operations.component.tsx +1 -1
- package/src/stock-reports/generate-report/create-stock-report.scss +3 -2
- package/src/stock-reports/generate-report/create-stock-report.workspace.tsx +32 -25
- package/src/stock-reports/report-list/stock-report-parameters.component.tsx +1 -1
- package/src/stock-reports/report-list/stock-report-status.component.tsx +1 -1
- package/src/stock-reports/report-list/stock-reports.component.tsx +24 -25
- package/src/stock-reports/report-list/stock-reports.scss +11 -3
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +12 -5
- package/src/stock-sources/add-stock-sources/add-stock-sources.test.tsx +38 -36
- package/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx +35 -30
- package/src/stock-sources/delete-stock-modal.component.tsx +2 -1
- package/src/stock-sources/delete-stock-modal.scss +1 -1
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.test.tsx +27 -36
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +33 -21
- package/src/stock-sources/stock-sources-items-table.component.tsx +16 -17
- package/src/stock-sources/stock-sources-items-table.resource.ts +8 -6
- package/src/stock-sources/stock-sources-items-table.test.tsx +60 -37
- package/src/stock-sources/stock-sources.component.tsx +1 -1
- package/src/stock-sources/stock-sources.scss +6 -2
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +5 -13
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +2 -2
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +2 -1
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.scss +1 -1
- package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +1 -1
- package/src/stock-user-role-scopes/stock-user-role-scopes.scss +1 -1
- package/translations/en.json +5 -6
- package/tsconfig.json +4 -0
- package/dist/627.js +0 -1
- package/dist/627.js.map +0 -1
@@ -1,42 +1,51 @@
|
|
1
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
2
1
|
import React from 'react';
|
3
|
-
import
|
2
|
+
import userEvent from '@testing-library/user-event';
|
3
|
+
import { render, screen } from '@testing-library/react';
|
4
|
+
import { useFormContext, type Control, type FieldValues, type UseFormReturn } from 'react-hook-form';
|
5
|
+
import { otherUser } from '../../../core/utils/utils';
|
4
6
|
import { useUser } from '../../../stock-lookups/stock-lookups.resource';
|
5
7
|
import useSearchUser from '../hooks/useSearchUser';
|
6
8
|
import UsersSelector from './users-selector.component';
|
7
|
-
import { otherUser } from '../../../core/utils/utils';
|
8
|
-
import userEvent from '@testing-library/user-event';
|
9
9
|
|
10
|
-
jest.mock('../hooks/useSearchUser')
|
11
|
-
|
10
|
+
jest.mock('../hooks/useSearchUser', () => ({
|
11
|
+
__esModule: true,
|
12
|
+
default: jest.fn(),
|
13
|
+
}));
|
14
|
+
|
15
|
+
jest.mock('../../../stock-lookups/stock-lookups.resource', () => ({
|
16
|
+
useUser: jest.fn(),
|
17
|
+
}));
|
18
|
+
|
12
19
|
jest.mock('react-hook-form', () => ({
|
13
20
|
useFormContext: jest.fn(),
|
14
21
|
Controller: ({ render }) => render({ field: {}, fieldState: {} }),
|
15
22
|
}));
|
16
|
-
jest.mock('react-i18next', () => ({
|
17
|
-
useTranslation: () => ({ t: (key: string) => key }),
|
18
|
-
}));
|
19
23
|
|
20
|
-
const mockUseSearchUser =
|
21
|
-
const mockUseUser =
|
22
|
-
const mockUseFormContext =
|
24
|
+
const mockUseSearchUser = jest.mocked(useSearchUser);
|
25
|
+
const mockUseUser = jest.mocked(useUser);
|
26
|
+
const mockUseFormContext = jest.mocked(useFormContext);
|
23
27
|
|
24
|
-
describe('
|
28
|
+
describe('User Selector', () => {
|
25
29
|
beforeEach(() => {
|
26
|
-
jest.clearAllMocks();
|
27
30
|
mockUseFormContext.mockReturnValue({
|
28
|
-
control: {}
|
31
|
+
control: {} as Control<FieldValues>,
|
29
32
|
watch: jest.fn().mockImplementation((field) => {
|
30
33
|
if (field === 'responsiblePersonUuid') return 'responsibleperson.uuid';
|
31
34
|
if (field === 'responsiblePersonOther') return 'responsiblepersonother.uuid';
|
32
35
|
return '';
|
33
36
|
}),
|
34
37
|
resetField: jest.fn(),
|
35
|
-
});
|
38
|
+
} as Partial<UseFormReturn<FieldValues>> as UseFormReturn<FieldValues>);
|
36
39
|
});
|
37
40
|
|
38
41
|
it('renders loading state', async () => {
|
39
|
-
mockUseSearchUser.mockReturnValue({
|
42
|
+
mockUseSearchUser.mockReturnValue({
|
43
|
+
isLoading: true,
|
44
|
+
userList: [],
|
45
|
+
setSearchString: jest.fn(),
|
46
|
+
setLimit: jest.fn(),
|
47
|
+
setRepresentation: jest.fn(),
|
48
|
+
});
|
40
49
|
mockUseUser.mockReturnValue({ isLoading: true, data: null, error: null });
|
41
50
|
|
42
51
|
render(<UsersSelector />);
|
@@ -46,64 +55,108 @@ describe('UsersSelector', () => {
|
|
46
55
|
|
47
56
|
it('renders error state', () => {
|
48
57
|
const errorMessage = 'Error message';
|
49
|
-
mockUseSearchUser.mockReturnValue({
|
58
|
+
mockUseSearchUser.mockReturnValue({
|
59
|
+
isLoading: false,
|
60
|
+
userList: [],
|
61
|
+
setSearchString: jest.fn(),
|
62
|
+
setLimit: jest.fn(),
|
63
|
+
setRepresentation: jest.fn(),
|
64
|
+
});
|
50
65
|
mockUseUser.mockReturnValue({ isLoading: false, data: null, error: new Error(errorMessage) });
|
66
|
+
|
51
67
|
render(<UsersSelector />);
|
52
|
-
|
68
|
+
|
69
|
+
expect(screen.getByText(/error loading responsible person/i)).toBeInTheDocument();
|
53
70
|
expect(screen.getByText(errorMessage)).toBeInTheDocument();
|
54
71
|
});
|
55
72
|
|
56
73
|
it('renders ComboBox with user list', async () => {
|
74
|
+
const user = userEvent.setup();
|
75
|
+
|
57
76
|
mockUseSearchUser.mockReturnValue({
|
58
77
|
isLoading: false,
|
59
78
|
userList: [
|
60
|
-
{
|
61
|
-
|
79
|
+
{
|
80
|
+
uuid: '1',
|
81
|
+
person: { display: 'User 1', uuid: '1' },
|
82
|
+
display: 'User 1',
|
83
|
+
givenName: 'User',
|
84
|
+
familyName: '1',
|
85
|
+
firstName: 'User',
|
86
|
+
lastName: '1',
|
87
|
+
privileges: [],
|
88
|
+
},
|
89
|
+
{
|
90
|
+
uuid: '2',
|
91
|
+
person: { display: 'User 2', uuid: '2' },
|
92
|
+
display: 'User 2',
|
93
|
+
givenName: 'User',
|
94
|
+
familyName: '2',
|
95
|
+
firstName: 'User',
|
96
|
+
lastName: '2',
|
97
|
+
privileges: [],
|
98
|
+
},
|
62
99
|
],
|
63
100
|
setSearchString: jest.fn(),
|
101
|
+
setLimit: jest.fn(),
|
102
|
+
setRepresentation: jest.fn(),
|
64
103
|
});
|
65
104
|
|
66
105
|
mockUseUser.mockReturnValue({ isLoading: false, data: null, error: null });
|
106
|
+
|
67
107
|
render(<UsersSelector />);
|
68
|
-
|
108
|
+
|
109
|
+
expect(screen.getByText(/responsible person/i)).toBeInTheDocument();
|
69
110
|
const combobox = screen.getByRole('combobox');
|
70
|
-
|
111
|
+
await user.click(combobox);
|
71
112
|
expect(screen.getByText('User 1')).toBeInTheDocument();
|
72
113
|
expect(screen.getByText('User 2')).toBeInTheDocument();
|
73
114
|
});
|
74
115
|
|
75
116
|
it('renders TextInput for other user', async () => {
|
76
|
-
mockUseSearchUser.mockReturnValue({
|
117
|
+
mockUseSearchUser.mockReturnValue({
|
118
|
+
isLoading: false,
|
119
|
+
userList: [],
|
120
|
+
setSearchString: jest.fn(),
|
121
|
+
setLimit: jest.fn(),
|
122
|
+
setRepresentation: jest.fn(),
|
123
|
+
});
|
77
124
|
mockUseFormContext.mockReturnValue({
|
78
|
-
control: {}
|
125
|
+
control: {} as Control<FieldValues>,
|
79
126
|
watch: jest.fn().mockImplementation((field) => {
|
80
127
|
if (field === 'responsiblePersonUuid') return otherUser.uuid;
|
81
128
|
if (field === 'responsiblePersonOther') return '';
|
82
129
|
return '';
|
83
130
|
}),
|
84
131
|
resetField: jest.fn(),
|
85
|
-
});
|
132
|
+
} as Partial<UseFormReturn<FieldValues>> as UseFormReturn<FieldValues>);
|
86
133
|
mockUseUser.mockReturnValue({ isLoading: false, data: null, error: null });
|
87
134
|
|
88
135
|
render(<UsersSelector />);
|
136
|
+
|
89
137
|
expect(screen.getByRole('textbox')).toBeInTheDocument();
|
90
|
-
expect(screen.getByPlaceholderText(
|
138
|
+
expect(screen.getByPlaceholderText(/please specify/i)).toBeInTheDocument();
|
91
139
|
});
|
92
140
|
|
93
141
|
it('calls setSearchString on input change after delay simulating debounce timout', async () => {
|
142
|
+
const user = userEvent.setup();
|
143
|
+
|
94
144
|
const setSearchString = jest.fn();
|
95
145
|
mockUseSearchUser.mockReturnValue({
|
96
146
|
isLoading: false,
|
97
147
|
userList: [],
|
98
148
|
setSearchString,
|
149
|
+
setLimit: jest.fn(),
|
150
|
+
setRepresentation: jest.fn(),
|
99
151
|
});
|
100
152
|
|
101
153
|
mockUseUser.mockReturnValue({ isLoading: false, data: null, error: null });
|
102
154
|
|
103
155
|
render(<UsersSelector />);
|
156
|
+
|
104
157
|
const combobox = screen.getByRole('combobox');
|
105
|
-
await
|
106
|
-
await
|
158
|
+
await user.click(combobox);
|
159
|
+
await user.type(combobox, 'test');
|
107
160
|
await new Promise((resolve) => setTimeout(resolve, 2000)); // Simulate debounce
|
108
161
|
expect(setSearchString).toHaveBeenCalledWith('test');
|
109
162
|
});
|