@openmrs/esm-stock-management-app 1.0.1-pre.597 → 1.0.1-pre.608

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,9 +85,9 @@
85
85
  "initial": false,
86
86
  "entry": false,
87
87
  "recorded": false,
88
- "size": 1841081,
88
+ "size": 1840985,
89
89
  "sizes": {
90
- "javascript": 1840871,
90
+ "javascript": 1840775,
91
91
  "consume-shared": 210
92
92
  },
93
93
  "names": [],
@@ -101,7 +101,7 @@
101
101
  "auxiliaryFiles": [
102
102
  "173.js.map"
103
103
  ],
104
- "hash": "46a14a22a8277c61",
104
+ "hash": "32293cb595f3bc1a",
105
105
  "childrenByOrder": {}
106
106
  },
107
107
  {
@@ -109,10 +109,10 @@
109
109
  "initial": true,
110
110
  "entry": true,
111
111
  "recorded": false,
112
- "size": 5509508,
112
+ "size": 5509412,
113
113
  "sizes": {
114
114
  "consume-shared": 252,
115
- "javascript": 5487558,
115
+ "javascript": 5487462,
116
116
  "share-init": 252,
117
117
  "runtime": 21446
118
118
  },
@@ -129,7 +129,7 @@
129
129
  "auxiliaryFiles": [
130
130
  "main.js.map"
131
131
  ],
132
- "hash": "940def1cebcc4a09",
132
+ "hash": "eadc2b790e0bb731",
133
133
  "childrenByOrder": {}
134
134
  },
135
135
  {
@@ -251,9 +251,9 @@
251
251
  "initial": false,
252
252
  "entry": false,
253
253
  "recorded": false,
254
- "size": 11502,
254
+ "size": 11501,
255
255
  "sizes": {
256
- "javascript": 11502
256
+ "javascript": 11501
257
257
  },
258
258
  "names": [],
259
259
  "idHints": [],
@@ -265,7 +265,7 @@
265
265
  "574.js"
266
266
  ],
267
267
  "auxiliaryFiles": [],
268
- "hash": "1dabb0391057300e",
268
+ "hash": "b881a6484ecb0d98",
269
269
  "childrenByOrder": {}
270
270
  },
271
271
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.597"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.608"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.597",
3
+ "version": "1.0.1-pre.608",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -30,6 +30,7 @@ import {
30
30
  StockOperationType,
31
31
  StockOperationTypeCanBeRelatedToRequisition,
32
32
  operationFromString,
33
+ StockOperationTypeRequiresDispatchAcknowledgement,
33
34
  } from "../../core/api/types/stockOperation/StockOperationType";
34
35
  import {
35
36
  getStockOperationLinks,
@@ -52,6 +53,9 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
52
53
  props?.isEditing
53
54
  );
54
55
 
56
+ const [requiresDispatchAcknowledgement, setRequiresDispatchAcknowledgement] =
57
+ useState(false);
58
+
55
59
  const currentStockOperationType = types?.results?.find(
56
60
  (p) => p.operationType === props.model?.operationType
57
61
  );
@@ -88,6 +92,18 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
88
92
  const [selectedIndex, setSelectedIndex] = useState(0);
89
93
  const [canDisplayReceivedItems, setCanDisplayReceivedItems] = useState(false);
90
94
 
