@openmrs/esm-stock-management-app 3.0.1-pre.848 → 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/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.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-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 +5 -1
- package/src/stock-items/stock-items-table.test.tsx +106 -65
- 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-lookups/stock-lookups.resource.ts +3 -2
- 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 +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-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 +10 -2
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +11 -4
- 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/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.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/translations/en.json +5 -6
- package/tsconfig.json +4 -0
- package/dist/627.js +0 -1
- package/dist/627.js.map +0 -1
package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx
CHANGED
@@ -1,64 +1,66 @@
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
2
|
-
import userEvent from '@testing-library/user-event';
|
3
1
|
import React from 'react';
|
2
|
+
import userEvent from '@testing-library/user-event';
|
3
|
+
import { render, screen } from '@testing-library/react';
|
4
4
|
import { useStockItem } from '../../../stock-items/stock-items.resource';
|
5
5
|
import QtyUomSelector from './quantity-uom-selector.component';
|
6
6
|
|
7
|
-
jest.mock('../../../stock-items/stock-items.resource')
|
8
|
-
jest.
|
9
|
-
|
7
|
+
jest.mock('../../../stock-items/stock-items.resource', () => ({
|
8
|
+
useStockItem: jest.fn().mockReturnValue({
|
9
|
+
isLoading: false,
|
10
|
+
item: {},
|
11
|
+
error: null,
|
12
|
+
}),
|
13
|
+
useStockItems: jest.fn().mockReturnValue({
|
14
|
+
isLoading: false,
|
15
|
+
error: null,
|
16
|
+
items: {},
|
17
|
+
}),
|
18
|
+
useStockBatches: jest.fn().mockReturnValue({
|
19
|
+
isLoading: false,
|
20
|
+
error: null,
|
21
|
+
items: {},
|
22
|
+
}),
|
10
23
|
}));
|
11
24
|
|
12
|
-
const mockUseStockItem =
|
25
|
+
const mockUseStockItem = jest.mocked(useStockItem);
|
13
26
|
|
14
27
|
describe('QtyUOMSelector', () => {
|
15
28
|
const mockOnValueChange = jest.fn();
|
16
29
|
const mockStockItemUuid = 'test-uuid';
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
drugName: 'Ibuprofen Injection solution 5mg/mL ',
|
21
|
-
conceptUuid: '77897AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
22
|
-
conceptName: 'IBUPROFEN',
|
23
|
-
hasExpiration: true,
|
24
|
-
preferredVendorUuid: 'b7e481ef-06e7-46ba-8a7c-ab077aa3355f',
|
25
|
-
preferredVendorName: 'Kenya Medical Supplies Authority',
|
26
|
-
purchasePrice: 100.0,
|
27
|
-
purchasePriceUoMUuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
28
|
-
purchasePriceUoMName: 'Box',
|
29
|
-
purchasePriceUoMFactor: 10.0,
|
30
|
-
dispensingUnitName: 'Tablet',
|
31
|
-
dispensingUnitUuid: '1513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
32
|
-
dispensingUnitPackagingUoMUuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
33
|
-
dispensingUnitPackagingUoMName: 'Box',
|
34
|
-
dispensingUnitPackagingUoMFactor: 10.0,
|
35
|
-
defaultStockOperationsUoMUuid: null,
|
36
|
-
defaultStockOperationsUoMName: null,
|
37
|
-
defaultStockOperationsUoMFactor: null,
|
38
|
-
categoryUuid: '183f9497-b72e-4ebe-ae17-5dcf110ff3b6',
|
30
|
+
|
31
|
+
const mockStockItem = {
|
32
|
+
acronym: null,
|
39
33
|
categoryName: 'Other Lymph Node Comments',
|
34
|
+
categoryUuid: '183f9497-b72e-4ebe-ae17-5dcf110ff3b6',
|
40
35
|
commonName: 'Ibuprofen 5 MG/ML Injectable Solution',
|
41
|
-
|
42
|
-
|
43
|
-
reorderLevelUoMUuid: null,
|
44
|
-
reorderLevelUoMName: null,
|
45
|
-
reorderLevelUoMFactor: null,
|
46
|
-
dateCreated: '2024-09-03T09:46:47.000+0300',
|
47
|
-
creatorGivenName: 'Mark',
|
36
|
+
conceptName: 'IBUPROFEN',
|
37
|
+
conceptUuid: '77897AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
48
38
|
creatorFamilyName: 'Miller',
|
49
|
-
|
39
|
+
creatorGivenName: 'Mark',
|
40
|
+
dateCreated: new Date('2024-09-03T09:46:47.000+0300'),
|
41
|
+
defaultStockOperationsUoMFactor: null,
|
42
|
+
defaultStockOperationsUoMName: null,
|
43
|
+
defaultStockOperationsUoMUuid: null,
|
44
|
+
dispensingUnitName: 'Tablet',
|
45
|
+
dispensingUnitPackagingUoMFactor: 10.0,
|
46
|
+
dispensingUnitPackagingUoMName: 'Box',
|
47
|
+
dispensingUnitPackagingUoMUuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
48
|
+
dispensingUnitUuid: '1513AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
49
|
+
drugName: 'Ibuprofen Injection solution 5mg/mL ',
|
50
|
+
drugUuid: '1776AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
|
50
51
|
expiryNotice: 180,
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
hasExpiration: true,
|
53
|
+
isDrug: true,
|
54
|
+
links: [
|
55
|
+
{
|
56
|
+
rel: 'self',
|
57
|
+
uri: 'http://hie.kenyahmis.org/openmrs/ws/rest/v1/stockmanagement/stockitem/33225466-93c8-4720-b110-4f445f3764c6',
|
58
|
+
resourceAlias: 'stockitem',
|
59
|
+
},
|
60
|
+
],
|
55
61
|
packagingUnits: [
|
56
62
|
{
|
57
|
-
uuid: '8023ef7d-56da-442f-bc74-319f000840b4',
|
58
63
|
factor: 1.0,
|
59
|
-
packagingUomUuid: '162382AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
60
|
-
packagingUomName: 'Vial',
|
61
|
-
stockItemUuid: '33225466-93c8-4720-b110-4f445f3764c6',
|
62
64
|
isDefaultStockOperationsUoM: false,
|
63
65
|
isDispensingUnit: false,
|
64
66
|
links: [
|
@@ -68,14 +70,14 @@ describe('QtyUOMSelector', () => {
|
|
68
70
|
resourceAlias: 'stockitempackaginguom',
|
69
71
|
},
|
70
72
|
],
|
73
|
+
packagingUomName: 'Vial',
|
74
|
+
packagingUomUuid: '162382AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
71
75
|
resourceVersion: '1.8',
|
76
|
+
stockItemUuid: '33225466-93c8-4720-b110-4f445f3764c6',
|
77
|
+
uuid: '8023ef7d-56da-442f-bc74-319f000840b4',
|
72
78
|
},
|
73
79
|
{
|
74
|
-
uuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
75
80
|
factor: 10.0,
|
76
|
-
packagingUomUuid: '162396AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
77
|
-
packagingUomName: 'Box',
|
78
|
-
stockItemUuid: '33225466-93c8-4720-b110-4f445f3764c6',
|
79
81
|
isDefaultStockOperationsUoM: false,
|
80
82
|
isDispensingUnit: true,
|
81
83
|
links: [
|
@@ -85,73 +87,113 @@ describe('QtyUOMSelector', () => {
|
|
85
87
|
resourceAlias: 'stockitempackaginguom',
|
86
88
|
},
|
87
89
|
],
|
90
|
+
packagingUomName: 'Box',
|
91
|
+
packagingUomUuid: '162396AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
88
92
|
resourceVersion: '1.8',
|
93
|
+
stockItemUuid: '33225466-93c8-4720-b110-4f445f3764c6',
|
94
|
+
uuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
89
95
|
},
|
90
96
|
],
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
97
|
+
permission: {
|
98
|
+
canApprove: false,
|
99
|
+
canDisplayReceivedItems: false,
|
100
|
+
canEdit: true,
|
101
|
+
canReceiveItems: false,
|
102
|
+
canUpdateBatchInformation: false,
|
103
|
+
canView: true,
|
104
|
+
isRequisitionAndCanIssueStock: false,
|
105
|
+
},
|
106
|
+
preferredVendorName: 'Kenya Medical Supplies Authority',
|
107
|
+
preferredVendorUuid: 'b7e481ef-06e7-46ba-8a7c-ab077aa3355f',
|
108
|
+
purchasePrice: 100.0,
|
109
|
+
purchasePriceUoMFactor: 10.0,
|
110
|
+
purchasePriceUoMName: 'Box',
|
111
|
+
purchasePriceUoMUuid: '65dc9ec7-0663-4cf0-a35c-6a2d2cf99eee',
|
112
|
+
reorderLevel: null,
|
113
|
+
reorderLevelUoMFactor: null,
|
114
|
+
reorderLevelUoMName: null,
|
115
|
+
reorderLevelUoMUuid: null,
|
99
116
|
resourceVersion: '1.8',
|
117
|
+
uuid: '33225466-93c8-4720-b110-4f445f3764c6',
|
118
|
+
voided: false,
|
100
119
|
};
|
101
120
|
|
102
121
|
beforeEach(() => {
|
103
|
-
jest.clearAllMocks();
|
104
122
|
mockUseStockItem.mockReturnValue({
|
105
123
|
isLoading: false,
|
106
|
-
item:
|
124
|
+
item: mockStockItem,
|
125
|
+
error: null,
|
107
126
|
});
|
108
127
|
});
|
128
|
+
|
109
129
|
it('should render Skeleton when loading stock item', () => {
|
110
|
-
mockUseStockItem.mockReturnValue({ isLoading: true });
|
130
|
+
mockUseStockItem.mockReturnValue({ isLoading: true, item: mockStockItem, error: null });
|
131
|
+
|
111
132
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} />);
|
133
|
+
|
112
134
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
113
135
|
});
|
136
|
+
|
114
137
|
it('should render Inline notification error when error ocuured while fetching item', () => {
|
115
138
|
const errorMessage = 'error loading stock item';
|
116
|
-
mockUseStockItem.mockReturnValue({ isLoading: false, error: new Error(errorMessage) });
|
139
|
+
mockUseStockItem.mockReturnValue({ isLoading: false, error: new Error(errorMessage), item: mockStockItem });
|
140
|
+
|
117
141
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} />);
|
142
|
+
|
118
143
|
expect(screen.getByText(errorMessage)).toBeInTheDocument();
|
119
144
|
expect(screen.getByRole('status')).toBeInTheDocument();
|
120
145
|
});
|
146
|
+
|
121
147
|
it('should render Inline notification error when error ocuured while fetching item', () => {
|
122
148
|
const errorMessage = 'error loading stock item';
|
123
|
-
mockUseStockItem.mockReturnValue({ isLoading: false, error: new Error(errorMessage) });
|
149
|
+
mockUseStockItem.mockReturnValue({ isLoading: false, error: new Error(errorMessage), item: mockStockItem });
|
150
|
+
|
124
151
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} />);
|
152
|
+
|
125
153
|
expect(screen.getByText(errorMessage)).toBeInTheDocument();
|
126
154
|
expect(screen.getByRole('status')).toBeInTheDocument();
|
127
155
|
});
|
128
156
|
|
129
157
|
it('should display error message when error prop is provided', () => {
|
130
158
|
const errorMessage = 'This is an error';
|
159
|
+
|
131
160
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} error={errorMessage} />);
|
161
|
+
|
132
162
|
expect(screen.getByText(errorMessage)).toBeInTheDocument();
|
133
163
|
});
|
164
|
+
|
134
165
|
it('should display error message when error prop is provided', () => {
|
135
166
|
const errorMessage = 'This is an error';
|
167
|
+
|
136
168
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} error={errorMessage} />);
|
169
|
+
|
137
170
|
expect(screen.getByText(errorMessage)).toBeInTheDocument();
|
138
171
|
});
|
139
172
|
|
140
173
|
it('should render packing uom options', async () => {
|
174
|
+
const user = userEvent.setup();
|
175
|
+
|
141
176
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} />);
|
177
|
+
|
142
178
|
const combobox = screen.getByRole('combobox');
|
143
|
-
await
|
144
|
-
|
179
|
+
await user.click(combobox);
|
180
|
+
|
181
|
+
mockStockItem.packagingUnits.forEach(({ factor, packagingUomName }) => {
|
145
182
|
expect(screen.getByText(`${packagingUomName} - ${factor}`)).toBeInTheDocument();
|
146
183
|
});
|
147
184
|
});
|
185
|
+
|
148
186
|
it('should packing uom selection', async () => {
|
149
|
-
const
|
187
|
+
const user = userEvent.setup();
|
188
|
+
const itemToSelect = mockStockItem.packagingUnits[1];
|
189
|
+
|
150
190
|
render(<QtyUomSelector stockItemUuid={mockStockItemUuid} onValueChange={mockOnValueChange} />);
|
191
|
+
|
151
192
|
const combobox = screen.getByRole('combobox');
|
152
193
|
await userEvent.click(combobox);
|
194
|
+
|
153
195
|
const option = screen.getByText(`${itemToSelect.packagingUomName} - ${itemToSelect.factor}`);
|
154
|
-
await
|
196
|
+
await user.click(option);
|
155
197
|
expect(mockOnValueChange).toHaveBeenCalledWith(itemToSelect.uuid);
|
156
198
|
});
|
157
199
|
});
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { ComboBox, InlineNotification, SkeletonText } from '@carbon/react';
|
2
1
|
import React, { useMemo } from 'react';
|
2
|
+
import { ComboBox, InlineNotification, SkeletonText } from '@carbon/react';
|
3
3
|
import { useTranslation } from 'react-i18next';
|
4
4
|
import { type StockItemPackagingUOMDTO } from '../../../core/api/types/stockItem/StockItemPackagingUOM';
|
5
5
|
import { useStockItem } from '../../../stock-items/stock-items.resource';
|
@@ -32,20 +32,20 @@ const QtyUomSelector: React.FC<QtyUomSelectorProps> = ({ stockItemUuid, error, i
|
|
32
32
|
|
33
33
|
return (
|
34
34
|
<ComboBox
|
35
|
-
titleText={t('quantityUom', 'Qty UoM')}
|
36
|
-
name={'stockItemPackagingUOMUuid'}
|
37
35
|
id={'stockItemPackagingUOMUuid'}
|
38
|
-
items={item?.packagingUnits ?? []}
|
39
|
-
onChange={(data: { selectedItem?: StockItemPackagingUOMDTO }) => {
|
40
|
-
onValueChange?.(data.selectedItem?.uuid);
|
41
|
-
}}
|
42
36
|
initialSelectedItem={initialSelectedItem}
|
37
|
+
invalid={!!error}
|
38
|
+
invalidText={error}
|
39
|
+
items={item?.packagingUnits ?? []}
|
43
40
|
itemToString={(s: StockItemPackagingUOMDTO) =>
|
44
41
|
s.packagingUomName ? `${s?.packagingUomName} - ${s?.factor} ` : ''
|
45
42
|
}
|
43
|
+
name={'stockItemPackagingUOMUuid'}
|
44
|
+
onChange={(data: { selectedItem?: StockItemPackagingUOMDTO }) => {
|
45
|
+
onValueChange?.(data.selectedItem?.uuid);
|
46
|
+
}}
|
46
47
|
placeholder={t('filter', 'Filter') + '...'}
|
47
|
-
|
48
|
-
invalidText={error}
|
48
|
+
titleText={t('quantityUom', 'Qty UoM')}
|
49
49
|
/>
|
50
50
|
);
|
51
51
|
};
|
@@ -1,215 +1,97 @@
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
2
|
-
import userEvent from '@testing-library/user-event';
|
3
1
|
import React from 'react';
|
4
|
-
|
2
|
+
import userEvent from '@testing-library/user-event';
|
3
|
+
import { render, screen } from '@testing-library/react';
|
4
|
+
import { type FieldValues, useFormContext, type UseFormReturn } from 'react-hook-form';
|
5
5
|
import { useConfig } from '@openmrs/esm-framework';
|
6
|
-
import { useFormContext } from 'react-hook-form';
|
7
6
|
import { useConcept } from '../../../stock-lookups/stock-lookups.resource';
|
8
7
|
import StockOperationReasonSelector from './stock-operation-reason-selector.component';
|
9
8
|
|
10
|
-
|
11
|
-
jest.
|
12
|
-
|
13
|
-
}));
|
9
|
+
const mockUseConfig = jest.mocked(useConfig);
|
10
|
+
const mockUseConcept = jest.mocked(useConcept);
|
11
|
+
const mockUseFormContext = jest.mocked(useFormContext);
|
14
12
|
|
15
13
|
jest.mock('react-hook-form', () => ({
|
16
14
|
useFormContext: jest.fn(),
|
17
15
|
Controller: ({ render }) => render({ field: {}, fieldState: {} }),
|
18
16
|
}));
|
19
|
-
jest.mock('../../../stock-lookups/stock-lookups.resource');
|
20
|
-
jest.mock('react-i18next', () => ({
|
21
|
-
useTranslation: () => ({ t: (key: string) => key }),
|
22
|
-
}));
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
18
|
+
jest.mock('../../../stock-lookups/stock-lookups.resource', () => ({
|
19
|
+
useConcept: jest.fn(),
|
20
|
+
}));
|
27
21
|
|
28
22
|
describe('StockoperationReasonSelector', () => {
|
29
|
-
const
|
30
|
-
uuid: '3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25',
|
31
|
-
display: 'Stock Adjustment Reason',
|
32
|
-
name: {
|
33
|
-
display: 'Stock Adjustment Reason',
|
34
|
-
uuid: '4eb6556a-a2d4-4e85-9b62-4d076a1063fc',
|
35
|
-
name: 'Stock Adjustment Reason',
|
36
|
-
locale: 'en',
|
37
|
-
localePreferred: true,
|
38
|
-
conceptNameType: 'FULLY_SPECIFIED',
|
39
|
-
links: [
|
40
|
-
{
|
41
|
-
rel: 'self',
|
42
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25/name/4eb6556a-a2d4-4e85-9b62-4d076a1063fc',
|
43
|
-
resourceAlias: 'name',
|
44
|
-
},
|
45
|
-
{
|
46
|
-
rel: 'full',
|
47
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25/name/4eb6556a-a2d4-4e85-9b62-4d076a1063fc?v=full',
|
48
|
-
resourceAlias: 'name',
|
49
|
-
},
|
50
|
-
],
|
51
|
-
resourceVersion: '1.9',
|
52
|
-
},
|
53
|
-
datatype: {
|
54
|
-
uuid: '8d4a48b6-c2cc-11de-8d13-0010c6dffd0f',
|
55
|
-
display: 'Coded',
|
56
|
-
links: [
|
57
|
-
{
|
58
|
-
rel: 'self',
|
59
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/conceptdatatype/8d4a48b6-c2cc-11de-8d13-0010c6dffd0f',
|
60
|
-
resourceAlias: 'conceptdatatype',
|
61
|
-
},
|
62
|
-
],
|
63
|
-
},
|
64
|
-
conceptClass: {
|
65
|
-
uuid: '8d491e50-c2cc-11de-8d13-0010c6dffd0f',
|
66
|
-
display: 'Question',
|
67
|
-
links: [
|
68
|
-
{
|
69
|
-
rel: 'self',
|
70
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/conceptclass/8d491e50-c2cc-11de-8d13-0010c6dffd0f',
|
71
|
-
resourceAlias: 'conceptclass',
|
72
|
-
},
|
73
|
-
],
|
74
|
-
},
|
75
|
-
set: false,
|
76
|
-
version: null,
|
77
|
-
retired: false,
|
78
|
-
names: [
|
79
|
-
{
|
80
|
-
uuid: '4eb6556a-a2d4-4e85-9b62-4d076a1063fc',
|
81
|
-
display: 'Stock Adjustment Reason',
|
82
|
-
links: [
|
83
|
-
{
|
84
|
-
rel: 'self',
|
85
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25/name/4eb6556a-a2d4-4e85-9b62-4d076a1063fc',
|
86
|
-
resourceAlias: 'name',
|
87
|
-
},
|
88
|
-
],
|
89
|
-
},
|
90
|
-
{
|
91
|
-
uuid: '36eb0855-c810-4816-9bed-1de5c615e702',
|
92
|
-
display: 'Stock Adjustment Reason',
|
93
|
-
links: [
|
94
|
-
{
|
95
|
-
rel: 'self',
|
96
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25/name/36eb0855-c810-4816-9bed-1de5c615e702',
|
97
|
-
resourceAlias: 'name',
|
98
|
-
},
|
99
|
-
],
|
100
|
-
},
|
101
|
-
],
|
102
|
-
descriptions: [
|
103
|
-
{
|
104
|
-
uuid: '67311e07-1935-448b-8305-7d11abf0de63',
|
105
|
-
display: 'Stock Adjustment Reason',
|
106
|
-
links: [
|
107
|
-
{
|
108
|
-
rel: 'self',
|
109
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25/description/67311e07-1935-448b-8305-7d11abf0de63',
|
110
|
-
resourceAlias: 'description',
|
111
|
-
},
|
112
|
-
],
|
113
|
-
},
|
114
|
-
],
|
115
|
-
mappings: [],
|
23
|
+
const mockConcept = {
|
116
24
|
answers: [
|
117
25
|
{
|
118
26
|
uuid: '165420AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
119
27
|
display: 'Drug not available due to expired medication',
|
120
|
-
links: [
|
121
|
-
{
|
122
|
-
rel: 'self',
|
123
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/165420AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
124
|
-
resourceAlias: 'concept',
|
125
|
-
},
|
126
|
-
],
|
127
28
|
},
|
128
29
|
{
|
129
30
|
uuid: '160584AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
130
31
|
display: 'Lost or ran out of medication',
|
131
|
-
links: [
|
132
|
-
{
|
133
|
-
rel: 'self',
|
134
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/160584AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
135
|
-
resourceAlias: 'concept',
|
136
|
-
},
|
137
|
-
],
|
138
32
|
},
|
139
33
|
{
|
140
34
|
uuid: '122835AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
141
35
|
display: 'Work Shift Change',
|
142
|
-
links: [
|
143
|
-
{
|
144
|
-
rel: 'self',
|
145
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/122835AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
146
|
-
resourceAlias: 'concept',
|
147
|
-
},
|
148
|
-
],
|
149
36
|
},
|
150
37
|
{
|
151
38
|
uuid: '160561AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
152
39
|
display: 'New drug available',
|
153
|
-
links: [
|
154
|
-
{
|
155
|
-
rel: 'self',
|
156
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/160561AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
157
|
-
resourceAlias: 'concept',
|
158
|
-
},
|
159
|
-
],
|
160
40
|
},
|
161
41
|
],
|
162
|
-
setMembers: [],
|
163
|
-
attributes: [],
|
164
|
-
links: [
|
165
|
-
{
|
166
|
-
rel: 'self',
|
167
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25',
|
168
|
-
resourceAlias: 'concept',
|
169
|
-
},
|
170
|
-
{
|
171
|
-
rel: 'full',
|
172
|
-
uri: 'http://qa.kenyahmis.org/openmrs/ws/rest/v1/concept/3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25?v=full',
|
173
|
-
resourceAlias: 'concept',
|
174
|
-
},
|
175
|
-
],
|
176
|
-
resourceVersion: '2.0',
|
177
42
|
};
|
43
|
+
|
178
44
|
beforeEach(() => {
|
179
|
-
|
180
|
-
|
45
|
+
mockUseConfig.mockReturnValue({
|
46
|
+
stockAdjustmentReasonUUID: '3bbfaa44-d5b8-404d-b4c1-2bf49ad8ce25',
|
47
|
+
});
|
48
|
+
mockUseFormContext.mockReturnValue({
|
49
|
+
control: {},
|
50
|
+
formState: { errors: {} },
|
51
|
+
} as UseFormReturn<FieldValues>);
|
181
52
|
mockUseConcept.mockReturnValue({
|
182
53
|
isLoading: false,
|
183
|
-
items:
|
54
|
+
items: mockConcept as any,
|
55
|
+
error: null,
|
184
56
|
});
|
185
57
|
});
|
186
58
|
|
187
59
|
it('should display loading state while loading reason concepts', () => {
|
188
|
-
mockUseFormContext.mockReturnValue({ control: {} });
|
60
|
+
mockUseFormContext.mockReturnValue({ control: {} } as UseFormReturn<FieldValues>);
|
189
61
|
mockUseConcept.mockReturnValue({
|
190
62
|
isLoading: true,
|
191
|
-
items:
|
63
|
+
items: mockConcept as any,
|
64
|
+
error: null,
|
192
65
|
});
|
66
|
+
|
193
67
|
render(<StockOperationReasonSelector />);
|
68
|
+
|
194
69
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
195
70
|
});
|
71
|
+
|
196
72
|
it('should display error notification when error encountered while fetching concepts', () => {
|
197
73
|
const errorMessahe = 'Error message';
|
198
74
|
mockUseConcept.mockReturnValue({
|
199
75
|
isLoading: false,
|
200
|
-
items:
|
76
|
+
items: mockConcept as any,
|
201
77
|
error: new Error(errorMessahe),
|
202
78
|
});
|
79
|
+
|
203
80
|
render(<StockOperationReasonSelector />);
|
81
|
+
|
204
82
|
expect(screen.getByRole('status')).toBeInTheDocument();
|
205
83
|
expect(screen.getByText(errorMessahe)).toBeInTheDocument();
|
206
84
|
});
|
207
85
|
|
208
86
|
it('renders ComboBox with reasons', async () => {
|
87
|
+
const user = userEvent.setup();
|
88
|
+
|
209
89
|
render(<StockOperationReasonSelector />);
|
90
|
+
|
210
91
|
const combobox = screen.getByRole('combobox');
|
211
|
-
await
|
212
|
-
|
92
|
+
await user.click(combobox);
|
93
|
+
|
94
|
+
mockConcept.answers.forEach((ans) => {
|
213
95
|
expect(screen.getByText(`${ans?.display}`)).toBeInTheDocument();
|
214
96
|
});
|
215
97
|
});
|