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

+11 -3
View File
@@ -18,6 +18,7 @@ export function initCornerstoneToolsAliases() {
cy.get('[data-cy="MoreTools-split-button-secondary"]').as('moreBtnSecondary');
cy.get('[data-cy="Layout"]').as('layoutBtn');
cy.get('.cornerstone-viewport-element').as('viewport');
cy.get('[data-cy="MPR"]').as('mprBtn');
}
//Creating aliases for Common page elements
@@ -49,9 +50,16 @@ export function initCommonElementsAliases() {
//Creating aliases for Routes
export function initRouteAliases() {
cy.server();
cy.route('GET', '**/series**').as('getStudySeries');
cy.route('GET', '**/studies**').as('getStudies');
cy.intercept('GET', '**/series**', { statusCode: 200, body: [] }).as(
'getStudySeries'
);
// Todo: for some reason cypress does not redirect to the correct url
// so we intercept the request and redirect it to the correct url
cy.intercept('/studies?limit*', req => {
const url = req.url.replace(/\/studies\?/, '/studies/?limit');
req.url = url;
});
}
//Creating aliases for Study List page elements on Desktop experience
+47 -7
View File
@@ -5,7 +5,6 @@ import {
initCornerstoneToolsAliases,
initCommonElementsAliases,
initRouteAliases,
initVTKToolsAliases,
initStudyListAliasesOnDesktop,
initStudyListAliasesOnTablet,
initPreferencesModalAliases,
@@ -46,7 +45,9 @@ import {
Cypress.Commands.add('openStudy', PatientName => {
cy.openStudyList();
cy.get('#filter-patientNameOrId').type(PatientName);
cy.wait('@getStudies');
// cy.get('@getStudies').then(() => {
cy.wait(1000);
cy.get('[data-cy="study-list-results"]', { timeout: 5000 })
.contains(PatientName)
.first()
@@ -56,15 +57,16 @@ Cypress.Commands.add('openStudy', PatientName => {
Cypress.Commands.add('checkStudyRouteInViewer', StudyInstanceUID => {
cy.location('pathname').then($url => {
cy.log($url);
if ($url == 'blank' || !$url.includes(`/viewer/${StudyInstanceUID}`)) {
if ($url == 'blank' || !$url.includes(`/basic-test/${StudyInstanceUID}`)) {
cy.openStudyInViewer(StudyInstanceUID);
cy.waitDicomImage();
cy.wait(2000);
}
});
});
Cypress.Commands.add('openStudyInViewer', StudyInstanceUID => {
cy.visit(`/viewer?StudyInstanceUIDs=${StudyInstanceUID}`);
cy.visit(`/basic-test?StudyInstanceUIDs=${StudyInstanceUID}`);
});
/**
@@ -89,16 +91,20 @@ Cypress.Commands.add('openStudyModality', Modality => {
/**
* Command to wait and check if a new page was loaded
*
* @param {string} url - part of the expected url. Default value is /viewer
* @param {string} url - part of the expected url. Default value is /basic-test
*/
Cypress.Commands.add('isPageLoaded', (url = '/viewer') => {
Cypress.Commands.add('isPageLoaded', (url = '/basic-test') => {
return cy.location('pathname', { timeout: 60000 }).should('include', url);
});
Cypress.Commands.add('openStudyList', () => {
cy.initRouteAliases();
cy.visit('/');
cy.wait('@getStudies');
// For some reason cypress 12.x does not like to stub the network request
// so we just wait herer for 1 second
// cy.wait('@getStudies');
cy.wait(1000);
});
Cypress.Commands.add('waitStudyList', () => {
@@ -450,6 +456,29 @@ Cypress.Commands.add('openPreferences', () => {
});
});
Cypress.Commands.add('scrollToIndex', index => {
// Workaround implemented based on Cypress issue:
// https://github.com/cypress-io/cypress/issues/1570#issuecomment-450966053
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
window.HTMLInputElement.prototype,
'value'
).set;
cy.get('input.imageSlider[type=range]').then($range => {
// get the DOM node
const range = $range[0];
// set the value manually
nativeInputValueSetter.call(range, index);
// now dispatch the event
range.dispatchEvent(
new Event('change', {
value: index,
bubbles: true,
})
);
});
});
Cypress.Commands.add('closePreferences', () => {
cy.log('Close User Preferences Modal');
@@ -596,3 +625,14 @@ Cypress.Commands.add('setLanguage', (language, save = true) => {
.click();
});
});
// hide noisy logs
// https://github.com/cypress-io/cypress/issues/7362
// uncomment this if you really need the network logs
const origLog = Cypress.log;
Cypress.log = function(opts, ...other) {
if (opts.displayName === 'script' || opts.name === 'request') {
return;
}
return origLog(opts, ...other);
};