@openmrs/esm-stock-management-app 3.0.1-pre.855 → 3.0.1-pre.865
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/.husky/pre-push +2 -0
- 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 +18 -17
- 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 +36 -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 +79 -36
- 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 +8 -6
- package/tsconfig.json +4 -0
- package/dist/627.js +0 -1
- package/dist/627.js.map +0 -1
@@ -1,12 +1,6 @@
|
|
1
|
-
import { useConfig } from '@openmrs/esm-framework';
|
2
|
-
import { render, screen } from '@testing-library/react';
|
3
1
|
import React from 'react';
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import { useStockOperations } from '../stock-operations.resource';
|
7
|
-
import useParties from './hooks/useParties';
|
8
|
-
import StockOperationForm from './stock-operation-form.component';
|
9
|
-
import { MAIN_STORE_LOCATION_TAG } from '../../constants';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import { useConfig, useSession } from '@openmrs/esm-framework';
|
10
4
|
import {
|
11
5
|
adjustmentOpeationTypeMock,
|
12
6
|
disposalOperationTypeMock,
|
@@ -17,28 +11,17 @@ import {
|
|
17
11
|
stockIssueOperationtypeMock,
|
18
12
|
stockTakeOperationTypeMock,
|
19
13
|
tranferOutOperationTypeMock,
|
20
|
-
} from '
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
} from '@mocks';
|
15
|
+
import { useStockOperationTypes } from '../../stock-lookups/stock-lookups.resource';
|
16
|
+
import { useStockOperations } from '../stock-operations.resource';
|
17
|
+
import useParties from './hooks/useParties';
|
18
|
+
import StockOperationForm from './stock-operation-form.component';
|
24
19
|
|
25
|
-
jest.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
getState: jest.fn(),
|
31
|
-
subscribe: jest.fn(),
|
32
|
-
setState: jest.fn(),
|
33
|
-
})),
|
34
|
-
parseDate: jest.fn((date) => new Date(date)),
|
35
|
-
showNotification: jest.fn(),
|
36
|
-
usePagination: jest.fn(() => ({ currentPage: 1, setPage: jest.fn() })),
|
37
|
-
useSession: jest.fn(() => ({ user: { display: 'Test User' } })),
|
38
|
-
useConfig: jest.fn(),
|
39
|
-
ErrorState: jest.fn(({ error }: { error: any }) => <div>{error}</div>),
|
40
|
-
launchWorkspace: jest.fn(),
|
41
|
-
}));
|
20
|
+
const mockUseParties = jest.mocked(useParties);
|
21
|
+
const mockUseStockOperationTypes = jest.mocked(useStockOperationTypes);
|
22
|
+
const mockUseStockOperations = jest.mocked(useStockOperations);
|
23
|
+
const mockUseConfig = jest.mocked(useConfig);
|
24
|
+
const mockUseSession = jest.mocked(useSession);
|
42
25
|
|
43
26
|
jest.mock('../../stock-lookups/stock-lookups.resource', () => ({
|
44
27
|
useStockOperationTypes: jest.fn(),
|
@@ -48,10 +31,14 @@ jest.mock('../../stock-lookups/stock-lookups.resource', () => ({
|
|
48
31
|
}));
|
49
32
|
|
50
33
|
jest.mock('../stock-operations.resource', () => ({
|
51
|
-
operationStatusColor: jest.fn(() => 'some-color'),
|
52
34
|
getStockOperationLinks: jest.fn(),
|
35
|
+
operationStatusColor: jest.fn(() => 'some-color'),
|
53
36
|
useStockOperations: jest.fn().mockReturnValue({
|
54
|
-
items: {
|
37
|
+
items: {
|
38
|
+
results: [],
|
39
|
+
links: [],
|
40
|
+
totalCount: 0,
|
41
|
+
},
|
55
42
|
isLoading: false,
|
56
43
|
error: null,
|
57
44
|
}),
|
@@ -67,25 +54,75 @@ jest.mock('../stock-operations.resource', () => ({
|
|
67
54
|
}),
|
68
55
|
}));
|
69
56
|
|
70
|
-
jest.mock('./hooks/useParties', () =>
|
57
|
+
jest.mock('./hooks/useParties', () => ({
|
58
|
+
__esModule: true,
|
59
|
+
default: jest.fn(),
|
60
|
+
useParties: jest.fn(),
|
61
|
+
}));
|
71
62
|
|
72
63
|
describe('Stock Operation step 1 (baseoperation details)', () => {
|
73
64
|
beforeEach(() => {
|
74
|
-
const mockStockOperationTypes = {
|
75
|
-
|
76
|
-
|
77
|
-
|
65
|
+
const mockStockOperationTypes = {
|
66
|
+
results: [],
|
67
|
+
links: [],
|
68
|
+
totalCount: 0,
|
69
|
+
};
|
70
|
+
mockUseStockOperationTypes.mockReturnValue({
|
71
|
+
types: mockStockOperationTypes,
|
72
|
+
isLoading: false,
|
73
|
+
error: null,
|
74
|
+
});
|
75
|
+
mockUseStockOperations.mockReturnValue({
|
76
|
+
items: {
|
77
|
+
results: [],
|
78
|
+
links: [],
|
79
|
+
totalCount: 0,
|
80
|
+
},
|
81
|
+
isLoading: false,
|
82
|
+
error: null,
|
83
|
+
});
|
84
|
+
|
85
|
+
mockUseConfig.mockReturnValue({ autoPopulateResponsiblePerson: true });
|
86
|
+
|
87
|
+
mockUseSession.mockReturnValue({
|
88
|
+
authenticated: true,
|
89
|
+
sessionId: 'test-session-id',
|
90
|
+
user: {
|
91
|
+
uuid: 'test-user-uuid',
|
92
|
+
display: 'Test User',
|
93
|
+
username: 'testuser',
|
94
|
+
systemId: 'test-system-id',
|
95
|
+
userProperties: {},
|
96
|
+
person: { uuid: 'test-person-uuid' },
|
97
|
+
privileges: [],
|
98
|
+
roles: [],
|
99
|
+
retired: false,
|
100
|
+
links: [],
|
101
|
+
locale: 'en',
|
102
|
+
allowedLocales: ['en'],
|
103
|
+
},
|
104
|
+
sessionLocation: {
|
105
|
+
uuid: 'test-location-uuid',
|
106
|
+
display: 'Test Location',
|
107
|
+
links: [],
|
108
|
+
},
|
109
|
+
});
|
78
110
|
});
|
79
111
|
|
80
112
|
it('should render loading state when loading parties info', async () => {
|
81
|
-
|
113
|
+
mockUseParties.mockReturnValue({
|
82
114
|
destinationParties: [],
|
83
|
-
|
84
|
-
|
115
|
+
destinationPartiesFilter: () => true,
|
116
|
+
destinationTags: [],
|
85
117
|
error: null,
|
118
|
+
isLoading: true,
|
119
|
+
mutate: jest.fn(),
|
120
|
+
parties: [],
|
121
|
+
sourceParties: [],
|
122
|
+
sourcePartiesFilter: () => true,
|
86
123
|
sourceTags: [],
|
87
|
-
destinationTags: [],
|
88
124
|
});
|
125
|
+
|
89
126
|
render(
|
90
127
|
<StockOperationForm
|
91
128
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -95,18 +132,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
95
132
|
promptBeforeClosing={jest.fn()}
|
96
133
|
/>,
|
97
134
|
);
|
135
|
+
|
98
136
|
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
99
137
|
});
|
100
138
|
|
101
139
|
it('should render error state when parties loading fails', async () => {
|
102
|
-
|
140
|
+
mockUseParties.mockReturnValue({
|
103
141
|
destinationParties: [],
|
104
|
-
|
105
|
-
|
142
|
+
destinationPartiesFilter: () => true,
|
143
|
+
destinationTags: [],
|
106
144
|
error: 'error',
|
145
|
+
isLoading: false,
|
146
|
+
mutate: jest.fn(),
|
147
|
+
parties: [],
|
148
|
+
sourceParties: [],
|
149
|
+
sourcePartiesFilter: () => true,
|
107
150
|
sourceTags: [],
|
108
|
-
destinationTags: [],
|
109
151
|
});
|
152
|
+
|
110
153
|
render(
|
111
154
|
<StockOperationForm
|
112
155
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -116,18 +159,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
116
159
|
promptBeforeClosing={jest.fn()}
|
117
160
|
/>,
|
118
161
|
);
|
119
|
-
|
162
|
+
|
163
|
+
expect(screen.getByText(/error state/i)).toBeInTheDocument();
|
120
164
|
});
|
121
165
|
|
122
166
|
it('should have only next btn and not previous btn', async () => {
|
123
|
-
|
167
|
+
mockUseParties.mockReturnValue({
|
124
168
|
destinationParties: [],
|
125
|
-
|
126
|
-
|
169
|
+
destinationPartiesFilter: () => true,
|
170
|
+
destinationTags: [],
|
127
171
|
error: undefined,
|
172
|
+
isLoading: false,
|
173
|
+
mutate: jest.fn(),
|
174
|
+
parties: [],
|
175
|
+
sourceParties: [],
|
176
|
+
sourcePartiesFilter: () => true,
|
128
177
|
sourceTags: [],
|
129
|
-
destinationTags: [],
|
130
178
|
});
|
179
|
+
|
131
180
|
render(
|
132
181
|
<StockOperationForm
|
133
182
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -137,17 +186,23 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
137
186
|
promptBeforeClosing={jest.fn()}
|
138
187
|
/>,
|
139
188
|
);
|
189
|
+
|
140
190
|
expect(screen.getByRole('button', { name: /next/i })).toBeInTheDocument();
|
141
191
|
expect(screen.queryByRole('button', { name: /previous/i })).not.toBeInTheDocument();
|
142
192
|
});
|
193
|
+
|
143
194
|
it('should render operation type in title', async () => {
|
144
|
-
|
195
|
+
mockUseParties.mockReturnValue({
|
145
196
|
destinationParties: [],
|
146
197
|
sourceParties: [],
|
147
198
|
isLoading: false,
|
148
199
|
error: undefined,
|
149
200
|
sourceTags: [],
|
150
201
|
destinationTags: [],
|
202
|
+
parties: [],
|
203
|
+
mutate: jest.fn(),
|
204
|
+
sourcePartiesFilter: () => true,
|
205
|
+
destinationPartiesFilter: () => true,
|
151
206
|
});
|
152
207
|
render(
|
153
208
|
<StockOperationForm
|
@@ -158,17 +213,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
158
213
|
promptBeforeClosing={jest.fn()}
|
159
214
|
/>,
|
160
215
|
);
|
161
|
-
expect(screen.
|
216
|
+
expect(screen.getByRole('heading', { name: `${receiptOperationTypeMock.name} Details` })).toBeInTheDocument();
|
162
217
|
});
|
163
218
|
|
164
|
-
it("should render combobox with 'from' name and '
|
165
|
-
|
219
|
+
it("should render combobox with 'from' name and 'choose a source' placeholder for receipt operation", async () => {
|
220
|
+
mockUseParties.mockReturnValue({
|
166
221
|
destinationParties: [],
|
167
222
|
sourceParties: [],
|
168
223
|
isLoading: false,
|
169
224
|
error: undefined,
|
170
225
|
sourceTags: [],
|
171
226
|
destinationTags: [],
|
227
|
+
parties: [],
|
228
|
+
mutate: jest.fn(),
|
229
|
+
sourcePartiesFilter: () => true,
|
230
|
+
destinationPartiesFilter: () => true,
|
172
231
|
});
|
173
232
|
render(
|
174
233
|
<StockOperationForm
|
@@ -181,21 +240,26 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
181
240
|
);
|
182
241
|
const sourceInput = screen.getByRole('combobox', {
|
183
242
|
name: (_, element) =>
|
184
|
-
element.getAttribute('placeholder') === '
|
243
|
+
element.getAttribute('placeholder') === 'Choose a source' && element.getAttribute('name') === 'sourceUuid',
|
185
244
|
});
|
186
245
|
expect(sourceInput).toBeInTheDocument();
|
187
246
|
expect(screen.getByRole('combobox', { name: /from/i })).toBeInTheDocument();
|
188
247
|
});
|
189
248
|
|
190
249
|
it("should render combobox with 'to' name and defaulted to 'main store' location in receipt operation", async () => {
|
191
|
-
|
250
|
+
mockUseParties.mockReturnValue({
|
192
251
|
destinationParties: [],
|
193
252
|
sourceParties: [],
|
194
253
|
isLoading: false,
|
195
254
|
error: undefined,
|
196
255
|
sourceTags: [],
|
197
256
|
destinationTags: [],
|
257
|
+
parties: [],
|
258
|
+
mutate: jest.fn(),
|
259
|
+
sourcePartiesFilter: () => true,
|
260
|
+
destinationPartiesFilter: () => true,
|
198
261
|
});
|
262
|
+
|
199
263
|
render(
|
200
264
|
<StockOperationForm
|
201
265
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -205,18 +269,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
205
269
|
promptBeforeClosing={jest.fn()}
|
206
270
|
/>,
|
207
271
|
);
|
272
|
+
|
208
273
|
expect(screen.getByRole('combobox', { name: /to/i })).toBeInTheDocument();
|
209
274
|
});
|
210
275
|
|
211
276
|
it("should render combobox with 'destinationUuid' name and 'chooseADestination' placeholder", async () => {
|
212
|
-
|
277
|
+
mockUseParties.mockReturnValue({
|
213
278
|
destinationParties: [],
|
214
279
|
sourceParties: [],
|
215
280
|
isLoading: false,
|
216
281
|
error: undefined,
|
217
282
|
sourceTags: [],
|
218
283
|
destinationTags: [],
|
284
|
+
parties: [],
|
285
|
+
mutate: jest.fn(),
|
286
|
+
sourcePartiesFilter: () => true,
|
287
|
+
destinationPartiesFilter: () => true,
|
219
288
|
});
|
289
|
+
|
220
290
|
render(
|
221
291
|
<StockOperationForm
|
222
292
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -226,24 +296,31 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
226
296
|
promptBeforeClosing={jest.fn()}
|
227
297
|
/>,
|
228
298
|
);
|
299
|
+
|
229
300
|
expect(
|
230
301
|
screen.getByRole('combobox', {
|
231
302
|
name: (_, element) =>
|
232
|
-
element.getAttribute('placeholder') === '
|
303
|
+
element.getAttribute('placeholder') === 'Choose a destination' &&
|
233
304
|
element.getAttribute('name') === 'destinationUuid',
|
234
305
|
}),
|
235
306
|
).toBeInTheDocument();
|
236
307
|
expect(screen.getByRole('combobox', { name: /to/i })).toBeInTheDocument();
|
237
308
|
});
|
238
|
-
|
239
|
-
|
309
|
+
|
310
|
+
it("should render combobox with 'sourceUuid' name and 'chooseALocation' placeholder for disposal operation", async () => {
|
311
|
+
mockUseParties.mockReturnValue({
|
240
312
|
destinationParties: [],
|
241
313
|
sourceParties: [],
|
242
314
|
isLoading: false,
|
243
315
|
error: undefined,
|
244
316
|
sourceTags: [],
|
245
317
|
destinationTags: [],
|
318
|
+
parties: [],
|
319
|
+
mutate: jest.fn(),
|
320
|
+
sourcePartiesFilter: () => true,
|
321
|
+
destinationPartiesFilter: () => true,
|
246
322
|
});
|
323
|
+
|
247
324
|
render(
|
248
325
|
<StockOperationForm
|
249
326
|
stockOperationType={disposalOperationTypeMock as any}
|
@@ -253,24 +330,30 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
253
330
|
promptBeforeClosing={jest.fn()}
|
254
331
|
/>,
|
255
332
|
);
|
333
|
+
|
256
334
|
expect(
|
257
335
|
screen.getByRole('combobox', {
|
258
336
|
name: (_, element) =>
|
259
|
-
element.getAttribute('placeholder') === '
|
337
|
+
element.getAttribute('placeholder') === 'Choose a location' && element.getAttribute('name') === 'sourceUuid',
|
260
338
|
}),
|
261
339
|
).toBeInTheDocument();
|
262
340
|
expect(screen.getByRole('combobox', { name: /location/i })).toBeInTheDocument();
|
263
341
|
});
|
264
342
|
|
265
343
|
it('should not render reason input field for receipt operation', async () => {
|
266
|
-
|
344
|
+
mockUseParties.mockReturnValue({
|
267
345
|
destinationParties: [],
|
268
346
|
sourceParties: [],
|
269
347
|
isLoading: false,
|
270
348
|
error: undefined,
|
271
349
|
sourceTags: [],
|
272
350
|
destinationTags: [],
|
351
|
+
parties: [],
|
352
|
+
mutate: jest.fn(),
|
353
|
+
sourcePartiesFilter: () => true,
|
354
|
+
destinationPartiesFilter: () => true,
|
273
355
|
});
|
356
|
+
|
274
357
|
render(
|
275
358
|
<StockOperationForm
|
276
359
|
stockOperationType={receiptOperationTypeMock as any}
|
@@ -282,15 +365,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
282
365
|
);
|
283
366
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
284
367
|
});
|
368
|
+
|
285
369
|
it('should render reason input field for adjustment operation', async () => {
|
286
|
-
|
370
|
+
mockUseParties.mockReturnValue({
|
287
371
|
destinationParties: [],
|
288
372
|
sourceParties: [],
|
289
373
|
isLoading: false,
|
290
374
|
error: undefined,
|
291
375
|
sourceTags: [],
|
292
376
|
destinationTags: [],
|
377
|
+
parties: [],
|
378
|
+
mutate: jest.fn(),
|
379
|
+
sourcePartiesFilter: () => true,
|
380
|
+
destinationPartiesFilter: () => true,
|
293
381
|
});
|
382
|
+
|
294
383
|
render(
|
295
384
|
<StockOperationForm
|
296
385
|
stockOperationType={adjustmentOpeationTypeMock as any}
|
@@ -302,15 +391,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
302
391
|
);
|
303
392
|
expect(screen.getByRole('combobox', { name: /reason/i })).toBeInTheDocument();
|
304
393
|
});
|
394
|
+
|
305
395
|
it('should not render reason input field for opening stock operation', async () => {
|
306
|
-
|
396
|
+
mockUseParties.mockReturnValue({
|
307
397
|
destinationParties: [],
|
308
398
|
sourceParties: [],
|
309
399
|
isLoading: false,
|
310
400
|
error: undefined,
|
311
401
|
sourceTags: [],
|
312
402
|
destinationTags: [],
|
403
|
+
parties: [],
|
404
|
+
mutate: jest.fn(),
|
405
|
+
sourcePartiesFilter: () => true,
|
406
|
+
destinationPartiesFilter: () => true,
|
313
407
|
});
|
408
|
+
|
314
409
|
render(
|
315
410
|
<StockOperationForm
|
316
411
|
stockOperationType={openingStockOperationTypeMock as any}
|
@@ -322,15 +417,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
322
417
|
);
|
323
418
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
324
419
|
});
|
420
|
+
|
325
421
|
it('should not render reason input field for requisition operation', async () => {
|
326
|
-
|
422
|
+
mockUseParties.mockReturnValue({
|
327
423
|
destinationParties: [],
|
328
424
|
sourceParties: [],
|
329
425
|
isLoading: false,
|
330
426
|
error: undefined,
|
331
427
|
sourceTags: [],
|
332
428
|
destinationTags: [],
|
429
|
+
parties: [],
|
430
|
+
mutate: jest.fn(),
|
431
|
+
sourcePartiesFilter: () => true,
|
432
|
+
destinationPartiesFilter: () => true,
|
333
433
|
});
|
434
|
+
|
334
435
|
render(
|
335
436
|
<StockOperationForm
|
336
437
|
stockOperationType={requisitionOperationTypeMock as any}
|
@@ -342,15 +443,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
342
443
|
);
|
343
444
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
344
445
|
});
|
446
|
+
|
345
447
|
it('should not render reason input field for return operation', async () => {
|
346
|
-
|
448
|
+
mockUseParties.mockReturnValue({
|
347
449
|
destinationParties: [],
|
348
450
|
sourceParties: [],
|
349
451
|
isLoading: false,
|
350
452
|
error: undefined,
|
351
453
|
sourceTags: [],
|
352
454
|
destinationTags: [],
|
455
|
+
parties: [],
|
456
|
+
mutate: jest.fn(),
|
457
|
+
sourcePartiesFilter: () => true,
|
458
|
+
destinationPartiesFilter: () => true,
|
353
459
|
});
|
460
|
+
|
354
461
|
render(
|
355
462
|
<StockOperationForm
|
356
463
|
stockOperationType={returnOperationTypeMock as any}
|
@@ -360,17 +467,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
360
467
|
promptBeforeClosing={jest.fn()}
|
361
468
|
/>,
|
362
469
|
);
|
470
|
+
|
363
471
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
364
472
|
});
|
473
|
+
|
365
474
|
it('should not render reason input field for issue operation', async () => {
|
366
|
-
|
475
|
+
mockUseParties.mockReturnValue({
|
367
476
|
destinationParties: [],
|
368
477
|
sourceParties: [],
|
369
478
|
isLoading: false,
|
370
479
|
error: undefined,
|
371
480
|
sourceTags: [],
|
372
481
|
destinationTags: [],
|
482
|
+
parties: [],
|
483
|
+
mutate: jest.fn(),
|
484
|
+
sourcePartiesFilter: () => true,
|
485
|
+
destinationPartiesFilter: () => true,
|
373
486
|
});
|
487
|
+
|
374
488
|
render(
|
375
489
|
<StockOperationForm
|
376
490
|
stockOperationType={stockIssueOperationtypeMock as any}
|
@@ -380,17 +494,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
380
494
|
promptBeforeClosing={jest.fn()}
|
381
495
|
/>,
|
382
496
|
);
|
497
|
+
|
383
498
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
384
499
|
});
|
500
|
+
|
385
501
|
it('should not render reason input field for tranfer out operation', async () => {
|
386
|
-
|
502
|
+
mockUseParties.mockReturnValue({
|
387
503
|
destinationParties: [],
|
388
504
|
sourceParties: [],
|
389
505
|
isLoading: false,
|
390
506
|
error: undefined,
|
391
507
|
sourceTags: [],
|
392
508
|
destinationTags: [],
|
509
|
+
parties: [],
|
510
|
+
mutate: jest.fn(),
|
511
|
+
sourcePartiesFilter: () => true,
|
512
|
+
destinationPartiesFilter: () => true,
|
393
513
|
});
|
514
|
+
|
394
515
|
render(
|
395
516
|
<StockOperationForm
|
396
517
|
stockOperationType={tranferOutOperationTypeMock as any}
|
@@ -400,17 +521,24 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
400
521
|
promptBeforeClosing={jest.fn()}
|
401
522
|
/>,
|
402
523
|
);
|
524
|
+
|
403
525
|
expect(screen.queryByRole('combobox', { name: /reason/i })).not.toBeInTheDocument();
|
404
526
|
});
|
527
|
+
|
405
528
|
it('should render reason input field for disposal operation', async () => {
|
406
|
-
|
529
|
+
mockUseParties.mockReturnValue({
|
407
530
|
destinationParties: [],
|
408
531
|
sourceParties: [],
|
409
532
|
isLoading: false,
|
410
533
|
error: undefined,
|
411
534
|
sourceTags: [],
|
412
535
|
destinationTags: [],
|
536
|
+
parties: [],
|
537
|
+
mutate: jest.fn(),
|
538
|
+
sourcePartiesFilter: () => true,
|
539
|
+
destinationPartiesFilter: () => true,
|
413
540
|
});
|
541
|
+
|
414
542
|
render(
|
415
543
|
<StockOperationForm
|
416
544
|
stockOperationType={disposalOperationTypeMock as any}
|
@@ -422,15 +550,21 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
422
550
|
);
|
423
551
|
expect(screen.getByRole('combobox', { name: /reason/i })).toBeInTheDocument();
|
424
552
|
});
|
553
|
+
|
425
554
|
it('should render reason input field for stock take operation', async () => {
|
426
|
-
|
555
|
+
mockUseParties.mockReturnValue({
|
427
556
|
destinationParties: [],
|
428
557
|
sourceParties: [],
|
429
558
|
isLoading: false,
|
430
559
|
error: undefined,
|
431
560
|
sourceTags: [],
|
432
561
|
destinationTags: [],
|
562
|
+
parties: [],
|
563
|
+
mutate: jest.fn(),
|
564
|
+
sourcePartiesFilter: () => true,
|
565
|
+
destinationPartiesFilter: () => true,
|
433
566
|
});
|
567
|
+
|
434
568
|
render(
|
435
569
|
<StockOperationForm
|
436
570
|
stockOperationType={stockTakeOperationTypeMock as any}
|
@@ -440,6 +574,7 @@ describe('Stock Operation step 1 (baseoperation details)', () => {
|
|
440
574
|
promptBeforeClosing={jest.fn()}
|
441
575
|
/>,
|
442
576
|
);
|
577
|
+
|
443
578
|
expect(screen.getByRole('combobox', { name: /reason/i })).toBeInTheDocument();
|
444
579
|
});
|
445
580
|
});
|