@ohif/extension-default 3.14.0-beta.10 → 3.14.0-beta.101
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/dist/ohif-extension-default.css +1 -1
- package/dist/ohif-extension-default.umd.js +1 -1
- package/package.json +14 -10
- package/src/Actions/createReportAsync.tsx +45 -0
- package/src/Components/DataSourceConfigurationComponent.tsx +142 -0
- package/src/Components/DataSourceConfigurationModalComponent.tsx +200 -0
- package/src/Components/ItemListComponent.tsx +95 -0
- package/src/Components/LineChartViewport/LineChartViewport.tsx +31 -0
- package/src/Components/LineChartViewport/index.ts +1 -0
- package/src/Components/MoreDropdownMenu.tsx +112 -0
- package/src/Components/ProgressDropdownWithService.tsx +101 -0
- package/src/Components/SidePanelWithServices.tsx +122 -0
- package/src/CustomizableContextMenu/ContextMenuController.tsx +216 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.test.js +29 -0
- package/src/CustomizableContextMenu/ContextMenuItemsBuilder.ts +176 -0
- package/src/CustomizableContextMenu/index.ts +5 -0
- package/src/CustomizableContextMenu/types.ts +126 -0
- package/src/DataSourceConfigurationAPI/GoogleCloudDataSourceConfigurationAPI.ts +236 -0
- package/src/DicomJSONDataSource/index.js +326 -0
- package/src/DicomLocalDataSource/index.js +273 -0
- package/src/DicomTagBrowser/DicomTagBrowser.css +49 -0
- package/src/DicomTagBrowser/DicomTagBrowser.tsx +454 -0
- package/src/DicomTagBrowser/DicomTagTable.tsx +311 -0
- package/src/DicomWebDataSource/dcm4cheeReject.js +45 -0
- package/src/DicomWebDataSource/exampleInstances.js +280 -0
- package/src/DicomWebDataSource/index.ts +808 -0
- package/src/DicomWebDataSource/qido.js +215 -0
- package/src/DicomWebDataSource/retrieveBulkData.test.ts +35 -0
- package/src/DicomWebDataSource/retrieveBulkData.ts +31 -0
- package/src/DicomWebDataSource/retrieveRendered.test.ts +147 -0
- package/src/DicomWebDataSource/retrieveRendered.ts +141 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.js +108 -0
- package/src/DicomWebDataSource/retrieveStudyMetadata.test.js +75 -0
- package/src/DicomWebDataSource/retrieveThumbnail.ts +346 -0
- package/src/DicomWebDataSource/serviceUrls.test.ts +143 -0
- package/src/DicomWebDataSource/utils/StaticWadoClient.ts +272 -0
- package/src/DicomWebDataSource/utils/cleanDenaturalizedDataset.ts +78 -0
- package/src/DicomWebDataSource/utils/findIndexOfString.ts +47 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.test.ts +68 -0
- package/src/DicomWebDataSource/utils/fixBulkDataURI.ts +78 -0
- package/src/DicomWebDataSource/utils/fixMultiValueKeys.ts +12 -0
- package/src/DicomWebDataSource/utils/fixMultipart.ts +70 -0
- package/src/DicomWebDataSource/utils/getImageId.js +54 -0
- package/src/DicomWebDataSource/utils/getWADORSImageId.js +51 -0
- package/src/DicomWebDataSource/utils/index.ts +9 -0
- package/src/DicomWebDataSource/utils/retrieveMetadataFiltered.js +61 -0
- package/src/DicomWebDataSource/wado/retrieveMetadata.js +41 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoader.js +64 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderAsync.js +159 -0
- package/src/DicomWebDataSource/wado/retrieveMetadataLoaderSync.js +58 -0
- package/src/DicomWebProxyDataSource/index.ts +90 -0
- package/src/MergeDataSource/index.test.ts +212 -0
- package/src/MergeDataSource/index.ts +319 -0
- package/src/MergeDataSource/types.ts +46 -0
- package/src/Panels/DataSourceSelector.tsx +55 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +612 -0
- package/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +88 -0
- package/src/Panels/StudyBrowser/constants/actionIcons.ts +12 -0
- package/src/Panels/StudyBrowser/constants/index.ts +4 -0
- package/src/Panels/StudyBrowser/constants/viewPresets.ts +16 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.test.ts +197 -0
- package/src/Panels/StudyBrowser/resolveThumbnailDetails.ts +132 -0
- package/src/Panels/StudyBrowser/types/actionIcon.ts +9 -0
- package/src/Panels/StudyBrowser/types/index.ts +4 -0
- package/src/Panels/StudyBrowser/types/viewPreset.ts +7 -0
- package/src/Panels/WrappedPanelStudyBrowser.tsx +61 -0
- package/src/Panels/createReportDialogPrompt.tsx +128 -0
- package/src/Panels/debounce.js +25 -0
- package/src/Panels/getImageSrcFromImageId.js +16 -0
- package/src/Panels/getStudiesForPatientByMRN.js +19 -0
- package/src/Panels/index.js +5 -0
- package/src/Panels/requestDisplaySetCreationForStudy.js +19 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.test.ts +81 -0
- package/src/SOPClassHandlers/chartSOPClassHandler.ts +127 -0
- package/src/Toolbar/ToolBoxWrapper.tsx +64 -0
- package/src/Toolbar/ToolButtonListWrapper.tsx +77 -0
- package/src/Toolbar/ToolButtonWrapper.tsx +32 -0
- package/src/Toolbar/ToolRowWrapper.tsx +41 -0
- package/src/Toolbar/Toolbar.tsx +98 -0
- package/src/Toolbar/ToolbarDivider.tsx +5 -0
- package/src/Toolbar/ToolbarLayoutSelector.tsx +195 -0
- package/src/Toolbar/index.ts +7 -0
- package/src/ViewerLayout/HeaderPatientInfo/HeaderPatientInfo.tsx +96 -0
- package/src/ViewerLayout/HeaderPatientInfo/index.js +3 -0
- package/src/ViewerLayout/HeaderUndoRedo.tsx +47 -0
- package/src/ViewerLayout/ResizablePanelsHook.tsx +334 -0
- package/src/ViewerLayout/ViewerHeader.tsx +124 -0
- package/src/ViewerLayout/constants/panels.ts +42 -0
- package/src/ViewerLayout/index.tsx +227 -0
- package/src/ViewerLayout/useUndoRedoState.ts +75 -0
- package/src/__tests__/commandsModuleToggleOneUp.test.ts +147 -0
- package/src/commandsModule.ts +970 -0
- package/src/customizations/aboutModalCustomization.tsx +42 -0
- package/src/customizations/appearanceModalCustomization.tsx +143 -0
- package/src/customizations/contextMenuCustomization.ts +25 -0
- package/src/customizations/contextMenuUICustomization.ts +5 -0
- package/src/customizations/customRoutesCustomization.ts +6 -0
- package/src/customizations/dataSourceConfigurationCustomization.ts +19 -0
- package/src/customizations/datasourcesCustomization.tsx +14 -0
- package/src/customizations/defaultContextMenuCustomization.ts +22 -0
- package/src/customizations/hangingProtocolsCustomization.ts +15 -0
- package/src/customizations/headerRightSideCustomization.ts +19 -0
- package/src/customizations/helloPageCustomization.tsx +14 -0
- package/src/customizations/hideHeaderUndoRedoCustomization.ts +22 -0
- package/src/customizations/hotkeyBindingsCustomization.ts +5 -0
- package/src/customizations/instanceSortingCriteriaCustomization.ts +6 -0
- package/src/customizations/labellingFlowCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorProgressCustomization.tsx +5 -0
- package/src/customizations/loadingIndicatorTotalPercentCustomization.tsx +5 -0
- package/src/customizations/menuContentCustomization.tsx +67 -0
- package/src/customizations/metadataContextCustomization.test.ts +22 -0
- package/src/customizations/metadataContextCustomization.ts +28 -0
- package/src/customizations/metadataDisplaySetCustomization.ts +55 -0
- package/src/customizations/missingReferenceDisplaySetHandler.ts +5 -0
- package/src/customizations/multimonitorCustomization.ts +63 -0
- package/src/customizations/notificationCustomization.ts +29 -0
- package/src/customizations/onDropHandlerCustomization.ts +5 -0
- package/src/customizations/onboardingCustomization.ts +200 -0
- package/src/customizations/overlayItemCustomization.tsx +33 -0
- package/src/customizations/progressDropdownCustomization.ts +5 -0
- package/src/customizations/progressLoadingBarCustomization.tsx +5 -0
- package/src/customizations/reportDialogCustomization.test.ts +701 -0
- package/src/customizations/reportDialogCustomization.tsx +661 -0
- package/src/customizations/sortingCriteriaCustomization.ts +14 -0
- package/src/customizations/studyBrowserCustomization.test.ts +69 -0
- package/src/customizations/studyBrowserCustomization.ts +95 -0
- package/src/customizations/thumbnailDetailsCustomization.ts +91 -0
- package/src/customizations/userPreferencesCustomization.tsx +342 -0
- package/src/customizations/workListCustomization.ts +107 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.test.ts +181 -0
- package/src/displaySetSplitting/makeDisplaySetFromInstanceGroup.ts +240 -0
- package/src/displaySetSplitting/makeImageSetDisplaySet.ts +276 -0
- package/src/displaySetSplitting/stackSopClassUids.ts +60 -0
- package/src/displaySetSplitting/urlSplitModules.test.ts +333 -0
- package/src/findViewportsByPosition.ts +102 -0
- package/src/getCustomizationModule.tsx +109 -0
- package/src/getDataSourcesModule.js +44 -0
- package/src/getDisplaySetMessages.ts +54 -0
- package/src/getDisplaySetsFromUnsupportedSeries.js +63 -0
- package/src/getDisplaySetsFromUnsupportedSeries.test.js +14 -0
- package/src/getHangingProtocolModule.js +155 -0
- package/src/getLayoutTemplateModule.js +28 -0
- package/src/getPTImageIdInstanceMetadata.test.ts +102 -0
- package/src/getPTImageIdInstanceMetadata.ts +124 -0
- package/src/getPanelModule.tsx +29 -0
- package/src/getSopClassHandlerModule.js +152 -0
- package/src/getSopClassHandlerModule.test.js +78 -0
- package/src/getToolbarModule.tsx +63 -0
- package/src/getViewportModule.tsx +12 -0
- package/src/hangingprotocols/hpCompare.ts +189 -0
- package/src/hangingprotocols/hpEcgCustomization.test.ts +104 -0
- package/src/hangingprotocols/hpMNGrid.test.ts +120 -0
- package/src/hangingprotocols/hpMNGrid.ts +419 -0
- package/src/hangingprotocols/hpMammo.ts +202 -0
- package/src/hangingprotocols/hpScale.ts +132 -0
- package/src/hangingprotocols/index.ts +16 -0
- package/src/hangingprotocols/protocolMatchChanges.test.ts +73 -0
- package/src/hangingprotocols/utils/isNewestOfModality.ts +19 -0
- package/src/hangingprotocols/utils/laterality.ts +9 -0
- package/src/hangingprotocols/utils/mammoDisplaySetSelector.ts +214 -0
- package/src/hangingprotocols/utils/registerHangingProtocolAttributes.ts +14 -0
- package/src/hangingprotocols/utils/seriesSelectors.ts +62 -0
- package/src/hangingprotocols/utils/studySelectors.ts +14 -0
- package/src/hangingprotocols/utils/viewCode.test.js +25 -0
- package/src/hangingprotocols/utils/viewCode.ts +17 -0
- package/src/hangingprotocols/utils/viewportOptions.ts +18 -0
- package/src/hooks/usePatientInfo.tsx +63 -0
- package/src/id.js +5 -0
- package/src/index.ts +113 -0
- package/src/init.ts +169 -0
- package/src/stores/index.ts +7 -0
- package/src/stores/useDisplaySetSelectorStore.ts +83 -0
- package/src/stores/useHangingProtocolStageIndexStore.ts +76 -0
- package/src/stores/useToggleHangingProtocolStore.ts +76 -0
- package/src/stores/useToggleOneUpViewportGridStore.ts +19 -0
- package/src/stores/useUIStateStore.ts +87 -0
- package/src/stores/useViewportGridStore.ts +89 -0
- package/src/stores/useViewportsByPositionStore.ts +100 -0
- package/src/types/AppTypes.ts +20 -0
- package/src/types/commandModuleTypes.tsx +6 -0
- package/src/utils/Toolbox.tsx +123 -0
- package/src/utils/_shared/PROMPT_RESPONSES.ts +10 -0
- package/src/utils/addIcon.ts +6 -0
- package/src/utils/appendFrameQueryToImageId.js +9 -0
- package/src/utils/callInputDialog.tsx +126 -0
- package/src/utils/colorPickerDialog.css +4 -0
- package/src/utils/colorPickerDialog.tsx +45 -0
- package/src/utils/createRenderedRetrieve.js +32 -0
- package/src/utils/createRenderedRetrieve.test.js +46 -0
- package/src/utils/dicomWriter.test.ts +228 -0
- package/src/utils/dicomWriter.ts +110 -0
- package/src/utils/getBulkdataValue.js +45 -0
- package/src/utils/getBulkdataValue.test.js +105 -0
- package/src/utils/getDirectURL.test.ts +207 -0
- package/src/utils/getDirectURL.ts +65 -0
- package/src/utils/getSRSeriesAndInstanceNumber.js +48 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/layerConfigurationUtils.ts +202 -0
- package/src/utils/promptLabelAnnotation.js +47 -0
- package/src/utils/promptSaveReport.test.ts +106 -0
- package/src/utils/promptSaveReport.tsx +117 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.js +146 -0
- package/src/utils/registerNaturalizedDatasetForLocalWadouri.test.js +177 -0
- package/src/utils/registerStoredInstanceImageId.test.ts +73 -0
- package/src/utils/registerStoredInstanceImageId.ts +66 -0
- package/src/utils/reuseCachedLayouts.ts +92 -0
- package/src/utils/secureConfigFetch.js +115 -0
- package/src/utils/secureConfigFetch.test.js +163 -0
- package/src/utils/seriesDescriptionHistory.ts +83 -0
- package/src/utils/validations/areAllImageComponentsEqual.ts +24 -0
- package/src/utils/validations/areAllImageDimensionsEqual.test.ts +41 -0
- package/src/utils/validations/areAllImageDimensionsEqual.ts +27 -0
- package/src/utils/validations/areAllImagePositionsEqual.ts +75 -0
- package/src/utils/validations/areAllImageSpacingEqual.ts +66 -0
- package/src/utils/validations/checkMultiframe.ts +25 -0
- package/src/utils/validations/checkSingleFrames.ts +36 -0
|
@@ -0,0 +1,701 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { configure, fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
const mockDisplaySetCache = new Map();
|
|
5
|
+
|
|
6
|
+
jest.mock('react-i18next', () => ({
|
|
7
|
+
useTranslation: () => ({ t: key => key }),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
jest.mock('@ohif/core', () => ({
|
|
11
|
+
useSystem: () => ({
|
|
12
|
+
servicesManager: {
|
|
13
|
+
services: {
|
|
14
|
+
displaySetService: {
|
|
15
|
+
getDisplaySetCache: () => mockDisplaySetCache,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
// Lightweight stand ins for the design system components - the dialog is being
|
|
23
|
+
// tested for what it says about the destination series, not for how ui-next
|
|
24
|
+
// renders tabs, a select or an input.
|
|
25
|
+
jest.mock('@ohif/ui-next', () => {
|
|
26
|
+
const ReactMock = require('react');
|
|
27
|
+
const TabsContext = ReactMock.createContext(null);
|
|
28
|
+
const SelectContext = ReactMock.createContext(null);
|
|
29
|
+
|
|
30
|
+
const FooterAction = ({ children }) => ReactMock.createElement('div', null, children);
|
|
31
|
+
FooterAction.Left = ({ children }) => ReactMock.createElement('div', null, children);
|
|
32
|
+
FooterAction.Right = ({ children }) => ReactMock.createElement('div', null, children);
|
|
33
|
+
const footerButton = ({ dataCY, onClick, disabled, children }) =>
|
|
34
|
+
ReactMock.createElement('button', { 'data-cy': dataCY, onClick, disabled }, children);
|
|
35
|
+
FooterAction.Primary = footerButton;
|
|
36
|
+
FooterAction.Secondary = footerButton;
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
cn: (...classes) => classes.filter(Boolean).join(' '),
|
|
40
|
+
Icons: { ChevronOpen: () => null },
|
|
41
|
+
Label: ({ children, htmlFor }) => ReactMock.createElement('label', { htmlFor }, children),
|
|
42
|
+
Input: ({ className, ...props }) => ReactMock.createElement('input', props),
|
|
43
|
+
FooterAction,
|
|
44
|
+
Tabs: ({ value, onValueChange, children }) =>
|
|
45
|
+
ReactMock.createElement(TabsContext.Provider, { value: { value, onValueChange } }, children),
|
|
46
|
+
TabsList: ({ children }) => ReactMock.createElement('div', null, children),
|
|
47
|
+
TabsTrigger: ({ value, children, ...props }) => {
|
|
48
|
+
const context = ReactMock.useContext(TabsContext);
|
|
49
|
+
return ReactMock.createElement(
|
|
50
|
+
'button',
|
|
51
|
+
{
|
|
52
|
+
...props,
|
|
53
|
+
'aria-selected': context.value === value,
|
|
54
|
+
onClick: () => context.onValueChange(value),
|
|
55
|
+
},
|
|
56
|
+
children
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
Select: ({ value, onValueChange, children }) =>
|
|
60
|
+
ReactMock.createElement(
|
|
61
|
+
SelectContext.Provider,
|
|
62
|
+
{ value: { value, onValueChange } },
|
|
63
|
+
children
|
|
64
|
+
),
|
|
65
|
+
SelectTrigger: ({ children, ...props }) => ReactMock.createElement('div', props, children),
|
|
66
|
+
SelectContent: ({ children }) => ReactMock.createElement('div', null, children),
|
|
67
|
+
// Radix shows the placeholder until an item is chosen, then the item's text.
|
|
68
|
+
SelectValue: ({ placeholder }) => {
|
|
69
|
+
const context = ReactMock.useContext(SelectContext);
|
|
70
|
+
return context?.value ? null : placeholder;
|
|
71
|
+
},
|
|
72
|
+
SelectItem: ({ value, children }) => {
|
|
73
|
+
const context = ReactMock.useContext(SelectContext);
|
|
74
|
+
return ReactMock.createElement(
|
|
75
|
+
'button',
|
|
76
|
+
{ onClick: () => context.onValueChange(value) },
|
|
77
|
+
children
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
import { ReportDialog } from './reportDialogCustomization';
|
|
84
|
+
|
|
85
|
+
configure({ testIdAttribute: 'data-cy' });
|
|
86
|
+
|
|
87
|
+
const CURRENT_SERIES_IMAGE_ID = 'wadors:/seg-instance-1';
|
|
88
|
+
const OTHER_SERIES_IMAGE_ID = 'wadors:/seg-instance-2';
|
|
89
|
+
|
|
90
|
+
const CURRENT_SERIES = {
|
|
91
|
+
displaySetInstanceUID: 'ds-current',
|
|
92
|
+
Modality: 'SEG',
|
|
93
|
+
SeriesInstanceUID: '1.2.3',
|
|
94
|
+
SeriesNumber: 3105,
|
|
95
|
+
SeriesDescription: 'Liver',
|
|
96
|
+
predecessorImageId: CURRENT_SERIES_IMAGE_ID,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const OTHER_SERIES = {
|
|
100
|
+
displaySetInstanceUID: 'ds-other',
|
|
101
|
+
Modality: 'SEG',
|
|
102
|
+
SeriesInstanceUID: '1.2.5',
|
|
103
|
+
SeriesNumber: 3103,
|
|
104
|
+
SeriesDescription: 'Spleen',
|
|
105
|
+
predecessorImageId: OTHER_SERIES_IMAGE_ID,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Another modality, so it is never a destination for a SEG.
|
|
109
|
+
const UNRELATED_SERIES = {
|
|
110
|
+
displaySetInstanceUID: 'ds-ct',
|
|
111
|
+
Modality: 'CT',
|
|
112
|
+
SeriesInstanceUID: '1.2.4',
|
|
113
|
+
SeriesNumber: 1,
|
|
114
|
+
SeriesDescription: 'Axial',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// An uploaded instance carries a local id, which the provider resolves.
|
|
118
|
+
const LOCAL_SERIES = {
|
|
119
|
+
displaySetInstanceUID: 'ds-local',
|
|
120
|
+
Modality: 'SEG',
|
|
121
|
+
SeriesInstanceUID: '1.2.6',
|
|
122
|
+
SeriesNumber: 3107,
|
|
123
|
+
SeriesDescription: 'Kidney',
|
|
124
|
+
predecessorImageId: 'dicomfile:3',
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// The viewer never stored this series, so the series has no predecessor image id.
|
|
128
|
+
const DOWNLOADED_SERIES = {
|
|
129
|
+
displaySetInstanceUID: 'ds-downloaded',
|
|
130
|
+
Modality: 'SEG',
|
|
131
|
+
SeriesInstanceUID: '1.2.7',
|
|
132
|
+
SeriesNumber: 3108,
|
|
133
|
+
SeriesDescription: 'Pancreas',
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const HISTORY_STORAGE_KEY = 'ohif.seriesDescriptionHistory';
|
|
137
|
+
|
|
138
|
+
function setDisplaySets(displaySets) {
|
|
139
|
+
mockDisplaySetCache.clear();
|
|
140
|
+
displaySets.forEach(ds => mockDisplaySetCache.set(ds.displaySetInstanceUID, ds));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function renderDialog(props = {}) {
|
|
144
|
+
const onSave = jest.fn();
|
|
145
|
+
const onCancel = jest.fn();
|
|
146
|
+
render(
|
|
147
|
+
React.createElement(ReportDialog as any, {
|
|
148
|
+
dataSources: [],
|
|
149
|
+
modality: 'SEG',
|
|
150
|
+
minSeriesNumber: 3100,
|
|
151
|
+
defaultSeriesDescription: 'Segmentation 1',
|
|
152
|
+
enableDownload: true,
|
|
153
|
+
hide: jest.fn(),
|
|
154
|
+
onSave,
|
|
155
|
+
onCancel,
|
|
156
|
+
...props,
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
return { onSave, onCancel };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const tab = (destination: string) => screen.getByTestId(`report-destination-${destination}`);
|
|
163
|
+
const selectedTab = () =>
|
|
164
|
+
['current', 'new', 'replace'].find(
|
|
165
|
+
destination => tab(destination).getAttribute('aria-selected') === 'true'
|
|
166
|
+
);
|
|
167
|
+
const helpText = () => screen.getByTestId('report-destination-help').textContent;
|
|
168
|
+
const seriesNumberField = () => screen.getByTestId('report-series-number') as HTMLInputElement;
|
|
169
|
+
const descriptionField = () => screen.getByTestId('dialog-input') as HTMLInputElement;
|
|
170
|
+
const saveButton = () => screen.getByTestId('input-dialog-save-button') as HTMLButtonElement;
|
|
171
|
+
const isDisabled = (element: HTMLElement) => (element as HTMLButtonElement).disabled;
|
|
172
|
+
const shownDescriptions = () =>
|
|
173
|
+
Array.from(screen.getByTestId('report-series-description-list').querySelectorAll('button')).map(
|
|
174
|
+
option => option.textContent
|
|
175
|
+
);
|
|
176
|
+
const storedHistory = () => JSON.parse(window.localStorage.getItem(HISTORY_STORAGE_KEY) || '{}');
|
|
177
|
+
const setStoredHistory = (history: Record<string, string[]>) =>
|
|
178
|
+
window.localStorage.setItem(HISTORY_STORAGE_KEY, JSON.stringify(history));
|
|
179
|
+
|
|
180
|
+
describe('ReportDialog', () => {
|
|
181
|
+
beforeEach(() => {
|
|
182
|
+
window.localStorage.clear();
|
|
183
|
+
setDisplaySets([CURRENT_SERIES, OTHER_SERIES, UNRELATED_SERIES]);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe('destinations', () => {
|
|
187
|
+
it('saves to the series the data was loaded from by default', () => {
|
|
188
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
189
|
+
|
|
190
|
+
expect(selectedTab()).toBe('current');
|
|
191
|
+
expect(helpText()).toContain('Adds a new version to this series');
|
|
192
|
+
expect(saveButton().textContent).toBe('Save to current');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('creates a series by default when the data has never been saved', () => {
|
|
196
|
+
renderDialog();
|
|
197
|
+
|
|
198
|
+
expect(selectedTab()).toBe('new');
|
|
199
|
+
expect(helpText()).toBe('Creates a separate series.');
|
|
200
|
+
expect(saveButton().textContent).toBe('Save as new');
|
|
201
|
+
// There is no series it was loaded from to save to.
|
|
202
|
+
expect(isDisabled(tab('current'))).toBe(true);
|
|
203
|
+
expect(tab('current').getAttribute('title')).toBe(
|
|
204
|
+
'This data has not been saved to a series yet'
|
|
205
|
+
);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('cannot replace a series when no other series of the type is loaded', () => {
|
|
209
|
+
setDisplaySets([CURRENT_SERIES, UNRELATED_SERIES]);
|
|
210
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
211
|
+
|
|
212
|
+
expect(isDisabled(tab('replace'))).toBe(true);
|
|
213
|
+
expect(tab('replace').getAttribute('title')).toBe('No other series of this type is loaded');
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe('save to current', () => {
|
|
218
|
+
it('shows the series number and description, uneditable, and stores into it', () => {
|
|
219
|
+
const { onSave } = renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
220
|
+
|
|
221
|
+
expect(screen.getByTestId('report-series-description').textContent).toBe('Liver');
|
|
222
|
+
expect(seriesNumberField().textContent).toBe('3105');
|
|
223
|
+
expect(screen.queryByTestId('dialog-input')).toBeNull();
|
|
224
|
+
|
|
225
|
+
fireEvent.click(saveButton());
|
|
226
|
+
|
|
227
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
228
|
+
expect.objectContaining({
|
|
229
|
+
reportName: 'Liver',
|
|
230
|
+
series: CURRENT_SERIES_IMAGE_ID,
|
|
231
|
+
seriesNumber: 3105,
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe('save as new', () => {
|
|
238
|
+
it('offers the next series number and the default description', () => {
|
|
239
|
+
const { onSave } = renderDialog();
|
|
240
|
+
|
|
241
|
+
// One past the highest existing series number of this modality.
|
|
242
|
+
expect(seriesNumberField().value).toBe('3106');
|
|
243
|
+
expect(descriptionField().value).toBe('Segmentation 1');
|
|
244
|
+
|
|
245
|
+
fireEvent.click(saveButton());
|
|
246
|
+
|
|
247
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
248
|
+
expect.objectContaining({
|
|
249
|
+
reportName: 'Segmentation 1',
|
|
250
|
+
series: null,
|
|
251
|
+
seriesNumber: 3106,
|
|
252
|
+
priorSeriesNumber: 3105,
|
|
253
|
+
})
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('uses the minimum series number when no series of the modality exists', () => {
|
|
258
|
+
setDisplaySets([UNRELATED_SERIES]);
|
|
259
|
+
renderDialog();
|
|
260
|
+
|
|
261
|
+
expect(seriesNumberField().value).toBe('3101');
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('counts a series that it does not offer as a destination', () => {
|
|
265
|
+
// The lists do not offer series 3108, because that series has no
|
|
266
|
+
// predecessor image id. A new series must still take a number past 3108.
|
|
267
|
+
setDisplaySets([CURRENT_SERIES, DOWNLOADED_SERIES]);
|
|
268
|
+
renderDialog();
|
|
269
|
+
|
|
270
|
+
expect(seriesNumberField().value).toBe('3109');
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('saves an edited series number and description', () => {
|
|
274
|
+
const { onSave } = renderDialog();
|
|
275
|
+
|
|
276
|
+
fireEvent.change(seriesNumberField(), { target: { value: '4321' } });
|
|
277
|
+
fireEvent.change(descriptionField(), { target: { value: 'Left kidney' } });
|
|
278
|
+
fireEvent.click(saveButton());
|
|
279
|
+
|
|
280
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
281
|
+
expect.objectContaining({
|
|
282
|
+
reportName: 'Left kidney',
|
|
283
|
+
series: null,
|
|
284
|
+
seriesNumber: 4321,
|
|
285
|
+
priorSeriesNumber: 4320,
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('falls back to the offered values when the fields are emptied', () => {
|
|
291
|
+
const { onSave } = renderDialog();
|
|
292
|
+
|
|
293
|
+
fireEvent.change(seriesNumberField(), { target: { value: '' } });
|
|
294
|
+
fireEvent.change(descriptionField(), { target: { value: ' ' } });
|
|
295
|
+
fireEvent.click(saveButton());
|
|
296
|
+
|
|
297
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
298
|
+
expect.objectContaining({ reportName: 'Segmentation 1', seriesNumber: 3106 })
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
describe('replace existing', () => {
|
|
304
|
+
it('waits for a series to be chosen, then stores into it', () => {
|
|
305
|
+
const { onSave } = renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
306
|
+
|
|
307
|
+
fireEvent.click(tab('replace'));
|
|
308
|
+
|
|
309
|
+
expect(helpText()).toContain('Choose a series to replace');
|
|
310
|
+
expect(isDisabled(saveButton())).toBe(true);
|
|
311
|
+
expect(isDisabled(screen.getByTestId('report-download-button'))).toBe(true);
|
|
312
|
+
expect(seriesNumberField().textContent).toBe('');
|
|
313
|
+
// The row is labelled `Series Description`, so the control asks for the
|
|
314
|
+
// choice it needs rather than repeating the label.
|
|
315
|
+
expect(screen.getByTestId('report-replaced-series-select').textContent).toBe(
|
|
316
|
+
'Select a series'
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
// The series the data was loaded from is not offered again here.
|
|
320
|
+
fireEvent.click(screen.getByText('Spleen'));
|
|
321
|
+
|
|
322
|
+
expect(screen.queryByText('Liver')).toBeNull();
|
|
323
|
+
expect(seriesNumberField().textContent).toBe('3103');
|
|
324
|
+
expect(isDisabled(saveButton())).toBe(false);
|
|
325
|
+
|
|
326
|
+
fireEvent.click(saveButton());
|
|
327
|
+
|
|
328
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
329
|
+
expect.objectContaining({
|
|
330
|
+
reportName: 'Spleen',
|
|
331
|
+
series: OTHER_SERIES_IMAGE_ID,
|
|
332
|
+
seriesNumber: 3103,
|
|
333
|
+
})
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('names a series without a description by its number', () => {
|
|
338
|
+
setDisplaySets([{ ...OTHER_SERIES, SeriesDescription: undefined }]);
|
|
339
|
+
renderDialog();
|
|
340
|
+
|
|
341
|
+
fireEvent.click(tab('replace'));
|
|
342
|
+
|
|
343
|
+
expect(screen.getByText('Series 3103')).toBeTruthy();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('does not offer a series that no predecessor image id names', () => {
|
|
347
|
+
setDisplaySets([CURRENT_SERIES, OTHER_SERIES, LOCAL_SERIES, DOWNLOADED_SERIES]);
|
|
348
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
349
|
+
|
|
350
|
+
fireEvent.click(tab('replace'));
|
|
351
|
+
|
|
352
|
+
expect(screen.getByText('Spleen')).toBeTruthy();
|
|
353
|
+
// An uploaded instance carries a local id, which the provider resolves.
|
|
354
|
+
expect(screen.getByText('Kidney')).toBeTruthy();
|
|
355
|
+
// The list gave the `SeriesInstanceUID` of this display set before, which
|
|
356
|
+
// is not an image id, and the provider then threw a `TypeError`.
|
|
357
|
+
expect(screen.queryByText('Pancreas')).toBeNull();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('cannot replace when the only other series has no predecessor image id', () => {
|
|
361
|
+
setDisplaySets([CURRENT_SERIES, DOWNLOADED_SERIES]);
|
|
362
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
363
|
+
|
|
364
|
+
expect(isDisabled(tab('replace'))).toBe(true);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('stores into an uploaded series through its local image id', () => {
|
|
368
|
+
// A user must be able to save against an uploaded instance more than once.
|
|
369
|
+
setDisplaySets([LOCAL_SERIES]);
|
|
370
|
+
const { onSave } = renderDialog();
|
|
371
|
+
|
|
372
|
+
fireEvent.click(tab('replace'));
|
|
373
|
+
fireEvent.click(screen.getByText('Kidney'));
|
|
374
|
+
fireEvent.click(saveButton());
|
|
375
|
+
|
|
376
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
377
|
+
expect.objectContaining({
|
|
378
|
+
reportName: 'Kidney',
|
|
379
|
+
series: 'dicomfile:3',
|
|
380
|
+
seriesNumber: 3107,
|
|
381
|
+
})
|
|
382
|
+
);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
describe('remembered series descriptions', () => {
|
|
387
|
+
it('remembers the description that was used, per type of item', () => {
|
|
388
|
+
renderDialog();
|
|
389
|
+
|
|
390
|
+
fireEvent.change(descriptionField(), { target: { value: 'Right kidney' } });
|
|
391
|
+
fireEvent.click(saveButton());
|
|
392
|
+
|
|
393
|
+
expect(storedHistory()).toEqual({ SEG: ['Right kidney'] });
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
it('remembers nothing for the name that the caller provides', () => {
|
|
397
|
+
// `Segmentation 1` is the generated name of this segmentation. A later
|
|
398
|
+
// segmentation carries `Segmentation 2`, and the history would otherwise
|
|
399
|
+
// offer `Segmentation 1` as the name of that unrelated segmentation.
|
|
400
|
+
const { onSave } = renderDialog();
|
|
401
|
+
|
|
402
|
+
fireEvent.click(saveButton());
|
|
403
|
+
|
|
404
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
405
|
+
expect.objectContaining({ reportName: 'Segmentation 1' })
|
|
406
|
+
);
|
|
407
|
+
expect(storedHistory()).toEqual({});
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('remembers nothing when the typed name is the provided one', () => {
|
|
411
|
+
renderDialog({ defaultSeriesDescription: 'Contours' });
|
|
412
|
+
|
|
413
|
+
fireEvent.change(descriptionField(), { target: { value: ' contours ' } });
|
|
414
|
+
fireEvent.click(saveButton());
|
|
415
|
+
|
|
416
|
+
expect(storedHistory()).toEqual({});
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it('remembers nothing when an existing series is stored into', () => {
|
|
420
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
421
|
+
|
|
422
|
+
fireEvent.click(saveButton());
|
|
423
|
+
|
|
424
|
+
expect(storedHistory()).toEqual({});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('offers the last used description, and keeps the older ones behind it', () => {
|
|
428
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
429
|
+
renderDialog();
|
|
430
|
+
|
|
431
|
+
// The last used one is the most likely to be wanted again.
|
|
432
|
+
expect(descriptionField().value).toBe('Right kidney');
|
|
433
|
+
|
|
434
|
+
fireEvent.click(screen.getByTestId('report-series-description-options'));
|
|
435
|
+
// The ones used before, most recent first, then the generic name.
|
|
436
|
+
expect(shownDescriptions()).toEqual(['Right kidney', 'Left kidney', 'Segmentation 1']);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('offers the item name before every other description', () => {
|
|
440
|
+
// The user renamed `Liver` to `Liver + tumor` before the save.
|
|
441
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
442
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID, itemName: 'Liver + tumor' });
|
|
443
|
+
|
|
444
|
+
fireEvent.click(tab('new'));
|
|
445
|
+
|
|
446
|
+
expect(descriptionField().value).toBe('Liver + tumor');
|
|
447
|
+
|
|
448
|
+
fireEvent.click(screen.getByTestId('report-series-description-options'));
|
|
449
|
+
expect(shownDescriptions()).toEqual([
|
|
450
|
+
'Liver + tumor',
|
|
451
|
+
'Liver',
|
|
452
|
+
'Right kidney',
|
|
453
|
+
'Left kidney',
|
|
454
|
+
'Segmentation 1',
|
|
455
|
+
]);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it('ignores an item name of spaces', () => {
|
|
459
|
+
// A blank name must not hide the description of the loaded series.
|
|
460
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
461
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID, itemName: ' ' });
|
|
462
|
+
|
|
463
|
+
fireEvent.click(tab('new'));
|
|
464
|
+
|
|
465
|
+
expect(descriptionField().value).toBe('Liver');
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('offers the description of the loaded series when there is no item name', () => {
|
|
469
|
+
// The name of the last save comes before the remembered names.
|
|
470
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
471
|
+
renderDialog({ predecessorImageId: CURRENT_SERIES_IMAGE_ID });
|
|
472
|
+
|
|
473
|
+
fireEvent.click(tab('new'));
|
|
474
|
+
|
|
475
|
+
expect(descriptionField().value).toBe('Liver');
|
|
476
|
+
|
|
477
|
+
fireEvent.click(screen.getByTestId('report-series-description-options'));
|
|
478
|
+
expect(shownDescriptions()).toEqual([
|
|
479
|
+
'Liver',
|
|
480
|
+
'Right kidney',
|
|
481
|
+
'Left kidney',
|
|
482
|
+
'Segmentation 1',
|
|
483
|
+
]);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('offers the last used description when the caller provides none', () => {
|
|
487
|
+
// A caller such as the findings flow of a fork provides no description.
|
|
488
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
489
|
+
renderDialog({ defaultSeriesDescription: '' });
|
|
490
|
+
|
|
491
|
+
expect(descriptionField().value).toBe('Right kidney');
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
it('saves when the caller provides a null description', () => {
|
|
495
|
+
// A mode context, or a customization, can give an explicit null, and the
|
|
496
|
+
// default of the prop replaces `undefined` alone. A save read `.trim()`
|
|
497
|
+
// off that null and threw, and the save then stored nothing.
|
|
498
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
499
|
+
const { onSave } = renderDialog({ defaultSeriesDescription: null });
|
|
500
|
+
|
|
501
|
+
fireEvent.click(saveButton());
|
|
502
|
+
|
|
503
|
+
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reportName: 'Right kidney' }));
|
|
504
|
+
expect(storedHistory()).toEqual({ SEG: ['Right kidney'] });
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('drops the outer spaces of an offered name', () => {
|
|
508
|
+
// The dialog shows the trimmed name, so the save stores the trimmed name
|
|
509
|
+
// as well, and the history holds the same name as the series.
|
|
510
|
+
const { onSave } = renderDialog({ itemName: ' Right kidney ' });
|
|
511
|
+
|
|
512
|
+
expect(descriptionField().value).toBe('Right kidney');
|
|
513
|
+
|
|
514
|
+
fireEvent.click(saveButton());
|
|
515
|
+
|
|
516
|
+
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reportName: 'Right kidney' }));
|
|
517
|
+
expect(storedHistory()).toEqual({ SEG: ['Right kidney'] });
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('drops the outer spaces of the name an emptied field falls back to', () => {
|
|
521
|
+
const { onSave } = renderDialog({ itemName: ' Right kidney ' });
|
|
522
|
+
|
|
523
|
+
fireEvent.change(descriptionField(), { target: { value: ' ' } });
|
|
524
|
+
fireEvent.click(saveButton());
|
|
525
|
+
|
|
526
|
+
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reportName: 'Right kidney' }));
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it('drops the second copy of a description that two sources hold', () => {
|
|
530
|
+
// The history holds the generic name, so the list holds that name once.
|
|
531
|
+
setStoredHistory({ SEG: ['Segmentation 1', 'Left kidney'] });
|
|
532
|
+
renderDialog();
|
|
533
|
+
|
|
534
|
+
expect(descriptionField().value).toBe('Segmentation 1');
|
|
535
|
+
|
|
536
|
+
fireEvent.click(screen.getByTestId('report-series-description-options'));
|
|
537
|
+
expect(shownDescriptions()).toEqual(['Segmentation 1', 'Left kidney']);
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
it('falls back to the offered description when the field is emptied', () => {
|
|
541
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
542
|
+
const { onSave } = renderDialog();
|
|
543
|
+
|
|
544
|
+
fireEvent.change(descriptionField(), { target: { value: ' ' } });
|
|
545
|
+
fireEvent.click(saveButton());
|
|
546
|
+
|
|
547
|
+
// The name the field offered, and not the generic name behind it.
|
|
548
|
+
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reportName: 'Right kidney' }));
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
it('moves a reused description back to the front, without duplicating it', () => {
|
|
552
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
553
|
+
renderDialog();
|
|
554
|
+
|
|
555
|
+
fireEvent.change(descriptionField(), { target: { value: 'left kidney' } });
|
|
556
|
+
fireEvent.click(saveButton());
|
|
557
|
+
|
|
558
|
+
expect(storedHistory()).toEqual({ SEG: ['left kidney', 'Right kidney'] });
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
it('remembers no more than the requested number of them', () => {
|
|
562
|
+
setStoredHistory({ SEG: ['4', '3', '2', '1'] });
|
|
563
|
+
renderDialog({ rememberedDescriptionCount: 3 });
|
|
564
|
+
|
|
565
|
+
fireEvent.change(descriptionField(), { target: { value: '5' } });
|
|
566
|
+
fireEvent.click(saveButton());
|
|
567
|
+
|
|
568
|
+
expect(storedHistory()).toEqual({ SEG: ['5', '4', '3'] });
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
it('remembers nothing, and offers nothing, for a count of 0', () => {
|
|
572
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
573
|
+
renderDialog({ rememberedDescriptionCount: 0 });
|
|
574
|
+
|
|
575
|
+
expect(descriptionField().value).toBe('Segmentation 1');
|
|
576
|
+
expect(screen.queryByTestId('report-series-description-options')).toBeNull();
|
|
577
|
+
|
|
578
|
+
fireEvent.click(saveButton());
|
|
579
|
+
expect(storedHistory()).toEqual({ SEG: ['Right kidney'] });
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('still starts from the item name for a count of 0', () => {
|
|
583
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
584
|
+
renderDialog({ rememberedDescriptionCount: 0, itemName: 'Liver + tumor' });
|
|
585
|
+
|
|
586
|
+
expect(descriptionField().value).toBe('Liver + tumor');
|
|
587
|
+
expect(screen.queryByTestId('report-series-description-options')).toBeNull();
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it('ignores an item name of spaces for a count of 0', () => {
|
|
591
|
+
// A blank name must not empty the field, and must not hide `Liver`.
|
|
592
|
+
renderDialog({
|
|
593
|
+
rememberedDescriptionCount: 0,
|
|
594
|
+
itemName: ' ',
|
|
595
|
+
predecessorImageId: CURRENT_SERIES_IMAGE_ID,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
fireEvent.click(tab('new'));
|
|
599
|
+
|
|
600
|
+
expect(descriptionField().value).toBe('Liver');
|
|
601
|
+
expect(screen.queryByTestId('report-series-description-options')).toBeNull();
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
it('offers the default when the current description is blank, for a count of 0', () => {
|
|
605
|
+
// A blank loaded description must fall through to the generic name.
|
|
606
|
+
setDisplaySets([{ ...CURRENT_SERIES, SeriesDescription: ' ' }]);
|
|
607
|
+
const { onSave } = renderDialog({
|
|
608
|
+
rememberedDescriptionCount: 0,
|
|
609
|
+
predecessorImageId: CURRENT_SERIES_IMAGE_ID,
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
fireEvent.click(tab('new'));
|
|
613
|
+
expect(descriptionField().value).toBe('Segmentation 1');
|
|
614
|
+
|
|
615
|
+
fireEvent.change(descriptionField(), { target: { value: ' ' } });
|
|
616
|
+
fireEvent.click(saveButton());
|
|
617
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
618
|
+
expect.objectContaining({ reportName: 'Segmentation 1' })
|
|
619
|
+
);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('keeps each type of item separate', () => {
|
|
623
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
624
|
+
renderDialog({ modality: 'RTSTRUCT', defaultSeriesDescription: 'Contours' });
|
|
625
|
+
|
|
626
|
+
expect(descriptionField().value).toBe('Contours');
|
|
627
|
+
|
|
628
|
+
fireEvent.change(descriptionField(), { target: { value: 'Left lung' } });
|
|
629
|
+
fireEvent.click(saveButton());
|
|
630
|
+
expect(storedHistory()).toEqual({ SEG: ['Right kidney'], RTSTRUCT: ['Left lung'] });
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
it('narrows the offered descriptions to what is being typed', () => {
|
|
634
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney', 'Liver'] });
|
|
635
|
+
renderDialog();
|
|
636
|
+
|
|
637
|
+
fireEvent.change(descriptionField(), { target: { value: 'Li' } });
|
|
638
|
+
|
|
639
|
+
expect(shownDescriptions()).toEqual(['Liver']);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
it('completes the typed prefix on tab', () => {
|
|
643
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
644
|
+
renderDialog();
|
|
645
|
+
|
|
646
|
+
fireEvent.change(descriptionField(), { target: { value: 'le' } });
|
|
647
|
+
fireEvent.keyDown(descriptionField(), { key: 'Tab' });
|
|
648
|
+
|
|
649
|
+
expect(descriptionField().value).toBe('Left kidney');
|
|
650
|
+
expect(screen.queryByTestId('report-series-description-list')).toBeNull();
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
it('leaves the typed description alone when nothing completes it', () => {
|
|
654
|
+
setStoredHistory({ SEG: ['Right kidney'] });
|
|
655
|
+
renderDialog();
|
|
656
|
+
|
|
657
|
+
fireEvent.change(descriptionField(), { target: { value: 'Spleen' } });
|
|
658
|
+
fireEvent.keyDown(descriptionField(), { key: 'Tab' });
|
|
659
|
+
|
|
660
|
+
expect(descriptionField().value).toBe('Spleen');
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
it('accepts a highlighted description with enter, and saves with the next one', () => {
|
|
664
|
+
setStoredHistory({ SEG: ['Right kidney', 'Left kidney'] });
|
|
665
|
+
const { onSave } = renderDialog();
|
|
666
|
+
|
|
667
|
+
fireEvent.click(screen.getByTestId('report-series-description-options'));
|
|
668
|
+
fireEvent.keyDown(descriptionField(), { key: 'ArrowDown' });
|
|
669
|
+
fireEvent.keyDown(descriptionField(), { key: 'ArrowDown' });
|
|
670
|
+
fireEvent.keyDown(descriptionField(), { key: 'Enter' });
|
|
671
|
+
|
|
672
|
+
// The field starts from the first entry, so the arrow key picks the second.
|
|
673
|
+
expect(descriptionField().value).toBe('Left kidney');
|
|
674
|
+
expect(onSave).not.toHaveBeenCalled();
|
|
675
|
+
|
|
676
|
+
fireEvent.keyDown(descriptionField(), { key: 'Enter' });
|
|
677
|
+
expect(onSave).toHaveBeenCalledWith(expect.objectContaining({ reportName: 'Left kidney' }));
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
describe('actions', () => {
|
|
682
|
+
it('downloads through the same destination', () => {
|
|
683
|
+
const { onSave } = renderDialog();
|
|
684
|
+
|
|
685
|
+
fireEvent.click(screen.getByTestId('report-download-button'));
|
|
686
|
+
|
|
687
|
+
expect(onSave).toHaveBeenCalledWith(
|
|
688
|
+
expect.objectContaining({ dataSource: 'download', series: null })
|
|
689
|
+
);
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
it('cancels without saving', () => {
|
|
693
|
+
const { onSave, onCancel } = renderDialog();
|
|
694
|
+
|
|
695
|
+
fireEvent.click(screen.getByTestId('input-dialog-cancel-button'));
|
|
696
|
+
|
|
697
|
+
expect(onCancel).toHaveBeenCalled();
|
|
698
|
+
expect(onSave).not.toHaveBeenCalled();
|
|
699
|
+
});
|
|
700
|
+
});
|
|
701
|
+
});
|