feat: add more e2e tests for MPR and add test mode and extension (#3180)
* tests: add various e2e tests for MPR and measurements wip add cypress config feat: add mode and extension for testing add hp applied through search params add MPR tests apply review comments add more e2e tests update yarn lock * fix unit tests failing
This commit is contained in:
1 parent
ae4183852f
commit
926290f69e
83 files changed
+6286
-6860
No files matched your search
@@ -3,9 +3,9 @@ import { useParams, useLocation } from 'react-router';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
// TODO: DicomMetadataStore should be injected?
|
||||
import { DicomMetadataStore } from '@ohif/core';
|
||||
import { DicomMetadataStore, ServicesManager } from '@ohif/core';
|
||||
import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui';
|
||||
import { useQuery } from '@hooks';
|
||||
import { useQuery, useSearchParams } from '@hooks';
|
||||
import ViewportGrid from '@components/ViewportGrid';
|
||||
import Compose from './Compose';
|
||||
|
||||
@@ -20,7 +20,7 @@ import Compose from './Compose';
|
||||
*/
|
||||
function defaultRouteInit(
|
||||
{ servicesManager, studyInstanceUIDs, dataSource, filters },
|
||||
hangingProtocol
|
||||
hangingProtocolId
|
||||
) {
|
||||
const {
|
||||
displaySetService,
|
||||
@@ -86,7 +86,7 @@ function defaultRouteInit(
|
||||
// hanging protocol in the mode configuration
|
||||
hangingProtocolService.run(
|
||||
{ studies, activeStudy, displaySets },
|
||||
hangingProtocol
|
||||
hangingProtocolId
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,7 +105,9 @@ export default function ModeRoute({
|
||||
const location = useLocation();
|
||||
const query = useQuery();
|
||||
const params = useParams();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const runTimeHangingProtocolId = searchParams.get('hangingprotocolid');
|
||||
const [studyInstanceUIDs, setStudyInstanceUIDs] = useState();
|
||||
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
@@ -121,7 +123,7 @@ export default function ModeRoute({
|
||||
const {
|
||||
displaySetService,
|
||||
hangingProtocolService,
|
||||
} = servicesManager.services;
|
||||
} = (servicesManager as ServicesManager).services;
|
||||
|
||||
const { extensions, sopClassHandlers, hotkeys, hangingProtocol } = mode;
|
||||
|
||||
@@ -249,22 +251,36 @@ export default function ModeRoute({
|
||||
extensionManager,
|
||||
commandsManager,
|
||||
});
|
||||
|
||||
// use the URL hangingProtocolId if it exists, otherwise use the one
|
||||
// defined in the mode configuration
|
||||
const hangingProtocolIdToUse = hangingProtocolService.getProtocolById(
|
||||
runTimeHangingProtocolId
|
||||
)
|
||||
? runTimeHangingProtocolId
|
||||
: hangingProtocol;
|
||||
|
||||
// Sets the active hanging protocols - if hangingProtocol is undefined,
|
||||
// resets to default. Done before the onModeEnter to allow the onModeEnter
|
||||
// to perform custom hanging protocol actions
|
||||
hangingProtocolService.setActiveProtocols(hangingProtocol);
|
||||
mode?.onModeEnter({ servicesManager, extensionManager, commandsManager });
|
||||
hangingProtocolService.setActiveProtocolIds(hangingProtocolIdToUse);
|
||||
|
||||
mode?.onModeEnter({
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
commandsManager,
|
||||
});
|
||||
|
||||
const setupRouteInit = async () => {
|
||||
/**
|
||||
* The next line should get all the query parameters provided by the URL
|
||||
* - except the StudyInstaceUIDs - and create an object called filters
|
||||
* - except the StudyInstanceUIDs - and create an object called filters
|
||||
* used to filtering the study as the user wants otherwise it will return
|
||||
* a empty object.
|
||||
*
|
||||
* Example:
|
||||
* const filters = {
|
||||
* seriesInstaceUID: 1.2.276.0.7230010.3.1.3.1791068887.5412.1620253993.114611
|
||||
* seriesInstanceUID: 1.2.276.0.7230010.3.1.3.1791068887.5412.1620253993.114611
|
||||
* }
|
||||
*/
|
||||
const filters =
|
||||
@@ -272,7 +288,10 @@ export default function ModeRoute({
|
||||
(acc: Record<string, string>, val: string) => {
|
||||
if (val !== 'StudyInstanceUIDs') {
|
||||
if (['seriesInstanceUID', 'SeriesInstanceUID'].includes(val)) {
|
||||
return { ...acc, seriesInstanceUID: query.get(val) };
|
||||
return {
|
||||
...acc,
|
||||
seriesInstanceUID: query.get(val),
|
||||
};
|
||||
}
|
||||
|
||||
return { ...acc, [val]: query.get(val) };
|
||||
@@ -291,7 +310,7 @@ export default function ModeRoute({
|
||||
dataSource,
|
||||
filters,
|
||||
},
|
||||
hangingProtocol
|
||||
hangingProtocolIdToUse
|
||||
);
|
||||
}
|
||||
|
||||
@@ -302,7 +321,7 @@ export default function ModeRoute({
|
||||
dataSource,
|
||||
filters,
|
||||
},
|
||||
hangingProtocol
|
||||
hangingProtocolIdToUse
|
||||
);
|
||||
};
|
||||
|
||||
@@ -316,7 +335,10 @@ export default function ModeRoute({
|
||||
// information, and must be in a try/catch to ensure subscriptions
|
||||
// are unsubscribed.
|
||||
try {
|
||||
mode?.onModeExit?.({ servicesManager, extensionManager });
|
||||
mode?.onModeExit?.({
|
||||
servicesManager,
|
||||
extensionManager,
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('mode exit failure', e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user