@spokane-folio/security-incident 1.0.28
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/.eslintrc +32 -0
- package/.github/workflows/CODEOWNERS +8 -0
- package/.github/workflows/pr-validation.yml +44 -0
- package/.github/workflows/release.yml +64 -0
- package/.prettierrc +6 -0
- package/.stripesclirc +4 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +4 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/administrator-documentation/roles-and-permissions.md +65 -0
- package/administrator-documentation/track-settings-admin-guide-sketch.md +192 -0
- package/administrator-documentation/using-the-application.md +192 -0
- package/icons/app.png +0 -0
- package/icons/app.svg +1 -0
- package/icons/playButton.png +0 -0
- package/icons/profilePicThumbnail.png +0 -0
- package/jest.config.js +10 -0
- package/module-descriptor.json +75 -0
- package/output/service-worker.js +0 -0
- package/package.json +146 -0
- package/src/components/incidents/ColumnChooser.js +37 -0
- package/src/components/incidents/CreateMedia.js +132 -0
- package/src/components/incidents/CreatePane.js +1215 -0
- package/src/components/incidents/CreatePane.test.js +138 -0
- package/src/components/incidents/CreateReport.js +102 -0
- package/src/components/incidents/DetailsPane.js +1267 -0
- package/src/components/incidents/DetailsPane.test.js +150 -0
- package/src/components/incidents/EditPane.js +2334 -0
- package/src/components/incidents/EditPane.test.js +187 -0
- package/src/components/incidents/GetDetails.js +55 -0
- package/src/components/incidents/GetListDQLinkIncident.js +81 -0
- package/src/components/incidents/GetListDynamicQuery.js +66 -0
- package/src/components/incidents/GetLocations.js +57 -0
- package/src/components/incidents/GetMedia.js +98 -0
- package/src/components/incidents/GetName.js +111 -0
- package/src/components/incidents/GetNameCreatedBy.js +94 -0
- package/src/components/incidents/GetOrgLocaleSettings.js +61 -0
- package/src/components/incidents/GetPatronGroups.js +52 -0
- package/src/components/incidents/GetSelf.js +65 -0
- package/src/components/incidents/GetSummary.js +110 -0
- package/src/components/incidents/IncidentTypeCard.js +53 -0
- package/src/components/incidents/IncidentTypeCard.test.js +133 -0
- package/src/components/incidents/IncidentsPaneset.js +810 -0
- package/src/components/incidents/IncidentsPaneset.test.js +128 -0
- package/src/components/incidents/LinkedIncident.js +86 -0
- package/src/components/incidents/ModalAddMedia.js +262 -0
- package/src/components/incidents/ModalAddMedia.test.js +97 -0
- package/src/components/incidents/ModalAttentionDecOfService.js +111 -0
- package/src/components/incidents/ModalCustomWitness.js +469 -0
- package/src/components/incidents/ModalCustomWitness.test.js +147 -0
- package/src/components/incidents/ModalCustomerDetails.js +480 -0
- package/src/components/incidents/ModalCustomerDetails.test.js +116 -0
- package/src/components/incidents/ModalDescribeCustomer.js +361 -0
- package/src/components/incidents/ModalDescribeCustomer.test.js +156 -0
- package/src/components/incidents/ModalDirtyFormWarn.js +62 -0
- package/src/components/incidents/ModalLinkIncident.js +1213 -0
- package/src/components/incidents/ModalLinkIncidentStyle.css +32 -0
- package/src/components/incidents/ModalSelectIncidentTypes.js +178 -0
- package/src/components/incidents/ModalSelectIncidentTypes.test.js +273 -0
- package/src/components/incidents/ModalSelectKnownCustomer.js +395 -0
- package/src/components/incidents/ModalSelectWitness.js +406 -0
- package/src/components/incidents/ModalSelectWitness.test.js +308 -0
- package/src/components/incidents/ModalStyle.css +44 -0
- package/src/components/incidents/ModalTrespass.js +741 -0
- package/src/components/incidents/ModalViewCustomerDetails.js +241 -0
- package/src/components/incidents/ModalViewMedia.js +86 -0
- package/src/components/incidents/ModalViewTrespass.js +210 -0
- package/src/components/incidents/ResultsPane.js +437 -0
- package/src/components/incidents/ResultsPane.test.js +120 -0
- package/src/components/incidents/SearchCustomerOrWitness.js +108 -0
- package/src/components/incidents/Thumbnail.js +72 -0
- package/src/components/incidents/ThumbnailMarkRemoval.js +38 -0
- package/src/components/incidents/ThumbnailSkeleton.js +30 -0
- package/src/components/incidents/ThumbnailStyles.js +49 -0
- package/src/components/incidents/ThumbnailTempPreSave.js +71 -0
- package/src/components/incidents/UpdateReport.js +84 -0
- package/src/components/incidents/__snapshots__/CreatePane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/DetailsPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/EditPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentTypeCard.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentsPaneset.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalAddMedia.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalCustomerDetails.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalSelectWitness.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ResultsPane.test.js.snap +3 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.css +5 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.js +51 -0
- package/src/components/incidents/helpers/ProfilePicture/isAValidURL.js +3 -0
- package/src/components/incidents/helpers/ProfilePicture/useProfilePicture.js +127 -0
- package/src/components/incidents/helpers/buildQueryString.js +28 -0
- package/src/components/incidents/helpers/cleanFormValues.js +53 -0
- package/src/components/incidents/helpers/computeEditedCustomers.js +124 -0
- package/src/components/incidents/helpers/convertDateIgnoringTZ.js +8 -0
- package/src/components/incidents/helpers/convertUTCISOToLocalePrettyTime.js +15 -0
- package/src/components/incidents/helpers/convertUTCISOToPrettyDate.js +19 -0
- package/src/components/incidents/helpers/decodeParamsToForm.js +20 -0
- package/src/components/incidents/helpers/deepNormalizeForComparison.js +39 -0
- package/src/components/incidents/helpers/extractFilterString.js +12 -0
- package/src/components/incidents/helpers/formatDateAndTimeToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatDateToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatTimeToUTCISO.js +28 -0
- package/src/components/incidents/helpers/getCurrentTime.js +20 -0
- package/src/components/incidents/helpers/getTodayDate.js +12 -0
- package/src/components/incidents/helpers/handlebarsHelpers.js +148 -0
- package/src/components/incidents/helpers/hasFormChangedAtCreate.js +50 -0
- package/src/components/incidents/helpers/hasTopLevelChangeAffectedDeclaration.js +90 -0
- package/src/components/incidents/helpers/hasTopLevelFormChanged.js +111 -0
- package/src/components/incidents/helpers/identifyCurrentTrespassDocs.js +109 -0
- package/src/components/incidents/helpers/isSameHtml.js +13 -0
- package/src/components/incidents/helpers/isValidDateFormat.js +14 -0
- package/src/components/incidents/helpers/isValidTimeInput.js +11 -0
- package/src/components/incidents/helpers/isValidUTCTimeFormat.js +14 -0
- package/src/components/incidents/helpers/parseMMDDYYYY.js +7 -0
- package/src/components/incidents/helpers/parseQueryString.js +16 -0
- package/src/components/incidents/helpers/sortTrespassDocuments.js +44 -0
- package/src/components/incidents/helpers/stripHTML.js +11 -0
- package/src/components/incidents/helpers/trespassDocUtils.js +197 -0
- package/src/components/incidents/helpers/validateTrespassDetails.js +37 -0
- package/src/components/incidents/usePersistedColModalLink.js +70 -0
- package/src/components/incidents/usePersistedColumns.js +70 -0
- package/src/components/incidents/usePersistedSort.js +23 -0
- package/src/components/incidents/usePersistedSortModalLink.js +23 -0
- package/src/contexts/IncidentContext.js +433 -0
- package/src/index.js +61 -0
- package/src/routes/Application.js +13 -0
- package/src/settings/GetIncidentCategories.js +56 -0
- package/src/settings/GetIncidentTypesDetails.js +88 -0
- package/src/settings/GetIncidentTypesIds.js +74 -0
- package/src/settings/GetLocationsInService.js +54 -0
- package/src/settings/GetSingleCustomLocationDetails.js +60 -0
- package/src/settings/GetSingleIncidentTypeDetails.js +60 -0
- package/src/settings/GetTrespassReasons.js +67 -0
- package/src/settings/GetTrespassTemplates.js +51 -0
- package/src/settings/IncidentCategoriesPane.js +285 -0
- package/src/settings/IncidentCategoriesPane.test.js +229 -0
- package/src/settings/IncidentTypeDetailsPane.js +215 -0
- package/src/settings/IncidentTypeDetailsPane.test.js +220 -0
- package/src/settings/IncidentTypeEditPane.js +211 -0
- package/src/settings/IncidentTypeEditPane.test.js +170 -0
- package/src/settings/IncidentTypesPaneset.js +167 -0
- package/src/settings/IncidentTypesPaneset.test.js +124 -0
- package/src/settings/LocationInServiceEditPane.js +320 -0
- package/src/settings/LocationsPaneset.js +415 -0
- package/src/settings/LocationsPaneset.test.js +106 -0
- package/src/settings/ModalDeleteCategory.js +47 -0
- package/src/settings/ModalDeleteIncidentType.js +49 -0
- package/src/settings/ModalDeleteLocationInService.js +49 -0
- package/src/settings/ModalDeleteTrespassReason.js +49 -0
- package/src/settings/ModalPreviewTrespassDoc.js +65 -0
- package/src/settings/ModalTrespassDocTokens.js +83 -0
- package/src/settings/NewIncidentTypePane.js +182 -0
- package/src/settings/PutIncidentType.js +60 -0
- package/src/settings/PutLocationsInService.js +52 -0
- package/src/settings/PutTrespassReasons.js +61 -0
- package/src/settings/PutTrespassTemplate.js +50 -0
- package/src/settings/TrespassDoc.css +17 -0
- package/src/settings/TrespassDocDetailsPane.js +215 -0
- package/src/settings/TrespassDocEditPane.js +538 -0
- package/src/settings/TrespassDocPaneset.js +581 -0
- package/src/settings/TrespassReasonDetailsPane.js +171 -0
- package/src/settings/TrespassReasonEditPane.js +221 -0
- package/src/settings/TrespassReasonsPaneset.js +282 -0
- package/src/settings/__snapshots__/IncidentCategoriesPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeDetailsPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeEditPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypesPaneset.test.js.snap +3 -0
- package/src/settings/__snapshots__/LocationsPaneset.test.js.snap +3 -0
- package/src/settings/data/exampleJSON.json +92 -0
- package/src/settings/data/templateTokens.js +396 -0
- package/src/settings/helpers/alphabetize.js +18 -0
- package/src/settings/helpers/getCategoryTitleById.js +13 -0
- package/src/settings/helpers/makeId.js +15 -0
- package/src/settings/index.js +48 -0
- package/stripes.config.js +10 -0
- package/test/jest/__mock__/index.js +8 -0
- package/test/jest/__mock__/intl.mock.js +27 -0
- package/test/jest/__mock__/stripes.mock.js +26 -0
- package/test/jest/__mock__/stripesComponents.mock.js +151 -0
- package/test/jest/__mock__/stripesConfig.mock.js +1 -0
- package/test/jest/__mock__/stripesCore.mock.js +9 -0
- package/test/jest/__mock__/stripesIcon.mock.js +5 -0
- package/test/jest/__mock__/stripesSmartComponents.mock.js +7 -0
- package/test/jest/__mock__/stripesUtils.mock.js +3 -0
- package/test/jest/eslintrc.js +12 -0
- package/test/jest/setupFiles.js +5 -0
- package/translations/ui-security-incident/en_US.json +542 -0
- package/ui-module-acceptance-criteria.md +34 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DetailsPane.test.js
|
|
3
|
+
* Snapshot + smoke tests for the DetailsPane container.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { act } from 'react-dom/test-utils';
|
|
7
|
+
import { createRoot } from 'react-dom/client';
|
|
8
|
+
import DetailsPane from './DetailsPane';
|
|
9
|
+
|
|
10
|
+
/* ------------------------------------------------------------------ *
|
|
11
|
+
1 external-library mocks
|
|
12
|
+
* ------------------------------------------------------------------ */
|
|
13
|
+
jest.mock('react-intl', () => ({
|
|
14
|
+
useIntl : () => ({ formatMessage: ({ id }) => id }),
|
|
15
|
+
FormattedMessage : (p) => <span>{p.id}</span>,
|
|
16
|
+
}));
|
|
17
|
+
jest.mock('react-router-dom', () => ({
|
|
18
|
+
useParams : () => ({ id: 'test-id' }),
|
|
19
|
+
useHistory : () => ({ push: jest.fn(), replace: jest.fn() }),
|
|
20
|
+
useLocation : () => ({ pathname: '/incidents/123', search: '' }),
|
|
21
|
+
}));
|
|
22
|
+
jest.mock('@folio/stripes/core', () => ({
|
|
23
|
+
useStripes: () => ({ hasPerm: jest.fn(() => true) }),
|
|
24
|
+
}));
|
|
25
|
+
jest.mock('@folio/stripes/components', () => {
|
|
26
|
+
const React = require('react');
|
|
27
|
+
const mk = (tag) => (p) => React.createElement(tag, p, p.children);
|
|
28
|
+
return {
|
|
29
|
+
Button : mk('button'),
|
|
30
|
+
Headline : mk('h2'),
|
|
31
|
+
Icon : (p) => <span {...p}>{p.icon}</span>,
|
|
32
|
+
Pane : mk('div'),
|
|
33
|
+
PaneHeader : mk('div'),
|
|
34
|
+
AccordionSet : mk('div'),
|
|
35
|
+
Accordion : mk('div'),
|
|
36
|
+
ExpandAllButton: mk('button'),
|
|
37
|
+
Label : mk('label'),
|
|
38
|
+
MetaSection : mk('div'),
|
|
39
|
+
MessageBanner : mk('div'),
|
|
40
|
+
Row : mk('div'),
|
|
41
|
+
Col : mk('div'),
|
|
42
|
+
LoadingPane : mk('div'),
|
|
43
|
+
List : (p) => <ul>{(p.items || []).map((it, i) => <li key={i}>{it}</li>)}</ul>,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
jest.mock('../helpers/ProfilePicture/ProfilePicture.js', () => {
|
|
47
|
+
const React = require('react');
|
|
48
|
+
const mk = (tag) => (p) => React.createElement(tag, p, p.children);
|
|
49
|
+
return {
|
|
50
|
+
ProfilePicture : mk('div'),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/* ------------------------------------------------------------------ *
|
|
55
|
+
2 child-component mocks
|
|
56
|
+
* ------------------------------------------------------------------ */
|
|
57
|
+
jest
|
|
58
|
+
.mock('./GetDetails', () => () => <div>Mock GetDetails</div>)
|
|
59
|
+
.mock('./GetName', () => () => <div>Mock GetName</div>)
|
|
60
|
+
.mock('./GetNameCreatedBy', () => () => <div>Mock GetNameCreatedBy</div>)
|
|
61
|
+
.mock('../../settings/GetLocationsInService', () => () => <div>Mock GetLocationsInService</div>)
|
|
62
|
+
.mock('../../settings/GetIncidentTypesDetails',() => () => <div>Mock GetIncidentTypesDetails</div>)
|
|
63
|
+
.mock('../../settings/GetTrespassReasons',() => () => <div>Mock GetTrespassReasons</div>)
|
|
64
|
+
.mock('./ModalViewMedia', () => () => <div>Mock ModalViewMedia</div>)
|
|
65
|
+
.mock('./ModalViewCustomerDetails', () => () => <div>Mock ModalViewCustomerDetails</div>)
|
|
66
|
+
.mock('./ModalViewTrespass', () => () => <div>Mock ModalViewTrespass</div>)
|
|
67
|
+
.mock('./GetMedia', () => () => <div>Mock GetMedia</div>)
|
|
68
|
+
.mock('./Thumbnail', () => () => <div>Mock Thumbnail</div>)
|
|
69
|
+
.mock('./ThumbnailSkeleton', () => () => <div>Mock ThumbnailSkeleton</div>)
|
|
70
|
+
.mock('./ModalCustomWitness', () => () => <div>Mock ModalCustomWitness</div>);
|
|
71
|
+
|
|
72
|
+
/* ------------------------------------------------------------------ *
|
|
73
|
+
3 helper mocks
|
|
74
|
+
* ------------------------------------------------------------------ */
|
|
75
|
+
jest.mock('./helpers/convertDateIgnoringTZ', () => jest.fn((d) => d));
|
|
76
|
+
jest.mock('./helpers/convertUTCISOToPrettyDate', () => jest.fn((d) => d));
|
|
77
|
+
jest.mock('./helpers/convertUTCISOToLocalePrettyTime', () => jest.fn((d) => d));
|
|
78
|
+
|
|
79
|
+
/* ------------------------------------------------------------------ *
|
|
80
|
+
* 4 incidentContext mock
|
|
81
|
+
* ------------------------------------------------------------------ */
|
|
82
|
+
jest.mock('../../contexts/IncidentContext', () => {
|
|
83
|
+
const customers = [];
|
|
84
|
+
const incidentContext = {
|
|
85
|
+
singleIncident : {
|
|
86
|
+
incidentLocation : 'loc-1',
|
|
87
|
+
subLocation : 'sub-1',
|
|
88
|
+
dateTimeOfIncident: '2020-01-01T12:00:00Z',
|
|
89
|
+
customers,
|
|
90
|
+
incidentTypes : [],
|
|
91
|
+
incidentWitnesses: [],
|
|
92
|
+
attachments : [],
|
|
93
|
+
detailedDescriptionOfIncident: 'Test Description',
|
|
94
|
+
createdBy : {},
|
|
95
|
+
metadata : {},
|
|
96
|
+
},
|
|
97
|
+
customers,
|
|
98
|
+
associatedKeyCustArray : [],
|
|
99
|
+
setSingleIncident : jest.fn(),
|
|
100
|
+
closeDetailsPane : jest.fn(),
|
|
101
|
+
openEditPane : jest.fn(),
|
|
102
|
+
openLoadingDetails : jest.fn(),
|
|
103
|
+
isLoadingDetails : false,
|
|
104
|
+
isModalViewImage : false,
|
|
105
|
+
openModalViewImage : jest.fn(),
|
|
106
|
+
mode : 'view',
|
|
107
|
+
incidentTypesList : [],
|
|
108
|
+
locationsInService : [],
|
|
109
|
+
isImageArrayLoading : false,
|
|
110
|
+
openImageSkeleton : jest.fn(),
|
|
111
|
+
closeImageSkeleton : jest.fn(),
|
|
112
|
+
openModalCustomWitness : jest.fn(),
|
|
113
|
+
documentError : false,
|
|
114
|
+
documentErrorMessage : '',
|
|
115
|
+
clearDocumentError : jest.fn(),
|
|
116
|
+
};
|
|
117
|
+
return { useIncidents: () => incidentContext };
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/* ------------------------------------------------------------------ *
|
|
121
|
+
5 DOM setup / teardown
|
|
122
|
+
* ------------------------------------------------------------------ */
|
|
123
|
+
let container, root;
|
|
124
|
+
beforeEach(() => {
|
|
125
|
+
container = document.createElement('div');
|
|
126
|
+
document.body.appendChild(container);
|
|
127
|
+
root = createRoot(container);
|
|
128
|
+
});
|
|
129
|
+
afterEach(() => {
|
|
130
|
+
root.unmount();
|
|
131
|
+
document.body.removeChild(container);
|
|
132
|
+
container = null;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
/* ------------------------------------------------------------------ *
|
|
136
|
+
6 tests
|
|
137
|
+
* ------------------------------------------------------------------ */
|
|
138
|
+
it('renders without crashing (snapshot)', () => {
|
|
139
|
+
act(() => {
|
|
140
|
+
root.render(<DetailsPane />);
|
|
141
|
+
});
|
|
142
|
+
expect(container.innerHTML).toMatchSnapshot();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('mounts key child components', () => {
|
|
146
|
+
act(() => {
|
|
147
|
+
root.render(<DetailsPane />);
|
|
148
|
+
});
|
|
149
|
+
expect(container.textContent).toContain('Mock GetDetails');
|
|
150
|
+
});
|