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:
Alireza authored and GitHub committed 2023-02-17 15:04:07 -05:00
1 parent ae4183852f
commit 926290f69e
83 files changed
+6286 -6860

No files matched your search

+5
View File
@@ -96,6 +96,11 @@ async function appInit(appConfigOrFunc, defaultExtensions, defaultModes) {
appConfig.modes.push(mode);
}
// remove modes that are not objects, or have no id
appConfig.modes = appConfig.modes.filter(
mode => typeof mode === 'object' && mode.id
);
return {
appConfig,
commandsManager,
+2 -1
View File
@@ -1,4 +1,5 @@
import useDebounce from './useDebounce.js';
import useQuery from './useQuery.js';
import useSearchParams from './useSearchParams.js';
export { useDebounce, useQuery };
export { useDebounce, useQuery, useSearchParams };
@@ -0,0 +1,17 @@
import useQuery from './useQuery';
/**
* It returns a Map of the query parameters in the URL, where the keys are
* lowercase
* @returns A function that returns a Map of the query parameters.
*/
export default function useSearchParams() {
const query = useQuery();
// make query params case-insensitive
const searchParams = new Map();
for (const [key, value] of query) {
searchParams.set(key.toLowerCase(), value);
}
return searchParams;
}
+16 -15
View File
@@ -5,7 +5,6 @@ import 'regenerator-runtime/runtime';
import App from './App';
import React from 'react';
import ReactDOM from 'react-dom';
/**
* EXTENSIONS AND MODES
* =================
@@ -15,21 +14,23 @@ import ReactDOM from 'react-dom';
* pluginImports.js imports all of the modes and extensions and adds them
* to the window for processing.
*/
import loadDynamicImports from './pluginImports.js';
import loadDynamicImports, { loadRuntimeImports } from './pluginImports.js';
loadDynamicImports().then(() => {
/**
* Combine our appConfiguration with installed extensions and modes.
* In the future appConfiguration may contain modes added at runtime.
* */
const appProps = {
config: window ? window.config : {},
defaultExtensions: window.extensions,
defaultModes: window.modes,
};
loadRuntimeImports(window.config).then(() => {
/**
* Combine our appConfiguration with installed extensions and modes.
* In the future appConfiguration may contain modes added at runtime.
* */
const appProps = {
config: window ? window.config : {},
defaultExtensions: window.extensions,
defaultModes: window.modes,
};
/** Create App */
const app = React.createElement(App, appProps, null);
/** Render */
ReactDOM.render(app, document.getElementById('root'));
/** Create App */
const app = React.createElement(App, appProps, null);
/** Render */
ReactDOM.render(app, document.getElementById('root'));
});
});
+35 -13
View File
@@ -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);
}
@@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
//
import filtersMeta from './filtersMeta.js';
import { useAppConfig } from '@state';
import { useDebounce, useQuery } from '@hooks';
import { useDebounce, useSearchParams } from '@hooks';
import { utils, hotkeys } from '@ohif/core';
import {
@@ -54,10 +54,10 @@ function WorkList({
// ~ Modes
const [appConfig] = useAppConfig();
// ~ Filters
const query = useQuery();
const searchParams = useSearchParams();
const navigate = useNavigate();
const STUDIES_LIMIT = 101;
const queryFilterValues = _getQueryFilterValues(query);
const queryFilterValues = _getQueryFilterValues(searchParams);
const [filterValues, _setFilterValues] = useState({
...defaultFilterValues,
...queryFilterValues,
@@ -503,7 +503,7 @@ const defaultFilterValues = {
function _tryParseInt(str, defaultValue) {
let retValue = defaultValue;
if (str !== null) {
if (str != null) {
if (str.length > 0) {
if (!isNaN(str)) {
retValue = parseInt(str);
@@ -513,24 +513,24 @@ function _tryParseInt(str, defaultValue) {
return retValue;
}
function _getQueryFilterValues(query) {
function _getQueryFilterValues(params) {
const queryFilterValues = {
patientName: query.get('patientName'),
mrn: query.get('mrn'),
patientName: params.get('patientname'),
mrn: params.get('mrn'),
studyDate: {
startDate: query.get('startDate'),
endDate: query.get('endDate'),
startDate: params.get('startdate') || null,
endDate: params.get('enddate') || null,
},
description: query.get('description'),
modalities: query.get('modalities')
? query.get('modalities').split(',')
description: params.get('description'),
modalities: params.get('modalities')
? params.get('modalities').split(',')
: [],
accession: query.get('accession'),
sortBy: query.get('sortBy'),
sortDirection: query.get('sortDirection'),
pageNumber: _tryParseInt(query.get('pageNumber'), undefined),
resultsPerPage: _tryParseInt(query.get('resultsPerPage'), undefined),
datasources: query.get('datasources'),
accession: params.get('accession'),
sortBy: params.get('sortby'),
sortDirection: params.get('sortdirection'),
pageNumber: _tryParseInt(params.get('pagenumber'), undefined),
resultsPerPage: _tryParseInt(params.get('resultsperpage'), undefined),
datasources: params.get('datasources'),
};
// Delete null/undefined keys