95
+ useEffect(() => {
96
+ const validOperationType = Object.values(OperationType).includes(
97
+ props.model.operationType as OperationType
98
+ )
99
+ ? (props.model.operationType as OperationType)
100
+ : OperationType.RETURN_OPERATION_TYPE;
101
+
102
+ setRequiresDispatchAcknowledgement(
103
+ StockOperationTypeRequiresDispatchAcknowledgement(validOperationType)
104
+ );
105
+ }, [props.model.operationType]);
106
+
91
107
  useEffect(() => {
92
108
  setCanDisplayReceivedItems(
93
109
  props?.model?.permission?.canDisplayReceivedItems ?? false
@@ -467,24 +483,15 @@ const AddStockOperation: React.FC<AddStockOperationProps> = (props) => {
467
483
  {!props?.model?.permission?.canEdit &&
468
484
  props?.model?.permission?.canApprove && (
469
485
  <>
470
- {(props?.model
471
- ? props?.model?.operationTypeName ===
472
- OperationType.RETURN_OPERATION_TYPE ||
473
- props?.model?.operationTypeName ===
474
- OperationType.STOCK_ISSUE_OPERATION_TYPE
475
- : true) && (
486
+ {!requiresDispatchAcknowledgement && (
476
487
  <div style={{ margin: "2px" }}>
477
488
  <StockOperationApprovalButton
478
489
  operation={props?.model}
479
490
  />
480
491
  </div>
481
492
  )}
482
- {!(props?.model
483
- ? props?.model?.operationTypeName ===
484
- OperationType.RETURN_OPERATION_TYPE ||
485
- props?.model?.operationTypeName ===
486
- OperationType.STOCK_ISSUE_OPERATION_TYPE
487
- : true) && (
493
+
494
+ {requiresDispatchAcknowledgement && (
488
495
  <div style={{ margin: "2px" }}>
489
496
  <StockOperationApproveDispatchButton
490
497
  operation={props?.model}
@@ -165,7 +165,7 @@ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
165
165
  {model?.operationNumber && (
166
166
  <TextInput
167
167
  id="operationNoLbl"
168
- value={model.operationNumber}
168
+ value={model?.operationNumber}
169
169
  readOnly={true}
170
170
  labelText={t("operationNumber", "Operation Number")}
171
171
  />
@@ -36,7 +36,7 @@ const EditStockOperationActionMenu: React.FC<
36
36
  iconDescription={t("editStockOperation", "Edit Stock Operation")}
37
37
  renderIcon={showIcon ? Edit : undefined}
38
38
  >
39
- {showprops && model.operationNumber}
39
+ {showprops && model?.operationNumber}
40
40
  </Button>
41
41
  );
42
42
  };
@@ -28,7 +28,7 @@ const StockOperationApprovalButton: React.FC<
28
28
  onClick={launchApprovalModal}
29
29
  renderIcon={(props) => <CheckmarkOutline size={16} {...props} />}
30
30
  >
31
- {t("approve", "Approve ")}
31
+ {t("approve", "Approve")}
32
32
  </Button>
33
33
  );
34
34
  };
@@ -18,7 +18,7 @@ const StockOperationApproveDispatchButton: React.FC<
18
18
  const dispose = showModal("stock-operation-dialog", {
19
19
  title: "Dispatch",
20
20
  operation: operation,
21
- requireReason: true,
21
+ requireReason: false,
22
22
  closeModal: () => dispose(),
23
23
  });
24
24
  }, [operation]);
@@ -28,7 +28,7 @@ const StockOperationApproveDispatchButton: React.FC<
28
28
  onClick={launchApproveDispatchModal}
29
29
  renderIcon={(props) => <Departure size={16} {...props} />}
30
30
  >
31
- {t("approve", "Dispatch")}
31
+ {t("dispatch", "Dispatch")}
32
32
  </Button>
33
33
  );
34
34
  };
@@ -63,7 +63,7 @@ export const BuildStockOperationData = async (
63
63
  : "";
64
64
  }
65
65
  data.remarks = currentOperation.remarks;
66
- data.operationNumber = currentOperation.operationNumber;
66
+ data.operationNumber = currentOperation?.operationNumber;
67
67
  data.operationDate =
68
68
  parentOperation?.operationDate ?? currentOperation?.operationDate;
69
69
  data.location =
@@ -80,10 +80,10 @@ export const BuildStockOperationData = async (
80
80
  }`;
81
81
  data.organizationName = HEALTH_CENTER_NAME;
82
82
  data.documentTitle = `${currentOperation.operationTypeName} ${
83
- currentOperation.operationNumber
83
+ currentOperation?.operationNumber
84
84
  }${
85
85
  parentOperation
86
- ? ` of ${parentOperation.operationTypeName} ${parentOperation.operationNumber}`
86
+ ? ` of ${parentOperation.operationTypeName} ${parentOperation?.operationNumber}`
87
87
  : ""
88
88
  }`;
89
89
  data.items = stockOperationItems.map((p) => {
@@ -0,0 +1,170 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import '@testing-library/jest-dom/extend-expect';
4
+ import StockSourcesAddOrUpdate from './add-stock-sources.component';
5
+ import { createOrUpdateStockSource } from '../stock-sources.resource';
6
+ import { showSnackbar, useConfig } from '@openmrs/esm-framework';
7
+ import { closeOverlay } from '../../core/components/overlay/hook';
8
+ import { StockSource } from '../../core/api/types/stockOperation/StockSource';
9
+
10
+
11
+ jest.mock('../stock-sources.resource');
12
+ jest.mock('@openmrs/esm-framework', () => ({
13
+ showSnackbar: jest.fn(),
14
+ useConfig: jest.fn(),
15
+ }));
16
+ jest.mock('../../core/components/overlay/hook', () => ({
17
+ closeOverlay: jest.fn(),
18
+ }));
19
+ jest.mock('../../stock-lookups/stock-lookups.resource', () => ({
20
+ useConcept: jest.fn(() => ({
21
+ items: {
22
+ answers: [
23
+ { uuid: 'type1', display: 'Type 1' },
24
+ { uuid: 'type2', display: 'Type 2' },
25
+ ],
26
+ },
27
+ })),
28
+ }));
29
+
30
+ describe('StockSourcesAddOrUpdate', () => {
31
+ beforeEach(() => {
32
+ jest.clearAllMocks();
33
+ (useConfig as jest.Mock).mockReturnValue({ stockSourceTypeUUID: 'mock-uuid' });
34
+ });
35
+
36
+ it('renders correctly without model prop', () => {
37
+ render(<StockSourcesAddOrUpdate />);
38
+ expect(screen.getByLabelText('Full Name')).toBeInTheDocument();
39
+ expect(screen.getByLabelText('Acronym/Code')).toBeInTheDocument();
40
+ expect(screen.getByLabelText('Source Type')).toBeInTheDocument();
41
+ });
42
+
43
+ it('renders correctly with model prop', () => {
44
+ const model: StockSource = {
45
+ uuid: '123', // Add this
46
+ name: 'Test Source',
47
+ acronym: 'TS',
48
+ sourceType: {
49
+ uuid: 'type1', display: 'Type 1',
50
+ conceptId: 0,
51
+ set: false,
52
+ version: '',
53
+ names: [],
54
+ name: undefined,
55
+ numeric: false,
56
+ complex: false,
57
+ shortNames: [],
58
+ indexTerms: [],
59
+ synonyms: [],
60
+ setMembers: [],
61
+ possibleValues: [],
62
+ preferredName: undefined,
63
+ shortName: undefined,
64
+ fullySpecifiedName: undefined,
65
+ answers: [],
66
+ creator: undefined,
67
+ dateCreated: undefined,
68
+ changedBy: undefined,
69
+ dateChanged: undefined,
70
+ retired: false,
71
+ dateRetired: undefined,
72
+ retiredBy: undefined,
73
+ retireReason: ''
74
+ },
75
+ // Add these properties from BaseOpenmrsData
76
+ creator: {
77
+ uuid: 'creator-uuid', display: 'Creator Name',
78
+ givenName: '',
79
+ familyName: '',
80
+ firstName: '',
81
+ lastName: '',
82
+ privileges: []
83
+ },
84
+ dateCreated: new Date(),
85
+ changedBy: null,
86
+ dateChanged: null,
87
+ voided: false,
88
+ voidedBy: null,
89
+ dateVoided: null,
90
+ voidReason: null
91
+ };
92
+ render(<StockSourcesAddOrUpdate model={model} />);
93
+ expect(screen.getByLabelText('Full Name')).toHaveValue('Test Source');
94
+ expect(screen.getByLabelText('Acronym/Code')).toHaveValue('TS');
95
+ expect(screen.getByLabelText('Source Type')).toHaveValue('type1');
96
+ });
97
+
98
+ it('updates form fields correctly on user input', () => {
99
+ render(<StockSourcesAddOrUpdate />);
100
+
101
+ fireEvent.change(screen.getByLabelText('Full Name'), { target: { value: 'New Source' } });
102
+ fireEvent.change(screen.getByLabelText('Acronym/Code'), { target: { value: 'NS' } });
103
+ fireEvent.change(screen.getByLabelText('Source Type'), { target: { value: 'type2' } });
104
+
105
+ expect(screen.getByLabelText('Full Name')).toHaveValue('New Source');
106
+ expect(screen.getByLabelText('Acronym/Code')).toHaveValue('NS');
107
+ expect(screen.getByLabelText('Source Type')).toHaveValue('type2');
108
+ });
109
+
110
+ it('calls createOrUpdateStockSource with correct data on form submission', async () => {
111
+ (createOrUpdateStockSource as jest.Mock).mockResolvedValue({});
112
+
113
+ render(<StockSourcesAddOrUpdate />);
114
+
115
+ fireEvent.change(screen.getByLabelText('Full Name'), { target: { value: 'New Source' } });
116
+ fireEvent.change(screen.getByLabelText('Acronym/Code'), { target: { value: 'NS' } });
117
+ fireEvent.change(screen.getByLabelText('Source Type'), { target: { value: 'type2' } });
118
+
119
+ fireEvent.click(screen.getByText('Save'));
120
+
121
+ await waitFor(() => {
122
+ expect(createOrUpdateStockSource).toHaveBeenCalledWith(
123
+ expect.objectContaining({
124
+ name: 'New Source',
125
+ acronym: 'NS',
126
+ sourceType: { uuid: 'type2', display: 'Type 2' },
127
+ })
128
+ );
129
+ });
130
+ });
131
+
132
+ it('shows success message and closes overlay on successful submission', async () => {
133
+ (createOrUpdateStockSource as jest.Mock).mockResolvedValue({});
134
+
135
+ render(<StockSourcesAddOrUpdate />);
136
+
137
+ fireEvent.click(screen.getByText('Save'));
138
+
139
+ await waitFor(() => {
140
+ expect(showSnackbar).toHaveBeenCalledWith(expect.objectContaining({
141
+ kind: 'success',
142
+ title: 'Add Source',
143
+ }));
144
+ expect(closeOverlay).toHaveBeenCalled();
145
+ });
146
+ });
147
+
148
+ it('shows error message on failed submission', async () => {
149
+ (createOrUpdateStockSource as jest.Mock).mockRejectedValue(new Error('API Error'));
150
+
151
+ render(<StockSourcesAddOrUpdate />);
152
+
153
+ fireEvent.click(screen.getByText('Save'));
154
+
155
+ await waitFor(() => {
156
+ expect(showSnackbar).toHaveBeenCalledWith(expect.objectContaining({
157
+ kind: 'error',
158
+ title: 'Error adding a source',
159
+ }));
160
+ });
161
+ });
162
+
163
+ it('closes overlay when cancel button is clicked', () => {
164
+ render(<StockSourcesAddOrUpdate />);
165
+
166
+ fireEvent.click(screen.getByText('Cancel'));
167
+
168
+ expect(closeOverlay).toHaveBeenCalled();
169
+ });
170
+ });
@@ -45,14 +45,17 @@ describe("StockSourcesDeleteActionMenu", () => {
45
45
  const { getByRole } = render(<StockSourcesDeleteActionMenu uuid={uuid} />);
46
46
  const button = getByRole("button", { name: "deleteSource" });
47
47
  fireEvent.click(button);
48
- expect(showModal).toHaveBeenCalledWith("delete-stock-modal", expect.objectContaining({
49
- close: expect.any(Function),
50
- uuid: uuid,
51
- onConfirmation: expect.any(Function),
52
- }));
48
+ expect(showModal).toHaveBeenCalledWith(
49
+ "delete-stock-modal",
50
+ expect.objectContaining({
51
+ close: expect.any(Function),
52
+ uuid: uuid,
53
+ onConfirmation: expect.any(Function),
54
+ })
55
+ );
53
56
  });
54
57
 
55
- it('calls onConfirmation when delete is clicked', () => {
58
+ it("calls onConfirmation when delete is clicked", () => {
56
59
  const mockOnConfirmation = jest.fn();
57
60
  const mockClose = jest.fn();
58
61
 
@@ -65,7 +68,7 @@ describe("StockSourcesDeleteActionMenu", () => {
65
68
 
66
69
  expect(screen.getByText(/deleteStockUserScope/i)).toBeInTheDocument();
67
70
 
68
- const deleteButton = screen.getByRole('button', { name: /delete/i });
71
+ const deleteButton = screen.getByRole("button", { name: /delete/i });
69
72
  fireEvent.click(deleteButton);
70
73
 
71
74
  expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
@@ -75,7 +78,7 @@ describe("StockSourcesDeleteActionMenu", () => {
75
78
  it("calls deleteStockSource with the correct UUID on confirmation", async () => {
76
79
  const mockOnConfirmation = jest.fn();
77
80
  const mockClose = jest.fn();
78
-
81
+
79
82
  render(
80
83
  <DeleteConfirmation
81
84
  close={mockClose}
@@ -85,10 +88,10 @@ describe("StockSourcesDeleteActionMenu", () => {
85
88
  }}
86
89
  />
87
90
  );
88
-
89
- const deleteButton = screen.getByRole('button', { name: /delete/i });
91
+
92
+ const deleteButton = screen.getByRole("button", { name: /delete/i });
90
93
  fireEvent.click(deleteButton);
91
-
94
+
92
95
  expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
93
96
  expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
94
97
  });
@@ -109,17 +112,21 @@ describe("StockSourcesDeleteActionMenu", () => {
109
112
  />
110
113
  );
111
114
 
112
- const deleteButton = screen.getByRole('button', { name: /delete/i });
115
+ const deleteButton = screen.getByRole("button", { name: /delete/i });
113
116
  fireEvent.click(deleteButton);
114
117
 
115
118
  await waitFor(() => {
116
119
  expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
117
- expect(handleMutate).toHaveBeenCalledWith("/openmrs/ws/rest/v1/stocksource");
120
+ expect(handleMutate).toHaveBeenCalledWith(
121
+ "/openmrs/ws/rest/v1/stocksource"
122
+ );
118
123
  });
119
124
  });
120
125
 
121
126
  it("calls showSnackbar with the correct parameters on deletion error", async () => {
122
- (deleteStockSource as jest.Mock).mockRejectedValueOnce(new Error("Deletion failed"));
127
+ (deleteStockSource as jest.Mock).mockRejectedValueOnce(
128
+ new Error("Deletion failed")
129
+ );
123
130
 
124
131
  const mockOnConfirmation = jest.fn();
125
132
  const mockClose = jest.fn();
@@ -140,7 +147,7 @@ describe("StockSourcesDeleteActionMenu", () => {
140
147
  />
141
148
  );
142
149
 
143
- const deleteButton = screen.getByRole('button', { name: /delete/i });
150
+ const deleteButton = screen.getByRole("button", { name: /delete/i });
144
151
  fireEvent.click(deleteButton);
145
152
 
146
153
  await waitFor(() => {
@@ -153,7 +160,9 @@ describe("StockSourcesDeleteActionMenu", () => {
153
160
  });
154
161
 
155
162
  it("handles the error state correctly when the delete action fails", async () => {
156
- (deleteStockSource as jest.Mock).mockRejectedValueOnce(new Error("Deletion failed"));
163
+ (deleteStockSource as jest.Mock).mockRejectedValueOnce(
164
+ new Error("Deletion failed")
165
+ );
157
166
 
158
167
  const mockOnConfirmation = jest.fn();
159
168
  const mockClose = jest.fn();
@@ -22,7 +22,7 @@
22
22
  "adminSettings": "Admin settings",
23
23
  "alertRole": "Alert Role",
24
24
  "all": "All",
25
- "approve": "Dispatch",
25
+ "approve": "Approve",
26
26
  "batch": "Batch No",
27
27
  "batchInformation": "Batch Information",
28
28
  "batchJob": "Batch Job",