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