chore(build): try to build demo and docs (#3434)
This commit is contained in:
1 parent
869b8ced05
commit
828690cd3b
329 files changed
+1896
-1010
No files matched your search
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: ['cypress'],
|
||||
env: {
|
||||
'cypress/globals': true,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
describe('OHIF PDF Display', function() {
|
||||
beforeEach(function() {
|
||||
cy.openStudyInViewer('2.25.317377619501274872606137091638706705333');
|
||||
|
||||
cy.resetViewport().wait(50);
|
||||
});
|
||||
|
||||
it('checks if series thumbnails are being displayed', function() {
|
||||
cy.get('[data-cy="study-browser-thumbnail-no-image"]')
|
||||
.its('length')
|
||||
.should('be.gt', 0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
describe('OHIF Video Display', function() {
|
||||
beforeEach(function() {
|
||||
cy.openStudyInViewer('2.25.96975534054447904995905761963464388233');
|
||||
cy.resetViewport().wait(50);
|
||||
});
|
||||
|
||||
it('checks if series thumbnails are being displayed', function() {
|
||||
cy.get('[data-cy="study-browser-thumbnail-no-image"]')
|
||||
.its('length')
|
||||
.should('be.gt', 1);
|
||||
});
|
||||
|
||||
it('performs double-click to load thumbnail in active viewport', () => {
|
||||
cy.get(
|
||||
'[data-cy="study-browser-thumbnail-no-image"]:nth-child(2)'
|
||||
).dblclick();
|
||||
|
||||
//const expectedText = 'Ser: 3';
|
||||
//cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
describe('OHIF HP', () => {
|
||||
const beforeSetup = () => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1',
|
||||
'&hangingProtocolId=@ohif/mnGrid'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
};
|
||||
|
||||
it('Should display 3 up', () => {
|
||||
beforeSetup();
|
||||
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', 3);
|
||||
});
|
||||
|
||||
it('Should navigate next/previous stage', () => {
|
||||
beforeSetup();
|
||||
|
||||
cy.get('body').type(',');
|
||||
cy.wait(250);
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', 4);
|
||||
|
||||
cy.get('body').type('..');
|
||||
cy.wait(250);
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', 2);
|
||||
});
|
||||
|
||||
it('Should navigate to display set specified', () => {
|
||||
// This filters by series instance UID, meaning there will only be 1 thumbnail
|
||||
// It applies the initial SOP instance, navigating to that image
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1',
|
||||
'&SeriesInstanceUID=1.3.6.1.4.1.25403.345050719074.3824.20170125113545.4&initialSopInstanceUID=1.3.6.1.4.1.25403.345050719074.3824.20170125113546.1'
|
||||
);
|
||||
cy.expectMinimumThumbnails(1);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
|
||||
// The specified series/sop UID's are index 101, so ensure that image is displayed
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', 'I:6');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,52 @@
|
||||
describe('OHIF Double Click', () => {
|
||||
beforeEach(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1',
|
||||
'&hangingProtocolId=@ohif/mnGrid'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
});
|
||||
|
||||
it('Should double click each viewport to one up and back', () => {
|
||||
const numExpectedViewports = 3;
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', numExpectedViewports);
|
||||
|
||||
for (let i = 0; i < numExpectedViewports; i += 1) {
|
||||
// For whatever reason, with Cypress tests, we have to activate the
|
||||
// viewport we are double clicking first.
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.eq(i)
|
||||
.trigger('mousedown', 'center', { force: true })
|
||||
.trigger('mouseup', 'center', { force: true });
|
||||
|
||||
// Wait for the viewport to be 'active'.
|
||||
// TODO Is there a better way to do this?
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.eq(i)
|
||||
.parent()
|
||||
.find('[data-cy="viewport-pane"]')
|
||||
.not('.pointer-events-none');
|
||||
|
||||
// The actual double click.
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.eq(i)
|
||||
.trigger('dblclick', 'center');
|
||||
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', 1);
|
||||
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.eq(0)
|
||||
.trigger('dblclick', 'center');
|
||||
|
||||
cy.get('[data-cy="viewport-pane"]')
|
||||
.its('length')
|
||||
.should('be.eq', numExpectedViewports);
|
||||
}
|
||||
});
|
||||
});
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
describe('OHIF Context Menu', function () {
|
||||
beforeEach(function () {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCommonElementsAliases();
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.resetViewport().wait(50);
|
||||
});
|
||||
|
||||
it('checks context menu customization', function () {
|
||||
// Add length measurement
|
||||
cy.addLengthMeasurement();
|
||||
cy.get('[data-cy="prompt-begin-tracking-yes"]').click();
|
||||
cy.get('[data-cy="measurement-item"]').click();
|
||||
|
||||
const [x1, y1] = [150, 100];
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', x1, y1, {
|
||||
which: 3,
|
||||
})
|
||||
.trigger('mouseup', x1, y1, {
|
||||
which: 3,
|
||||
});
|
||||
|
||||
// Contextmenu is visible
|
||||
cy.get('[data-cy="context-menu"]').should('be.visible');
|
||||
|
||||
// Click "Finding" subMenu
|
||||
cy.get('[data-cy="context-menu-item"]')
|
||||
.contains('Finding')
|
||||
.click();
|
||||
|
||||
// Click "Finding" subMenu
|
||||
cy.get('[data-cy="context-menu-item"]')
|
||||
.contains('Aortic insufficiency')
|
||||
.click();
|
||||
cy.get('[data-cy="measurement-item"]').contains('Aortic insufficiency');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,158 @@
|
||||
describe('OHIF Cornerstone Hotkeys', () => {
|
||||
beforeEach(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
|
||||
cy.window()
|
||||
.its('cornerstone')
|
||||
.then(cornerstone => {
|
||||
// For debugging issues where tests pass locally but fail on CI
|
||||
// - Sometimes Cypress orb seems to use CPU rendering pathway
|
||||
cy.log(
|
||||
`Cornerstone using CPU Rendering?: ${cornerstone.getShouldUseCPURendering()}`
|
||||
);
|
||||
});
|
||||
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
});
|
||||
|
||||
it('checks if hotkeys "R" and "L" can rotate the image', () => {
|
||||
// Hotkey R
|
||||
cy.get('body').type('R');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'P');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
// Hotkey L
|
||||
cy.get('body').type('L');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
});
|
||||
|
||||
it('checks if hotkeys "ArrowUp" and "ArrowDown" can navigate in the stack', () => {
|
||||
// Hotkey ArrowDown
|
||||
cy.get('body').type('{downarrow}');
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', 'I:2 (2/26)');
|
||||
// Hotkey ArrowUp
|
||||
cy.get('body').type('{uparrow}');
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', 'I:1 (1/26)');
|
||||
});
|
||||
|
||||
it('checks if hotkeys "V" and "H" can flip the image', () => {
|
||||
// Hotkey H
|
||||
cy.get('body').type('h');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'L');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
// Hotkey V
|
||||
cy.get('body').type('v');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'L');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'P');
|
||||
});
|
||||
|
||||
// it('checks if hotkeys "+", "-" and "=" can zoom in, out and fit to viewport', () => {
|
||||
// //Click on button and verify if icon is active on toolbar
|
||||
// cy.get('@zoomBtn')
|
||||
// .click()
|
||||
// .then($zoomBtn => {
|
||||
// cy.wrap($zoomBtn).should('have.class', 'active');
|
||||
// });
|
||||
|
||||
// // Hotkey +
|
||||
// cy.get('body').type('+++'); // Press hotkey 3 times
|
||||
// cy.get('@viewportInfoTopLeft').should('contains.text', 'Zoom:2.30x');
|
||||
// // Hotkey -
|
||||
// cy.get('body').type('-');
|
||||
// cy.get('@viewportInfoTopLeft').should('contains.text', 'Zoom:2.09x');
|
||||
// // Hotkey =
|
||||
// cy.get('body').type('=');
|
||||
// cy.get('@viewportInfoTopLeft').should('contains.text', 'Zoom:1.67x');
|
||||
// });
|
||||
|
||||
it('checks if hotkey "SPACEBAR" can reset the image', () => {
|
||||
// Press multiples hotkeys
|
||||
cy.get('body').type('v+++i');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'P');
|
||||
|
||||
// Hotkey SPACEBAR
|
||||
cy.get('body').type(' ');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
});
|
||||
|
||||
/*
|
||||
// TODO: Pretty sure this is not implemented yet
|
||||
// it('uses hotkeys "RightArrow" and "LeftArrow" to navigate between multiple viewports', () => {
|
||||
//Select viewport layout (3,1)
|
||||
cy.setLayout(3, 1);
|
||||
cy.waitViewportImageLoading();
|
||||
|
||||
// Press multiples hotkeys on viewport #1
|
||||
cy.get('body').type('VL+++I');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'A');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoBottomRight').should('contains.text', 'Zoom: 134%');
|
||||
|
||||
// Hotkey RightArrow: Move to next viewport
|
||||
cy.get('body').type('{rightarrow}');
|
||||
|
||||
// Get overlay information from viewport #2
|
||||
cy.get(
|
||||
':nth-child(2) > .viewport-wrapper > .viewport-element > .ViewportOrientationMarkers.noselect > .top-mid.orientation-marker'
|
||||
).as('viewport2InfoMidTop');
|
||||
cy.get(
|
||||
':nth-child(2) > .viewport-wrapper > .viewport-element > .ViewportOrientationMarkers.noselect > .left-mid.orientation-marker'
|
||||
).as('viewport2InfoMidLeft');
|
||||
cy.get(
|
||||
':nth-child(2) > .viewport-wrapper > .viewport-element > .ViewportOverlay > div.bottom-right.overlay-element > div'
|
||||
).as('viewport2InfoBottomRight');
|
||||
|
||||
// Press multiples hotkeys on viewport #2
|
||||
cy.get('body').type('RR++H+++I');
|
||||
cy.get('@viewport2InfoMidLeft').should('contains.text', 'P');
|
||||
cy.get('@viewport2InfoMidTop').should('contains.text', 'H');
|
||||
cy.get('@viewport2InfoBottomRight').should('contains.text', 'Zoom: 120%');
|
||||
|
||||
// Hotkey LeftArrow: Move to previous viewport
|
||||
cy.get('body').type('{leftarrow}');
|
||||
|
||||
// Hotkey SPACEBAR: Reset viewport #1
|
||||
cy.get('body').type(' ');
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
cy.get('@viewportInfoBottomRight').should('contains.text', 'Zoom: 89%');
|
||||
|
||||
// Hotkey RightArrow: Move to next viewport
|
||||
cy.get('body').type('{rightarrow}');
|
||||
|
||||
// Hotkey SPACEBAR: Reset viewport #2
|
||||
cy.get('body').type(' ');
|
||||
cy.get('@viewport2InfoMidLeft').should('contains.text', 'A');
|
||||
cy.get('@viewport2InfoMidTop').should('contains.text', 'H');
|
||||
cy.get('@viewport2InfoBottomRight').should('contains.text', 'Zoom: 45%');
|
||||
|
||||
//Select viewport layout (1,1)
|
||||
cy.setLayout(1, 1);
|
||||
});*/
|
||||
|
||||
//TO-DO: This test is blocked by issue #1095 (https://github.com/OHIF/Viewers/issues/1095)
|
||||
//Once issue is fixed, this test can be uncommented
|
||||
// it('checks if hotkey "Z" activates zoom tool', () => {
|
||||
// // Hotkey Z
|
||||
// cy.get('body').type('Z');
|
||||
// // Verify if icon is active on toolbar
|
||||
// cy.get('@zoomBtn').should('have.class', 'active');
|
||||
// });
|
||||
|
||||
//TO-DO: This test is blocked by issue #1095 (https://github.com/OHIF/Viewers/issues/1095)
|
||||
//Once issue is fixed, this test can be uncommented
|
||||
// it('checks if hotkeys "PageDown" and "PageUp" can navigate in the series thumbnails', () => {
|
||||
// // Hotkey PageDown
|
||||
// cy.get('body').type('{pagedown}{pagedown}'); // press hotkey twice
|
||||
// cy.get('@viewportInfoBottomLeft').should('contains.text', 'Ser: 3');
|
||||
// // Hotkey PageUp
|
||||
// cy.get('body').type('{pageup}');
|
||||
// cy.get('@viewportInfoBottomLeft').should('contains.text', 'Ser: 2');
|
||||
// });
|
||||
});
|
||||
@@ -0,0 +1,432 @@
|
||||
describe('OHIF Cornerstone Toolbar', () => {
|
||||
beforeEach(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
|
||||
cy.get('[data-cy="study-browser-thumbnail"]')
|
||||
.eq(1)
|
||||
.click();
|
||||
|
||||
//const expectedText = 'Ser: 1';
|
||||
//cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText);
|
||||
});
|
||||
|
||||
it('checks if all primary buttons are being displayed', () => {
|
||||
cy.get('@zoomBtn').should('be.visible');
|
||||
cy.get('@wwwcBtnPrimary').should('be.visible');
|
||||
cy.get('@wwwcBtnSecondary').should('be.visible');
|
||||
cy.get('@panBtn').should('be.visible');
|
||||
cy.get('@measurementToolsBtnPrimary').should('be.visible');
|
||||
cy.get('@measurementToolsBtnSecondary').should('be.visible');
|
||||
cy.get('@moreBtnPrimary').should('be.visible');
|
||||
cy.get('@moreBtnSecondary').should('be.visible');
|
||||
cy.get('@layoutBtn').should('be.visible');
|
||||
});
|
||||
|
||||
/*it('checks if Stack Scroll tool will navigate across all series in the viewport', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.get('@stackScrollBtn')
|
||||
.click()
|
||||
.then($stackScrollBtn => {
|
||||
cy.wrap($stackScrollBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
//drags the mouse inside the viewport to be able to interact with series
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { buttons: 1 })
|
||||
.trigger('mousemove', 'top', { buttons: 1 })
|
||||
.trigger('mouseup');
|
||||
const expectedText =
|
||||
'Ser: 1Img: 1 1/26256 x 256Loc: -30.00 mm Thick: 5.00 mm';
|
||||
cy.get('@viewportInfoBottomLeft').should('have.text', expectedText);
|
||||
});*/
|
||||
|
||||
// it('checks if Zoom tool will zoom in/out an image in the viewport', () => {
|
||||
// //Click on button and verify if icon is active on toolbar
|
||||
// cy.get('@zoomBtn')
|
||||
// .click()
|
||||
// .then($zoomBtn => {
|
||||
// cy.wrap($zoomBtn).should('have.class', 'active');
|
||||
// });
|
||||
|
||||
// // IMPORTANT: Cypress sends out a mouseEvent which doesn't have the buttons
|
||||
// // property. This is a workaround to simulate a mouseEvent with the buttons property
|
||||
// // which is consumed by cornerstone
|
||||
// cy.get('@viewport')
|
||||
// .trigger('mousedown', 'center', { buttons: 1 })
|
||||
// .trigger('mousemove', 'top', {
|
||||
// buttons: 1,
|
||||
// })
|
||||
// .trigger('mouseup', {
|
||||
// buttons: 1,
|
||||
// });
|
||||
|
||||
// const expectedText = 'Zoom:0.96x';
|
||||
// cy.get('@viewportInfoTopLeft').should('have.text', expectedText);
|
||||
// });
|
||||
|
||||
it('checks if Levels tool will change the window width and center of an image', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.get('@wwwcBtnPrimary')
|
||||
.click()
|
||||
.then($wwwcBtn => {
|
||||
cy.wrap($wwwcBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
//drags the mouse inside the viewport to be able to interact with series
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { buttons: 1 })
|
||||
// Since we have scrollbar on the right side of the viewport, we need to
|
||||
// force the mousemove since it goes to another element
|
||||
.trigger('mousemove', 'right', { buttons: 1, force: true })
|
||||
.trigger('mouseup', { buttons: 1 });
|
||||
|
||||
// The exact text is slightly dependent on the viewport resolution, so leave a range
|
||||
cy.get('@viewportInfoTopLeft').should($txt => {
|
||||
const text = $txt.text();
|
||||
expect(text)
|
||||
.to.include('W:193')
|
||||
.include('L:479');
|
||||
});
|
||||
});
|
||||
|
||||
it('checks if Pan tool will move the image inside the viewport', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.get('@panBtn')
|
||||
.click()
|
||||
.then($panBtn => {
|
||||
cy.wrap($panBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { buttons: 1 })
|
||||
.trigger('mousemove', 'bottom', { buttons: 1 })
|
||||
.trigger('mouseup', 'bottom');
|
||||
});
|
||||
|
||||
it('checks if Length annotation can be added to viewport and shows up in the measurements panel', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.addLengthMeasurement();
|
||||
cy.get('[data-cy="viewport-notification"]').should('exist');
|
||||
cy.get('[data-cy="viewport-notification"]').should('be.visible');
|
||||
cy.get('[data-cy="prompt-begin-tracking-yes"]').click();
|
||||
|
||||
//Verify the measurement exists in the table
|
||||
cy.get('@measurementsPanel').should('be.visible');
|
||||
|
||||
cy.get('[data-cy="measurement-item"]')
|
||||
.its('length')
|
||||
.should('be.at.least', 1);
|
||||
});
|
||||
|
||||
/*it('checks if angle annotation can be added on viewport without causing any errors', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.get('@angleBtn')
|
||||
.click()
|
||||
.then($angleBtn => {
|
||||
cy.wrap($angleBtn).should('have.class', 'active'); // TODO: should we just add the 'active' class back? Or use a data property?
|
||||
});
|
||||
|
||||
//Add annotation on the viewport
|
||||
const initPos = [180, 390];
|
||||
const midPos = [300, 410];
|
||||
const finalPos = [180, 450];
|
||||
cy.addAngle('@viewport', initPos, midPos, finalPos);
|
||||
});*/
|
||||
|
||||
it('checks if Reset tool will reset all changes made on the image', () => {
|
||||
//Make some changes by zooming in and rotating the image
|
||||
cy.imageZoomIn();
|
||||
cy.imageContrast();
|
||||
|
||||
//Click on reset button
|
||||
cy.resetViewport();
|
||||
|
||||
const expectedText = 'W:958L:479';
|
||||
cy.get('@viewportInfoTopLeft').should('have.text', expectedText);
|
||||
});
|
||||
|
||||
/*it('checks if CINE tool will prompt a modal with working controls', () => {
|
||||
cy.server();
|
||||
cy.route('GET', '/!**!/studies/!**!/').as('studies');
|
||||
|
||||
//Click on button
|
||||
cy.get('@cineBtn').click();
|
||||
|
||||
// Verify if cine control overlay is being displayed
|
||||
cy.get('.cine-controls')
|
||||
.as('cineControls')
|
||||
.should('be.visible');
|
||||
|
||||
//Test PLAY button
|
||||
cy.get('[title="Play / Stop"]').then($btn => {
|
||||
$btn.click();
|
||||
cy.wait(100);
|
||||
$btn.click();
|
||||
});
|
||||
|
||||
let expectedText = 'Img: 1 1/26';
|
||||
cy.get('@viewportInfoBottomLeft', { timeout: 15000 }).should(
|
||||
'not.have.text',
|
||||
expectedText
|
||||
);
|
||||
|
||||
//Test SKIP TO FIRST IMAGE button
|
||||
cy.get('[title="Skip to first Image"]')
|
||||
.click()
|
||||
.wait(1000);
|
||||
cy.get('@viewportInfoBottomLeft', { timeout: 15000 }).should(
|
||||
'contain.text',
|
||||
expectedText
|
||||
);
|
||||
|
||||
//Test NEXT IMAGE button
|
||||
cy.get('[title="Next Image"]')
|
||||
.click()
|
||||
.wait(1000);
|
||||
expectedText = 'Img: 2 2/26';
|
||||
cy.get('@viewportInfoBottomLeft', { timeout: 15000 }).should(
|
||||
'contain.text',
|
||||
expectedText
|
||||
);
|
||||
|
||||
//Test SKIP TO LAST IMAGE button
|
||||
cy.get('[title="Skip to last Image"]')
|
||||
.click()
|
||||
.wait(2000);
|
||||
expectedText = 'Img: 27 26/26';
|
||||
cy.get('@viewportInfoBottomLeft', { timeout: 15000 }).should(
|
||||
'contain.text',
|
||||
expectedText
|
||||
);
|
||||
|
||||
//Test PREVIOUS IMAGE button
|
||||
cy.get('[title="Previous Image"]')
|
||||
.click()
|
||||
.wait(1000);
|
||||
expectedText = 'Img: 26 25/26';
|
||||
cy.get('@viewportInfoBottomLeft', { timeout: 15000 }).should(
|
||||
'contain.text',
|
||||
expectedText
|
||||
);
|
||||
|
||||
//Click on Cine button
|
||||
cy.get('@cineBtn')
|
||||
.click()
|
||||
.then(() => {
|
||||
// Verify that cine control overlay is hidden
|
||||
cy.get('@cineControls').should('not.exist');
|
||||
});
|
||||
});*/
|
||||
|
||||
/**
|
||||
it('checks if More button will prompt a modal with secondary tools', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtnSecondary').click();
|
||||
|
||||
//Verify if overlay is displayed
|
||||
cy.get('[data-cy="MoreTools-list-menu"]')
|
||||
.as('toolbarOverlay')
|
||||
.should('be.visible');
|
||||
|
||||
// Click on one of the secondary tools from the overlay
|
||||
cy.get('[data-cy="Magnify"]').click();
|
||||
|
||||
// Check if More button is active and if it has same icon as the secondary tool selected
|
||||
cy.get('@moreBtnPrimary').then($moreBtn => {
|
||||
cy.wrap($moreBtn)
|
||||
.should('have.class', 'active')
|
||||
.should('have.attr', 'data-tool', 'Magnify');
|
||||
});
|
||||
|
||||
// Verify if overlay is hidden
|
||||
cy.get('@toolbarOverlay').should('not.be.visible');
|
||||
});
|
||||
*/
|
||||
|
||||
/*it('checks if Layout tool will multiply the number of viewports displayed', () => {
|
||||
//Click on Layout button and verify if overlay is displayed
|
||||
cy.get('@layoutBtn')
|
||||
.click()
|
||||
.then(() => {
|
||||
cy.get('.layoutChooser')
|
||||
.as('layoutChooser')
|
||||
.should('be.visible')
|
||||
.find('td')
|
||||
.its('length')
|
||||
.should('be.eq', 9);
|
||||
cy.get('@layoutBtn').click();
|
||||
});
|
||||
|
||||
//verify if layout has changed to 2 viewports
|
||||
cy.setLayout(1, 2);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 2);
|
||||
});
|
||||
|
||||
cy.setLayout(2, 1);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 2);
|
||||
});
|
||||
|
||||
//verify if layout has changed to 3 viewports
|
||||
cy.setLayout(1, 3);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wait(1000);
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 3);
|
||||
});
|
||||
|
||||
cy.setLayout(3, 1);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 3);
|
||||
});
|
||||
|
||||
//verify if layout has changed to 4 viewports
|
||||
cy.setLayout(2, 2);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 4);
|
||||
});
|
||||
|
||||
//verify if layout has changed to 6 viewports
|
||||
cy.setLayout(2, 3);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 6);
|
||||
});
|
||||
|
||||
cy.setLayout(3, 2);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 6);
|
||||
});
|
||||
|
||||
//verify if layout has changed to 9 viewports
|
||||
cy.setLayout(3, 3);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 9);
|
||||
});
|
||||
|
||||
//verify if layout has changed to 1 viewport
|
||||
cy.setLayout(1, 1);
|
||||
cy.get('.viewport-container').then($viewport => {
|
||||
cy.wrap($viewport)
|
||||
.its('length')
|
||||
.should('be.eq', 1);
|
||||
});
|
||||
});
|
||||
|
||||
it('checks if the available viewport was set to active when layout is decreased', () => {
|
||||
cy.setLayout(3, 3);
|
||||
|
||||
// activate the ninth viewport
|
||||
cy.get('[data-cy=viewport-container-8]')
|
||||
.click()
|
||||
.should('have.class', 'active');
|
||||
|
||||
cy.setLayout(1, 1);
|
||||
|
||||
// first viewport should be active
|
||||
cy.get('[data-cy=viewport-container-0]').should('have.class', 'active');
|
||||
});
|
||||
|
||||
it('checks if Clear tool will delete all measurements added in the viewport', () => {
|
||||
//Add measurements in the viewport
|
||||
cy.addLengthMeasurement();
|
||||
cy.addAngleMeasurement();
|
||||
|
||||
//Verify if measurement annotation was added into the measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('[data-cy="measurement-item"]')
|
||||
.its('length')
|
||||
.should('be.at.least', 2);
|
||||
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay')
|
||||
.as('toolbarOverlay')
|
||||
.should('be.visible');
|
||||
//Click on Clear button
|
||||
cy.get('[data-cy="clear"]').click();
|
||||
|
||||
//Verify if measurements were removed from the measurements panel
|
||||
|
||||
//cy.get('.measurementItem'); //.should('not.exist');
|
||||
|
||||
//Close More button overlay
|
||||
cy.get('@moreBtn').click();
|
||||
|
||||
//Close the measurements panel
|
||||
cy.get('@measurementsBtn').then($btn => {
|
||||
$btn.click();
|
||||
cy.get('@measurementsPanel').should('not.be.enabled');
|
||||
});
|
||||
});
|
||||
|
||||
it('check if Rotate tool will change the image orientation in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay')
|
||||
.should('be.visible')
|
||||
.then(() => {
|
||||
//Click on Rotate button
|
||||
cy.get('[data-cy="rotate right"]').click({ force: true });
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'F');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
});
|
||||
|
||||
//Click on More button to close it
|
||||
cy.get('@moreBtn').click();
|
||||
});
|
||||
|
||||
it('check if Flip H tool will flip the image horizontally in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay').should('be.visible');
|
||||
|
||||
//Click on Flip H button
|
||||
cy.get('[data-cy="flip h"]').click();
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'L');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'H');
|
||||
|
||||
//Click on More button to close it
|
||||
cy.get('@moreBtn').click();
|
||||
cy.get('.tooltip-toolbar-overlay').should('not.exist');
|
||||
});
|
||||
|
||||
it('check if Flip V tool will flip the image vertically in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay').should('be.visible');
|
||||
|
||||
//Click on Flip V button
|
||||
cy.get('[data-cy="flip v"]').click();
|
||||
cy.get('@viewportInfoMidLeft').should('contains.text', 'R');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'F');
|
||||
|
||||
//Click on More button to close it
|
||||
cy.get('@moreBtn').click();
|
||||
cy.get('.tooltip-toolbar-overlay').should('not.exist');
|
||||
});*/
|
||||
});
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
describe('OHIF Download Snapshot File', () => {
|
||||
beforeEach(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.openDownloadImageModal();
|
||||
});
|
||||
|
||||
it('checks displayed information for Desktop experience', function() {
|
||||
// Set Desktop resolution
|
||||
// cy.viewport(1750, 720);
|
||||
// Visual comparison
|
||||
// cy.screenshot('Download Image Modal - Desktop experience');
|
||||
//Check if all elements are displayed
|
||||
|
||||
// TODO: need to add this attribute to the modal
|
||||
cy.get('[data-cy=modal-header]')
|
||||
.as('downloadImageModal')
|
||||
.should('contain.text', 'Download High Quality Image');
|
||||
|
||||
// Check input fields
|
||||
// TODO: select2
|
||||
// cy.get('[data-cy="file-type"]')
|
||||
// .select('png')
|
||||
// .should('have.value', 'png')
|
||||
// .select('jpg')
|
||||
// .should('have.value', 'jpg');
|
||||
|
||||
// Check image preview
|
||||
cy.get('[data-cy="image-preview"]').should('contain.text', 'Image preview');
|
||||
|
||||
//TODO: This is a canvas now, not an img with src
|
||||
// cy.get('[data-cy="viewport-preview-img"]')
|
||||
// .should('have.attr', 'src')
|
||||
// .and('include', 'data:image');
|
||||
|
||||
// Check buttons
|
||||
cy.get('[data-cy="cancel-btn"]')
|
||||
.scrollIntoView()
|
||||
.should('be.visible');
|
||||
cy.get('[data-cy="download-btn"]')
|
||||
.scrollIntoView()
|
||||
.should('be.visible');
|
||||
});
|
||||
|
||||
/*it('cancel changes on download modal', function() {
|
||||
//Change Image Width, Filename and File Type
|
||||
cy.get('[data-cy="image-width"]')
|
||||
.clear()
|
||||
.type('300');
|
||||
cy.get('[data-cy="image-height"]') //Image Height should be the same as width
|
||||
.should('have.value', '300');
|
||||
cy.get('[data-cy="file-name"]')
|
||||
.clear()
|
||||
.type('new-filename');
|
||||
cy.get('[data-cy="file-type"]').select('png');
|
||||
//Click on Cancel button
|
||||
cy.get('[data-cy="cancel-btn"]')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
//Check modal is closed
|
||||
cy.get('[data-cy="modal"]').should('not.exist');
|
||||
//Open Modal
|
||||
cy.openDownloadImageModal();
|
||||
//Verify default values was restored
|
||||
cy.get('[data-cy="image-width"]').should('have.value', '512');
|
||||
cy.get('[data-cy="file-name"]').should('have.value', 'image');
|
||||
cy.get('[data-cy=file-type]').should('have.value', 'jpg');
|
||||
});*/
|
||||
|
||||
// TO-DO once issue is fixed: https://github.com/OHIF/Viewers/issues/1217
|
||||
// it('checks error messages for empty fields', function() {
|
||||
// //Clear fields Image Width and Filename
|
||||
// cy.get('[data-cy="image-width"]').clear();
|
||||
// cy.get('[data-cy="file-name"]').clear();
|
||||
|
||||
// //Click on Download button
|
||||
// cy.get('[data-cy="download-btn"]')
|
||||
// .scrollIntoView()
|
||||
// .click();
|
||||
// //Check error message
|
||||
// });
|
||||
|
||||
/*it('checks if "Show Annotations" checkbox will display annotations', function() {
|
||||
// Close modal that is initially opened
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
|
||||
// Add measurements in the viewport
|
||||
cy.addLengthMeasurement();
|
||||
cy.addAngleMeasurement();
|
||||
|
||||
// Open Modal
|
||||
cy.openDownloadImageModal();
|
||||
// Select "Show Annotations" option
|
||||
cy.get('[data-cy="show-annotations"]').check();
|
||||
// Check image preview
|
||||
cy.get('[data-cy="image-preview"]').scrollIntoView();
|
||||
//Compare classes that exists on Image Preview with Annotations and Without Annotation
|
||||
cy.get('[data-cy="modal-content"]')
|
||||
.find('canvas')
|
||||
.should('have.class', 'magnifyTool'); //Class "MagnifyTool" exists with annotations displayed on Image preview
|
||||
// Uncheck "Show Annotations" option
|
||||
cy.get('[data-cy="show-annotations"]')
|
||||
.uncheck()
|
||||
.wait(300);
|
||||
// Check that class "MagnifyTool" should not exist
|
||||
cy.get('[data-cy="modal-content"]')
|
||||
.find('canvas')
|
||||
.should('not.have.class', 'magnifyTool');
|
||||
});*/
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
describe('OHIF Study Viewer Page', function() {
|
||||
beforeEach(function() {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCommonElementsAliases();
|
||||
cy.initCornerstoneToolsAliases();
|
||||
});
|
||||
|
||||
it('scrolls series stack using scrollbar', function() {
|
||||
cy.scrollToIndex(13);
|
||||
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', '14');
|
||||
});
|
||||
|
||||
it('performs right click to zoom', function() {
|
||||
// This is not used to activate the tool, it is used to ensure the
|
||||
// top left viewport info shows the zoom values (it only shows up
|
||||
// when the zoom tool is active)
|
||||
cy.get('@zoomBtn')
|
||||
.click()
|
||||
.then($zoomBtn => {
|
||||
cy.wrap($zoomBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
const zoomLevelInitial = cy
|
||||
.get('@viewportInfoTopLeft')
|
||||
.then($viewportInfo => {
|
||||
return $viewportInfo.text().substring(6, 9);
|
||||
});
|
||||
|
||||
//Right click on viewport
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'top', { buttons: 2 })
|
||||
.trigger('mousemove', 'center', { buttons: 2 })
|
||||
.trigger('mouseup');
|
||||
|
||||
// make sure the new zoom level is less than the initial
|
||||
cy.get('@viewportInfoTopLeft').then($viewportInfo => {
|
||||
const zoomLevelFinal = $viewportInfo.text().substring(6, 9);
|
||||
expect(zoomLevelFinal < zoomLevelInitial).to.eq(true);
|
||||
});
|
||||
});
|
||||
|
||||
/*it('performs middle click to pan', function() {
|
||||
//Get image position from cornerstone and check if y axis was modified
|
||||
let cornerstone;
|
||||
let currentPan;
|
||||
|
||||
// TO DO: Replace the cornerstone pan check by Percy snapshot comparison
|
||||
cy.window()
|
||||
.its('cornerstone')
|
||||
.then(c => {
|
||||
cornerstone = c;
|
||||
currentPan = () =>
|
||||
cornerstone.getEnabledElements()[0].viewport.translation;
|
||||
});
|
||||
|
||||
//pan image with middle click
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { buttons: 3 })
|
||||
.trigger('mousemove', 'bottom', { buttons: 3 })
|
||||
.trigger('mouseup', 'bottom')
|
||||
.then(() => {
|
||||
expect(currentPan().y > 0).to.eq(true);
|
||||
});
|
||||
});*/
|
||||
|
||||
/*it('opens About modal and verify the displayed information', function() {
|
||||
cy.get('[data-cy="options-dropdown"]')
|
||||
.first()
|
||||
.click();
|
||||
cy.get('[data-cy="about-modal"]')
|
||||
.as('aboutOverlay')
|
||||
.should('be.visible');
|
||||
|
||||
//check buttons and links
|
||||
cy.get('[data-cy="about-modal"]')
|
||||
.should('contains.text', 'Visit the forum')
|
||||
.and('contains.text', 'Report an issue')
|
||||
.and('contains.text', 'https://github.com/OHIF/Viewers/');
|
||||
|
||||
//check version number
|
||||
cy.get('[data-cy="about-modal"]').then($modal => {
|
||||
cy.get('[data-cy="header-version-info"]').should($headerVersionNumber => {
|
||||
$headerVersionNumber = $headerVersionNumber.text().substring(1);
|
||||
expect($modal).to.contain($headerVersionNumber);
|
||||
});
|
||||
});
|
||||
|
||||
//close modal
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
cy.get('@aboutOverlay').should('not.exist');
|
||||
});
|
||||
*/
|
||||
});
|
||||
@@ -0,0 +1,211 @@
|
||||
describe('OHIF Measurement Panel', function() {
|
||||
beforeEach(function() {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCommonElementsAliases();
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.resetViewport().wait(50);
|
||||
});
|
||||
|
||||
it('checks if Measurements right panel can be hidden/displayed', function() {
|
||||
cy.get('@measurementsPanel').should('exist');
|
||||
cy.get('@measurementsPanel').should('be.visible');
|
||||
|
||||
cy.get('@RightCollapseBtn').click();
|
||||
cy.get('@measurementsPanel').should('not.exist');
|
||||
|
||||
cy.get('@RightCollapseBtn').click();
|
||||
cy.get('@measurementsPanel').should('exist');
|
||||
cy.get('@measurementsPanel').should('be.visible');
|
||||
});
|
||||
|
||||
it('checks if measurement item can be Relabeled under Measurements panel', function() {
|
||||
// Add length measurement
|
||||
cy.addLengthMeasurement();
|
||||
cy.get('[data-cy="viewport-notification"]').should('exist');
|
||||
cy.get('[data-cy="viewport-notification"]').should('be.visible');
|
||||
cy.get('[data-cy="prompt-begin-tracking-yes"]').click();
|
||||
cy.get('[data-cy="measurement-item"]').click();
|
||||
|
||||
cy.get('[data-cy="measurement-item"]')
|
||||
.find('svg')
|
||||
.click();
|
||||
|
||||
// enter Bone label
|
||||
cy.get('[data-cy="input-annotation"]').should('exist');
|
||||
cy.get('[data-cy="input-annotation"]').should('be.visible');
|
||||
cy.get('[data-cy="input-annotation"]').type('Bone{enter}');
|
||||
|
||||
// Verify if 'Bone' label was added
|
||||
cy.get('[data-cy="measurement-item"]').should('contain.text', 'Bone');
|
||||
});
|
||||
|
||||
it('checks if image would jump when clicked on a measurement item', function() {
|
||||
// Add length measurement
|
||||
cy.addLengthMeasurement();
|
||||
cy.get('[data-cy="prompt-begin-tracking-yes"]').click();
|
||||
|
||||
cy.scrollToIndex(13);
|
||||
|
||||
cy.addLengthMeasurement([100, 100], [200, 200]); //Adding measurement in the viewport
|
||||
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', '(14/');
|
||||
|
||||
// Click on first measurement item
|
||||
cy.get('[data-cy="measurement-item"]')
|
||||
.eq(0)
|
||||
.click();
|
||||
|
||||
cy.get('@viewportInfoTopRight').should('contains.text', '(1/');
|
||||
cy.get('@viewportInfoTopRight').should('not.contains.text', '(14/');
|
||||
});
|
||||
|
||||
/*
|
||||
TODO: Not sure why this is failing
|
||||
it('checks if Description can be added to measurement item under Measurements panel', () => {
|
||||
cy.addLengthMeasurement(); //Adding measurement in the viewport
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('.measurementItem').click();
|
||||
|
||||
// Click "Description"
|
||||
cy.get('.btnAction')
|
||||
.contains('Description')
|
||||
.click();
|
||||
|
||||
// Enter description text
|
||||
const descriptionText = 'Adding text for description test';
|
||||
cy.get('#description').type(descriptionText);
|
||||
|
||||
// Confirm
|
||||
cy.get('.btn-confirm').click();
|
||||
|
||||
//Verify if descriptionText was added
|
||||
cy.get('.measurementLocation').should('contain.text', descriptionText);
|
||||
|
||||
// Remove the measurement we just added
|
||||
cy.get('.btnAction')
|
||||
.last()
|
||||
.contains('Delete')
|
||||
.click()
|
||||
|
||||
// Close panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('@measurementsPanel').should('not.be.enabled');
|
||||
});
|
||||
*/
|
||||
|
||||
/*it('checks if measurement item can be deleted through the context menu on the viewport', function() {
|
||||
cy.addLengthMeasurement([100, 100], [200, 100]); //Adding measurement in the viewport
|
||||
|
||||
//Right click on measurement annotation
|
||||
const [x1, y1] = [150, 100];
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', x1, y1, {
|
||||
which: 3,
|
||||
})
|
||||
.trigger('mouseup', x1, y1, {
|
||||
which: 3,
|
||||
})
|
||||
.wait(300)
|
||||
.then(() => {
|
||||
//Contextmenu is visible
|
||||
cy.get('.ToolContextMenu').should('be.visible');
|
||||
});
|
||||
|
||||
//Click "Delete measurement"
|
||||
cy.get('.form-action')
|
||||
.contains('Delete measurement')
|
||||
.click();
|
||||
|
||||
//Open measurements menu
|
||||
cy.get('@measurementsBtn').click();
|
||||
|
||||
//Verify measurements was removed from panel
|
||||
cy.get('.measurementItem')
|
||||
.should('not.exist')
|
||||
.log('Annotation successfully removed');
|
||||
|
||||
//Close panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('@measurementsPanel').should('not.exist');
|
||||
});*/
|
||||
|
||||
/*it('adds relabel and description to measurement item through the context menu on the viewport', function() {
|
||||
cy.addLengthMeasurement([100, 100], [200, 100]); //Adding measurement in the viewport
|
||||
|
||||
// Relabel
|
||||
// Right click on measurement annotation
|
||||
const [x1, y1] = [150, 100];
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', x1, y1, {
|
||||
which: 3,
|
||||
})
|
||||
.trigger('mouseup', x1, y1, {
|
||||
which: 3,
|
||||
});
|
||||
|
||||
// Contextmenu is visible
|
||||
cy.get('.ToolContextMenu').should('be.visible');
|
||||
|
||||
// Click "Relabel"
|
||||
cy.get('.form-action')
|
||||
.contains('Relabel')
|
||||
.click();
|
||||
|
||||
// Search for "Brain"
|
||||
cy.get('.searchInput').type('Brain');
|
||||
|
||||
// Select "Brain" Result
|
||||
cy.get('.treeInputs > .wrapperLabel')
|
||||
.contains('Brain')
|
||||
.click();
|
||||
|
||||
// Confirm Selection
|
||||
cy.get('.checkIconWrapper').click();
|
||||
|
||||
// Description
|
||||
// Right click on measurement annotation
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', x1, y1, {
|
||||
which: 3,
|
||||
})
|
||||
.trigger('mouseup', x1, y1, {
|
||||
which: 3,
|
||||
});
|
||||
|
||||
// Contextmenu is visible
|
||||
cy.get('.ToolContextMenu').should('be.visible');
|
||||
|
||||
// Click "Description"
|
||||
cy.get('.form-action')
|
||||
.contains('Add Description')
|
||||
.click();
|
||||
|
||||
// Enter description text
|
||||
const descriptionText = 'Adding text for description test';
|
||||
cy.get('#description').type(descriptionText);
|
||||
|
||||
// Confirm
|
||||
cy.get('.btn-confirm').click();
|
||||
|
||||
//Open measurements menu
|
||||
cy.get('@measurementsBtn').click();
|
||||
|
||||
// Verify if label was added
|
||||
cy.get('.measurementLocation')
|
||||
.should('contain.text', 'Brain')
|
||||
.log('Relabel added with success');
|
||||
|
||||
//Verify if descriptionText was added
|
||||
cy.get('.measurementLocation')
|
||||
.should('contain.text', descriptionText)
|
||||
.log('Description added with success');
|
||||
|
||||
// Close panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('@measurementsPanel').should('not.exist');
|
||||
});*/
|
||||
});
|
||||
@@ -0,0 +1,150 @@
|
||||
/*describe('OHIF Save Measurements', function() {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Wait image to load on viewport
|
||||
cy.wait(2000);
|
||||
cy.resetViewport();
|
||||
cy.initCommonElementsAliases();
|
||||
});
|
||||
|
||||
it('saves new measurement annotation', function() {
|
||||
// Add measurement in the viewport
|
||||
cy.addLengthMeasurement();
|
||||
|
||||
// Verify if measurement annotation was added into the measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('.measurementItem')
|
||||
.its('length')
|
||||
.should('be.at.least', 1);
|
||||
|
||||
// TODO: Don't save until we're using in-memory data store
|
||||
// Save new measurement
|
||||
// cy.get('[data-cy="save-measurements-btn"]').click();
|
||||
|
||||
// Verify that success message overlay is displayed
|
||||
// cy.get('.sb-success')
|
||||
// .should('be.visible')
|
||||
// .and('contains.text', 'Measurements saved successfully');
|
||||
|
||||
// Visual test comparison
|
||||
cy.screenshot('Save Measurements - new measurement added');
|
||||
cy.percyCanvasSnapshot('Save Measurements - new measurement added');
|
||||
});
|
||||
|
||||
// it('retrieves saved measurements', function() {
|
||||
// // Add measurement in the viewport
|
||||
// cy.addLengthMeasurement();
|
||||
|
||||
// // Verify if measurement annotation was added into the measurements panel
|
||||
// cy.get('@measurementsBtn').click();
|
||||
// cy.get('.measurementDisplayText') // Get label size of the recently added measurement
|
||||
// .last()
|
||||
// .then($measurementSizeLabel => {
|
||||
// // Save new measurement
|
||||
// // TODO: Do not save
|
||||
// cy.get('[data-cy="save-measurements-btn"]')
|
||||
// .click()
|
||||
// .then(() => {
|
||||
// // Verify that success message overlay is displayed
|
||||
// cy.get('.sb-success').should('be.visible');
|
||||
// });
|
||||
// // Reload the page
|
||||
// cy.reload()
|
||||
// .wait(1000) //Wait page to load
|
||||
// .expectMinimumThumbnails(2); //wait all thumbnails to load
|
||||
// // Verify that recently added measurement was retrieved
|
||||
// cy.get('@measurementsBtn').click();
|
||||
// cy.get('.measurementDisplayText') // Get label size of the recently added measurement
|
||||
// .last()
|
||||
// .then($retrivedMeasurementSizeLabel => {
|
||||
// expect($retrivedMeasurementSizeLabel.textContent).to.eq(
|
||||
// $measurementSizeLabel.textContent
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// it('checks error message when saving without any measurement', function() {
|
||||
// // Checks that measurement list is empty
|
||||
// cy.get('.numberOfItems').should('have.text', '0');
|
||||
|
||||
// // Click on Save Measurement button
|
||||
// cy.get('[data-cy="save-measurements-btn"]').click();
|
||||
|
||||
// // Verify that error message overlay is displayed
|
||||
// cy.get('.sb-error')
|
||||
// .should('be.visible')
|
||||
// .and('contains.text', 'Error while saving the measurements');
|
||||
// // Close message overlay
|
||||
// cy.get('.sb-closeIcon').click();
|
||||
// });
|
||||
|
||||
it('checks if warning message is displayed on measurements of unsupported tools', function() {
|
||||
// Add measurement for unsupported tool in the viewport
|
||||
cy.addAngleMeasurement();
|
||||
|
||||
// Verify if measurement annotation was added into the measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('.measurementItem')
|
||||
.its('length')
|
||||
.should('be.at.least', 1);
|
||||
|
||||
// Check that warning is displayed for unsupported tool
|
||||
cy.get('.hasWarnings').should('be.visible');
|
||||
|
||||
// // Save new measurement
|
||||
// cy.get('[data-cy="save-measurements-btn"]').click();
|
||||
|
||||
// // Verify that error message overlay is displayed
|
||||
// cy.get('.sb-error')
|
||||
// .should('be.visible')
|
||||
// .and('contains.text', 'Error while saving the measurements');
|
||||
|
||||
// Close Measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
});
|
||||
|
||||
/*it('checks if measurements of unsupported tools were not saved', function() {
|
||||
// Add measurement for supported tool in the viewport
|
||||
cy.addLengthMeasurement();
|
||||
// Add measurement for unsupported tool in the viewport
|
||||
cy.addAngleMeasurement();
|
||||
|
||||
// Verify if measurement annotation was added into the measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('.measurementItem')
|
||||
.its('length')
|
||||
.should('be.eq', 2);
|
||||
|
||||
// Check that warning is displayed for unsupported tool
|
||||
cy.get('.hasWarnings').should('be.visible');
|
||||
|
||||
// Save new measurement
|
||||
cy.get('[data-cy="save-measurements-btn"]').click();
|
||||
|
||||
// Verify that success message overlay is displayed
|
||||
cy.get('.sb-success')
|
||||
.should('be.visible')
|
||||
.and('contains.text', 'Measurements saved successfully');
|
||||
|
||||
// Reload the page
|
||||
cy.reload()
|
||||
.wait(1000) //Wait page to load
|
||||
.expectMinimumThumbnails(2); //wait all thumbnails to load
|
||||
|
||||
//Verify that measurement for unsupported tool was not saved
|
||||
cy.get('@measurementsBtn').click();
|
||||
cy.get('.measurementItem')
|
||||
.its('length')
|
||||
.should('be.eq', 1);
|
||||
|
||||
// Close Measurements panel
|
||||
cy.get('@measurementsBtn').click();
|
||||
});
|
||||
});*/
|
||||
@@ -0,0 +1,60 @@
|
||||
describe('OHIF Study Viewer Page', function() {
|
||||
beforeEach(function() {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCommonElementsAliases();
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.resetViewport().wait(50);
|
||||
});
|
||||
|
||||
it('checks if series thumbnails are being displayed', function() {
|
||||
cy.get('[data-cy="study-browser-thumbnail"]')
|
||||
.its('length')
|
||||
.should('be.gt', 1);
|
||||
});
|
||||
|
||||
it('drags and drop a series thumbnail into viewport', function() {
|
||||
// Can't use the native drag version as the element should be rerendered
|
||||
// cy.get('[data-cy="study-browser-thumbnail"]:nth-child(2)') //element to be dragged
|
||||
// .drag('.cornerstone-canvas'); //dropzone element
|
||||
|
||||
const dataTransfer = new DataTransfer();
|
||||
|
||||
cy.get('[data-cy="study-browser-thumbnail"]:nth-child(2)')
|
||||
.first()
|
||||
.trigger('mousedown', { which: 1, button: 0 })
|
||||
.trigger('dragstart', { dataTransfer })
|
||||
.trigger('drag', {});
|
||||
cy.get('.cornerstone-canvas')
|
||||
.trigger('mousemove', 'center')
|
||||
.trigger('dragover', { dataTransfer, force: true })
|
||||
.trigger('drop', { dataTransfer, force: true });
|
||||
|
||||
//const expectedText =
|
||||
// 'Ser: 2Img: 1 1/13512 x 512Loc: -17.60 mm Thick: 3.00 mm';
|
||||
//cy.get('@viewportInfoBottomLeft').should('contain.text', expectedText);
|
||||
});
|
||||
|
||||
it('checks if Series left panel can be hidden/displayed', function() {
|
||||
cy.get('@seriesPanel').should('exist');
|
||||
cy.get('@seriesPanel').should('be.visible');
|
||||
|
||||
cy.get('@seriesBtn').click();
|
||||
cy.get('@seriesPanel').should('not.exist');
|
||||
|
||||
cy.get('@seriesBtn').click();
|
||||
cy.get('@seriesPanel').should('exist');
|
||||
cy.get('@seriesPanel').should('be.visible');
|
||||
});
|
||||
|
||||
it('performs double-click to load thumbnail in active viewport', () => {
|
||||
// Have to finish rendering the image before this works
|
||||
cy.wait(350);
|
||||
cy.get('[data-cy="study-browser-thumbnail"]:nth-child(2)').dblclick();
|
||||
|
||||
//cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText);
|
||||
});
|
||||
});
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*describe('Visual Regression - OHIF Cornerstone Hotkeys', () => {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
cy.resetViewport();
|
||||
});
|
||||
|
||||
it('checks if hotkey "I" can invert the image', () => {
|
||||
// Hotkey I
|
||||
cy.get('body').type('I');
|
||||
// Visual comparison
|
||||
cy.screenshot('Hotkey I - Should Invert Image');
|
||||
cy.percyCanvasSnapshot('Hotkey I - Should Invert Image');
|
||||
});
|
||||
|
||||
it('checks if hotkey "SPACEBAR" can reset the image', () => {
|
||||
// Press multiples hotkeys
|
||||
cy.get('body').type('V+++I');
|
||||
|
||||
// Hotkey SPACEBAR
|
||||
cy.get('body').type(' ');
|
||||
|
||||
// Visual comparison to make sure the 'inverted' image was reset
|
||||
cy.screenshot('Hotkey SPACEBAR - Should Reset Image');
|
||||
cy.percyCanvasSnapshot('Hotkey SPACEBAR - Should Reset Image');
|
||||
});
|
||||
});*/
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*describe('Visual Regression - OHIF Cornerstone Toolbar', () => {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
cy.resetViewport();
|
||||
});
|
||||
|
||||
it('checks if Pan tool will move the image inside the viewport', () => {
|
||||
//Click on button and verify if icon is active on toolbar
|
||||
cy.get('@panBtn')
|
||||
.click()
|
||||
.then($panBtn => {
|
||||
cy.wrap($panBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { which: 1 })
|
||||
.trigger('mousemove', 'bottom', { which: 1 })
|
||||
.trigger('mouseup', 'bottom');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Pan tool moved the image inside the viewport');
|
||||
});
|
||||
|
||||
it('check if Invert tool will change the colors of the image in the viewport', () => {
|
||||
// Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
// Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay').should('be.visible');
|
||||
|
||||
// Click on Invert button
|
||||
cy.get('[data-cy="invert"]').click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Invert tool - Should Invert Canvas');
|
||||
});
|
||||
|
||||
it('check if Rotate tool will change the image orientation in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay')
|
||||
.should('be.visible')
|
||||
.then(() => {
|
||||
//Click on Rotate button
|
||||
cy.get('[data-cy="rotate right"]').click({ force: true });
|
||||
});
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Rotate tool - Should Rotate Image to Right');
|
||||
});
|
||||
|
||||
it('check if Flip H tool will flip the image horizontally in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay').should('be.visible');
|
||||
|
||||
//Click on Flip H button
|
||||
cy.get('[data-cy="flip h"]').click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Flip H tool - Should Flip Image on Y axis');
|
||||
});
|
||||
|
||||
it('check if Flip V tool will flip the image vertically in the viewport', () => {
|
||||
//Click on More button
|
||||
cy.get('@moreBtn').click();
|
||||
//Verify if overlay is displayed
|
||||
cy.get('.tooltip-toolbar-overlay').should('be.visible');
|
||||
|
||||
//Click on Flip V button
|
||||
cy.get('[data-cy="flip v"]').click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Flip V tool - Should Flip Image on X axis');
|
||||
});
|
||||
});*/
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*describe('Visual Regression - OHIF Download Snapshot File', () => {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.openDownloadImageModal();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Close modal
|
||||
cy.get('[data-cy="close-button"]')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
it('checks displayed information for Desktop experience', function() {
|
||||
// Set Desktop resolution
|
||||
cy.viewport(1750, 720);
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Download Image Modal - Desktop experience');
|
||||
});
|
||||
|
||||
it('checks if "Show Annotations" checkbox will display annotations', function() {
|
||||
// Close modal that is initially opened
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
|
||||
// Add measurements in the viewport
|
||||
cy.addLengthMeasurement();
|
||||
cy.addAngleMeasurement();
|
||||
|
||||
// Open Modal
|
||||
cy.openDownloadImageModal();
|
||||
// Select "Show Annotations" option
|
||||
cy.get('[data-cy="show-annotations"]').check();
|
||||
// Check image preview
|
||||
cy.get('[data-cy="image-preview"]').scrollIntoView();
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('Download Image Modal - Show Annotations checked');
|
||||
});
|
||||
});*/
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*describe('Visual Regression - OHIF Study Viewer Page', function() {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
cy.initCommonElementsAliases();
|
||||
cy.resetViewport();
|
||||
});
|
||||
|
||||
it('checks if series thumbnails are being displayed', function() {
|
||||
cy.percyCanvasSnapshot('Series Thumbnails - Should Display Thumbnails');
|
||||
});
|
||||
|
||||
it('opens About modal and verify the displayed information', function() {
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.first()
|
||||
.click();
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.click();
|
||||
cy.get('[data-cy="about-modal"]')
|
||||
.as('aboutOverlay')
|
||||
.should('be.visible');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot('About modal - Should display modal');
|
||||
|
||||
//close modal
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
cy.get('@aboutOverlay').should('not.exist');
|
||||
});
|
||||
});*/
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
/*describe('Visual Regression - OHIF User Preferences', () => {
|
||||
context('Study List Page', function() {
|
||||
before(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Close User Preferences modal
|
||||
cy.closePreferences();
|
||||
});
|
||||
|
||||
it('checks displayed information on User Preferences modal', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
cy.get('@restoreBtn').scrollIntoView();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - Hotkeys tab initial state in StudyList page'
|
||||
);
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
});
|
||||
|
||||
it('checks translation by selecting Spanish language', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Language dropdown should be displayed
|
||||
cy.get('#language-select').should('be.visible');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - General tab initial state in StudyList page'
|
||||
);
|
||||
// Set language to Spanish and save
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Opciones')
|
||||
.click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - Spanish selected in StudyList page'
|
||||
);
|
||||
|
||||
// Close Options menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
});
|
||||
|
||||
context('Study Viewer Page', function() {
|
||||
before(() => {
|
||||
cy.openStudyInViewer('1.2.840.113619.2.5.1762583153.215519.978957063.78');
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.initCommonElementsAliases();
|
||||
cy.resetViewport();
|
||||
|
||||
cy.resetUserHotkeyPreferences();
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Close User Preferences modal
|
||||
cy.closePreferences();
|
||||
});
|
||||
|
||||
it('checks displayed information on User Preferences modal', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
cy.get('@restoreBtn').scrollIntoView();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - Hotkeys tab initial state in StudyViewer page'
|
||||
);
|
||||
cy.get('[data-cy="close-button"]').click(); //close User Preferences modal
|
||||
});
|
||||
|
||||
it('checks if W/L Preferences table is being displayed in the Window Level tab', function() {
|
||||
//Navigate to Window Level tab
|
||||
cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - Window Level Presets Tab'
|
||||
);
|
||||
});
|
||||
|
||||
it('checks translation by selecting Spanish language', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - General tab initial state in StudyViewer page'
|
||||
);
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Opciones')
|
||||
.click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - Spanish selected in StudyViewer page'
|
||||
);
|
||||
|
||||
// Close Options menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
|
||||
it('checks if user can restore to default the language selection and application will be in English', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
|
||||
// Go to general tab
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// Options menu should be in English
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Options')
|
||||
.click();
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'User Preferences Modal - English selected in StudyViewer page'
|
||||
);
|
||||
|
||||
// Close Options menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
|
||||
it('checks new hotkeys for "Next" and "Previous" Image on Viewport', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set new hotkey for 'Next Image Viewport' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Next Viewport',
|
||||
'{shift}{rightarrow}'
|
||||
);
|
||||
|
||||
// Set new hotkey for 'Previous Image Viewport' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Previous Viewport',
|
||||
'{shift}{leftarrow}'
|
||||
);
|
||||
|
||||
// Save new hotkeys
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// Set 3 viewports layout
|
||||
cy.setLayout(3, 1);
|
||||
cy.waitViewportImageLoading();
|
||||
|
||||
// Rotate Right and Invert colors on Viewport #1
|
||||
cy.get('body').type('RI');
|
||||
|
||||
//Move to Next Viewport
|
||||
cy.get('body').type('{shift}{rightarrow}');
|
||||
// Rotate Left and Invert colors on Viewport #2
|
||||
cy.get('body').type('LI');
|
||||
|
||||
//Move to Previous Viewport
|
||||
cy.get('body').type('{shift}{leftarrow}');
|
||||
// Reset viewport #1 with spacebar hotkey
|
||||
cy.get('body').type(' ');
|
||||
|
||||
// Visual comparison
|
||||
cy.percyCanvasSnapshot(
|
||||
'Viewport Navigation - 2nd viewport inverted and rotated'
|
||||
);
|
||||
// Set 1 viewport layout
|
||||
cy.setLayout(1, 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
@@ -0,0 +1,103 @@
|
||||
//We are keeping the hardcoded results values for the study list tests
|
||||
//this is intended to be running in a controled docker environment with test data.
|
||||
describe('OHIF Study List', function() {
|
||||
context('Desktop resolution', function() {
|
||||
beforeEach(function() {
|
||||
cy.openStudyList();
|
||||
|
||||
cy.viewport(1750, 720);
|
||||
cy.initStudyListAliasesOnDesktop();
|
||||
//Clear all text fields
|
||||
cy.get('@PatientName').clear();
|
||||
cy.get('@MRN').clear();
|
||||
cy.get('@AccessionNumber').clear();
|
||||
cy.get('@StudyDescription').clear();
|
||||
});
|
||||
|
||||
it('Displays several studies initially', function() {
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.greaterThan(1);
|
||||
expect($list).to.contain('Juno');
|
||||
expect($list).to.contain('832040');
|
||||
});
|
||||
});
|
||||
|
||||
it('searches Patient Name with exact string', function() {
|
||||
cy.get('@PatientName').type('Juno');
|
||||
//Wait result list to be displayed
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.eq(1);
|
||||
expect($list).to.contain('Juno');
|
||||
});
|
||||
});
|
||||
|
||||
it('searches MRN with exact string', function() {
|
||||
cy.get('@MRN').type('0000003');
|
||||
//Wait result list to be displayed
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.eq(1);
|
||||
expect($list).to.contain('0000003');
|
||||
});
|
||||
});
|
||||
|
||||
it('searches Accession with exact string', function() {
|
||||
cy.get('@AccessionNumber').type('321');
|
||||
//Wait result list to be displayed
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.eq(1);
|
||||
expect($list).to.contain('321');
|
||||
});
|
||||
});
|
||||
|
||||
it('searches Description with exact string', function() {
|
||||
cy.get('@StudyDescription').type('PETCT');
|
||||
//Wait result list to be displayed
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.eq(1);
|
||||
expect($list).to.contain('PETCT');
|
||||
});
|
||||
});
|
||||
|
||||
/* Todo: fix react select
|
||||
it('searches Modality with camel case', function() {
|
||||
cy.get('@modalities').type('Ct');
|
||||
// Wait result list to be displayed
|
||||
cy.waitStudyList();
|
||||
cy.get('@searchResult2').should($list => {
|
||||
expect($list.length).to.be.greaterThan(1);
|
||||
expect($list).to.contain('CT');
|
||||
});
|
||||
});
|
||||
|
||||
it('changes Rows per page and checks the study count', function() {
|
||||
//Show Rows per page options
|
||||
const pageRows = [25, 50, 100];
|
||||
|
||||
//Check all options of Rows
|
||||
pageRows.forEach(numRows => {
|
||||
cy.get('select').select(numRows.toString()); //Select Rows per page option
|
||||
//Wait result list to be displayed
|
||||
cy.waitStudyList().then(() => {
|
||||
//Compare the search result with the Study Count on the table header
|
||||
cy.get('@numStudies')
|
||||
.should(numStudies => {
|
||||
expect(parseInt(numStudies.text())).to.be.at.most(numRows); //less than or equals to
|
||||
})
|
||||
.then(numStudies => {
|
||||
//Compare to the number of Rows in the search result
|
||||
cy.get('@searchResult2').then($searchResult => {
|
||||
let countResults = $searchResult.length;
|
||||
expect(numStudies.text()).to.be.eq(countResults.toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,757 @@
|
||||
/*describe('OHIF User Preferences', () => {
|
||||
context('Study List Page', function() {
|
||||
before(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
});
|
||||
|
||||
it('checks displayed information on User Preferences modal', function() {
|
||||
cy.initPreferencesModalAliases();
|
||||
//Check Title
|
||||
cy.get('@preferencesModal').should('contain.text', 'User Preferences');
|
||||
//Check tabs
|
||||
cy.get('@userPreferencesHotkeysTab')
|
||||
.should('have.text', 'Hotkeys')
|
||||
.and('have.class', 'active');
|
||||
cy.get('@userPreferencesGeneralTab').should('have.text', 'General');
|
||||
cy.get('@userPreferencesWindowLevelTab').should(
|
||||
'have.text',
|
||||
'Window Level'
|
||||
);
|
||||
//Check buttons
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'Reset to Defaults');
|
||||
cy.get('@cancelBtn').should('have.text', 'Cancel');
|
||||
cy.get('@saveBtn').should('have.text', 'Save');
|
||||
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
});
|
||||
|
||||
it('checks translation by selecting Spanish language', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Language dropdown should be displayed
|
||||
cy.get('#language-select').should('be.visible');
|
||||
|
||||
// Set language to Spanish and save
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Header should be translated to Spanish
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'SOLO USO PARA INVESTIGACIÓN');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Opciones')
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'Acerca de');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferencias');
|
||||
|
||||
// Close Options menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
|
||||
it('checks if user can cancel the language selection and application will be in "English (USA)"', function() {
|
||||
// Set language to English and save
|
||||
cy.setLanguage('English (USA)');
|
||||
|
||||
// Set language to Spanish and cancel
|
||||
cy.setLanguage('Spanish', false);
|
||||
|
||||
// Header should be kept in "English (USA)"
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'INVESTIGATIONAL USE ONLY');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Options')
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'About');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferences');
|
||||
|
||||
// Close Options menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
|
||||
it('checks if user can restore to default the language selection and application will be in "English (USA)"', function() {
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
//Open Preferences again
|
||||
cy.openPreferences();
|
||||
|
||||
// Go to general tab
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon').click({ force: true });
|
||||
}
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
// Header should be in "English (USA)"
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'INVESTIGATIONAL USE ONLY');
|
||||
|
||||
// Options menu should be in "English (USA)"
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Options')
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'About');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferences');
|
||||
|
||||
// Close options Menu
|
||||
cy.get('[data-cy="options-menu"]').click();
|
||||
});
|
||||
|
||||
it('checks if W/L Preferences table is being displayed in the Window Level tab', function() {
|
||||
//Navigate to Window Level tab
|
||||
cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
|
||||
//Check table header
|
||||
cy.get('.wlRow.header')
|
||||
.should('contains.text', 'Preset')
|
||||
.and('contains.text', 'Description')
|
||||
.and('contains.text', 'Window')
|
||||
.and('contains.text', 'Level');
|
||||
|
||||
//Check table has more than 1 row (more than header)
|
||||
cy.get('.wlRow')
|
||||
.its('length')
|
||||
.should('be.greaterThan', 1);
|
||||
});
|
||||
|
||||
it('checks if Preferences set in Study List Page will be consistent on Viewer Page', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set new hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{shift}Q');
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon').click({ force: true });
|
||||
}
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
// Open User Preferences modal again
|
||||
cy.openPreferences();
|
||||
|
||||
// Go to General tab
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Go to Study Viewer page
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCommonElementsAliases();
|
||||
|
||||
// Check if application is in Spanish
|
||||
// Header should be translated to Spanish
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'SOLO USO PARA INVESTIGACIÓN');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Opciones')
|
||||
.click();
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'Acerca de');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferencias');
|
||||
|
||||
// Check if new hotkey is working on viewport
|
||||
cy.get('body').type('{shift}Q', {
|
||||
release: false,
|
||||
});
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
});
|
||||
});
|
||||
|
||||
context('Study Viewer Page', function() {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.initCommonElementsAliases();
|
||||
cy.resetViewport();
|
||||
|
||||
cy.resetUserHotkeyPreferences();
|
||||
cy.resetUserGeneralPreferences();
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Close User Preferences Modal (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.OHIFModal__header').length > 0) {
|
||||
cy.get('[data-cy="close-button"]').click({ force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('checks displayed information on User Preferences modal', function() {
|
||||
cy.get('@preferencesModal').should('contain.text', 'User Preferences');
|
||||
cy.get('@userPreferencesHotkeysTab')
|
||||
.should('have.text', 'Hotkeys')
|
||||
.and('have.class', 'active');
|
||||
cy.get('@userPreferencesGeneralTab').should('have.text', 'General');
|
||||
cy.get('@userPreferencesWindowLevelTab').should(
|
||||
'have.text',
|
||||
'Window Level'
|
||||
);
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'Reset to Defaults');
|
||||
cy.get('@cancelBtn').should('have.text', 'Cancel');
|
||||
cy.get('@saveBtn').should('have.text', 'Save');
|
||||
});
|
||||
|
||||
it('checks translation by selecting Spanish language', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Language dropdown should be displayed
|
||||
cy.get('#language-select').should('be.visible');
|
||||
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Header should be translated to Spanish
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'SOLO USO PARA INVESTIGACIÓN');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Opciones')
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'Acerca de');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferencias');
|
||||
});
|
||||
|
||||
it('checks if user can cancel the language selection and application will be in "English (USA)"', function() {
|
||||
// Set language to English and save
|
||||
cy.setLanguage('English (USA)');
|
||||
|
||||
// Set language to Spanish and cancel
|
||||
cy.setLanguage('Spanish', false);
|
||||
|
||||
// Header should be kept in "English (USA)"
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'INVESTIGATIONAL USE ONLY');
|
||||
|
||||
// Options menu should be translated
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Options')
|
||||
.click();
|
||||
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'About');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferences');
|
||||
});
|
||||
|
||||
it('checks if user can restore to default the language selection and application will be in "English (USA)', function() {
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Language dropdown should be displayed
|
||||
cy.get('#language-select').should('be.visible');
|
||||
|
||||
// Set language to Spanish
|
||||
cy.setLanguage('Spanish');
|
||||
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
|
||||
// Go to general tab
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// click on restore button
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// Header should be in "English (USA)""
|
||||
cy.get('.research-use')
|
||||
.scrollIntoView()
|
||||
.should('have.text', 'INVESTIGATIONAL USE ONLY');
|
||||
|
||||
// Options menu should be in "English (USA)"
|
||||
cy.get('[data-cy="options-menu"]')
|
||||
.should('have.text', 'Options')
|
||||
.click();
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.first()
|
||||
.should('contain.text', 'About');
|
||||
cy.get('[data-cy="dd-item-menu"]')
|
||||
.last()
|
||||
.should('contain.text', 'Preferences');
|
||||
});
|
||||
|
||||
it('checks new hotkeys for "Rotate Right" and "Rotate Left"', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set new hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Rotate Right',
|
||||
'{shift}{rightarrow}'
|
||||
);
|
||||
// Set new hotkey for 'Rotate Left' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Rotate Left',
|
||||
'{shift}{leftarrow}'
|
||||
);
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon').click({ force: true });
|
||||
}
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
//Rotate Right with new Hotkey
|
||||
cy.get('body').type('{shift}{rightarrow}');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
|
||||
//Rotate Left with new Hotkey
|
||||
cy.get('body').type('{shift}{leftarrow}');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
});
|
||||
|
||||
it('checks new hotkeys for "Next" and "Previous" Image on Viewport', function() {
|
||||
// Update hotkeys for 'Next/Previous Viewport'
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Next Viewport',
|
||||
'{shift}{rightarrow}'
|
||||
);
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Previous Viewport',
|
||||
'{shift}{leftarrow}'
|
||||
);
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon').click({ force: true });
|
||||
}
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
// Set 3 viewports layout
|
||||
cy.setLayout(3, 1);
|
||||
cy.waitViewportImageLoading();
|
||||
|
||||
// Reset, Rotate Right and Invert colors on Viewport #1
|
||||
cy.get('body').type(' ');
|
||||
cy.get('body').type('r');
|
||||
cy.get('body').type('i');
|
||||
|
||||
// Shift active viewport to next
|
||||
// Reset, Rotate Left and Invert colors on Viewport #2
|
||||
cy.get('body').type('{shift}{rightarrow}');
|
||||
cy.get('body').type(' ');
|
||||
cy.get('body').type('l');
|
||||
cy.get('body').type('i');
|
||||
|
||||
// Verify 1st viewport was rotated
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'R');
|
||||
|
||||
// Verify 2nd viewport was rotated
|
||||
cy.get(
|
||||
':nth-child(2) > .viewport-wrapper > .viewport-element > .ViewportOrientationMarkers.noselect > .top-mid.orientation-marker'
|
||||
).as('viewport2InfoMidTop');
|
||||
cy.get('@viewport2InfoMidTop').should('contains.text', 'P');
|
||||
|
||||
//Move to Previous Viewport
|
||||
cy.get('body').type('{shift}{leftarrow}');
|
||||
// Reset viewport #1 with spacebar hotkey
|
||||
cy.get('body').type(' ');
|
||||
cy.get('@viewportInfoMidTop').should('contains.text', 'A');
|
||||
|
||||
// Set 1 viewport layout
|
||||
cy.setLayout(1, 1);
|
||||
});
|
||||
|
||||
it('checks error message when duplicated hotkeys are inserted', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set duplicated hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{i}');
|
||||
|
||||
// Check error message
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains('Rotate Right') // label we're looking for
|
||||
.parent()
|
||||
.find('.preferencesInputErrorMessage')
|
||||
.as('errorMsg')
|
||||
.should('have.text', '"Invert" is already using the "i" shortcut.');
|
||||
});
|
||||
});
|
||||
|
||||
it('checks error message when invalid hotkey is inserted', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set invalid hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{ctrl}Z');
|
||||
|
||||
// Check error message
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains('Rotate Right') // label we're looking for
|
||||
.parent()
|
||||
.find('.preferencesInputErrorMessage')
|
||||
.as('errorMsg')
|
||||
.should('have.text', '"ctrl+z" shortcut combination is not allowed');
|
||||
});
|
||||
});
|
||||
|
||||
it('checks error message when only modifier keys are inserted', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set invalid modifier key: ctrl
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Zoom Out', '{ctrl}');
|
||||
// Check error message
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains('Zoom Out') // label we're looking for
|
||||
.parent()
|
||||
.find('.preferencesInputErrorMessage')
|
||||
.as('errorMsg')
|
||||
.should(
|
||||
'have.text',
|
||||
"It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut"
|
||||
);
|
||||
});
|
||||
|
||||
// Set invalid modifier key: shift
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Zoom Out', '{shift}');
|
||||
// Check error message
|
||||
cy.get('@errorMsg').should(
|
||||
'have.text',
|
||||
"It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut"
|
||||
);
|
||||
|
||||
// Set invalid modifier key: alt
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal('Zoom Out', '{alt}');
|
||||
// Check error message
|
||||
cy.get('@errorMsg').should(
|
||||
'have.text',
|
||||
"It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut"
|
||||
);
|
||||
});
|
||||
|
||||
it('checks if user can cancel changes made on User Preferences Hotkeys tab', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set new hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Rotate Right',
|
||||
'{ctrl}{shift}S'
|
||||
);
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon').click({ force: true });
|
||||
}
|
||||
//Cancel hotkeys
|
||||
cy.get('@cancelBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
});
|
||||
|
||||
// Open User Preferences modal again
|
||||
cy.openPreferences();
|
||||
|
||||
//Check that hotkey for 'Rotate Right' function was not changed
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains('Rotate Right') // label we're looking for
|
||||
.parent()
|
||||
.find('input')
|
||||
.should('have.value', 'r');
|
||||
});
|
||||
});
|
||||
|
||||
it('checks if user can reset to default values on User Preferences Hotkeys tab', function() {
|
||||
// Go go hotkeys tab
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab');
|
||||
|
||||
// Set new hotkey for 'Rotate Right' function
|
||||
cy.setNewHotkeyShortcutOnUserPreferencesModal(
|
||||
'Rotate Right',
|
||||
'{ctrl}{shift}S'
|
||||
);
|
||||
|
||||
// click on save button
|
||||
cy.get('@saveBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
// Open User Preferences modal again
|
||||
cy.openPreferences();
|
||||
|
||||
//Restore Default hotkeys
|
||||
cy.get('@restoreBtn')
|
||||
.scrollIntoView()
|
||||
.click();
|
||||
|
||||
//Check that hotkey for 'Rotate Right' function was not changed
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains('Rotate Right') // label we're looking for
|
||||
.parent()
|
||||
.find('input')
|
||||
.should('have.value', 'r');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('W/L Preset Preferences', function() {
|
||||
before(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.2.840.113619.2.5.1762583153.215519.978957063.78'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.initCommonElementsAliases();
|
||||
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
// Navigate to Window Level tab
|
||||
cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
});
|
||||
|
||||
it('checks if W/L Preferences table is being displayed in the Window Level tab', function() {
|
||||
//Check table header
|
||||
cy.get('.wlRow.header')
|
||||
.should('contains.text', 'Preset')
|
||||
.and('contains.text', 'Description')
|
||||
.and('contains.text', 'Window')
|
||||
.and('contains.text', 'Level');
|
||||
|
||||
//Check table has more than 1 row (more than header)
|
||||
cy.get('.wlRow')
|
||||
.its('length')
|
||||
.should('be.greaterThan', 1);
|
||||
});
|
||||
|
||||
// //TODO: Test blocked by issue #1551: https://github.com/OHIF/Viewers/issues/1551
|
||||
// it('checks if user can add a new W/L preset', function() {
|
||||
// let description = ':nth-child(8) > .description > .preferencesInput';
|
||||
// let window = ':nth-child(8) > .window > .preferencesInput';
|
||||
// let level = ':nth-child(8) > .level > .preferencesInput';
|
||||
// let new_window_value = 150;
|
||||
// let new_level_value = -600;
|
||||
// // Check existing preset values
|
||||
// cy.get(description).should('have.value', '');
|
||||
// cy.get(window).should('have.value', '');
|
||||
// cy.get(level).should('have.value', '');
|
||||
|
||||
// // Set new preset value
|
||||
// cy.setWindowLevelPreset(
|
||||
// 7,
|
||||
// 'New Description',
|
||||
// new_window_value,
|
||||
// new_level_value
|
||||
// );
|
||||
// cy.get('@saveBtn').click();
|
||||
|
||||
// // Open User Preferences modal
|
||||
// cy.openPreferences();
|
||||
// // Navigate to Window Level tab
|
||||
// cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
|
||||
// // Check recently added preset values
|
||||
// cy.get(description).should('have.value', 'New Description');
|
||||
// cy.get(window).should('have.value', new_window_value);
|
||||
// cy.get(level).should('have.value', new_level_value);
|
||||
|
||||
// // Close User Preferences modal
|
||||
// cy.get('[data-cy="close-button"]').click();
|
||||
|
||||
// // Check if new hotkey preset is working on viewport
|
||||
// cy.get('body').type('8');
|
||||
// cy.get('@viewportInfoBottomRight').should(
|
||||
// 'contains.text',
|
||||
// 'W: ' + new_window_value + ' L: ' + new_level_value
|
||||
// );
|
||||
// });
|
||||
|
||||
it('checks if user can remove an existing W/L preset', function() {
|
||||
let description = ':nth-child(3) > .description > .preferencesInput';
|
||||
let window = ':nth-child(3) > .window > .preferencesInput';
|
||||
let level = ':nth-child(3) > .level > .preferencesInput';
|
||||
// Check existing preset values
|
||||
cy.get(description)
|
||||
.should('not.have.value', '')
|
||||
.clear();
|
||||
cy.get(window)
|
||||
.should('not.have.value', '')
|
||||
.clear();
|
||||
cy.get(level)
|
||||
.should('not.have.value', '')
|
||||
.clear();
|
||||
|
||||
// Save changes
|
||||
cy.get('@saveBtn').click();
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
// Navigate to Window Level tab
|
||||
cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
|
||||
// Check recently added preset values
|
||||
cy.get(description).should('have.value', '');
|
||||
cy.get(window).should('have.value', '');
|
||||
cy.get(level).should('have.value', '');
|
||||
// Close User Preferences modal
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
});
|
||||
|
||||
// //TODO: Test blocked by issue #1551: https://github.com/OHIF/Viewers/issues/1551
|
||||
// it('checks if user can edit an existing W/L preset', function() {
|
||||
// let description = ':nth-child(2) > .description > .preferencesInput';
|
||||
// let window = ':nth-child(2) > .window > .preferencesInput';
|
||||
// let level = ':nth-child(2) > .level > .preferencesInput';
|
||||
// // Check existing preset values
|
||||
// cy.get(description).should('have.value', 'Soft tissue');
|
||||
// cy.get(window).should('have.value', '550');
|
||||
// cy.get(level).should('have.value', '40');
|
||||
|
||||
// // Set new preset value
|
||||
// cy.setWindowLevelPreset(1, 'Soft tissue New Description', 1220, 333);
|
||||
// cy.get('@saveBtn').click();
|
||||
|
||||
// // Open User Preferences modal
|
||||
// cy.openPreferences();
|
||||
// // Navigate to Window Level tab
|
||||
// cy.selectPreferencesTab('@userPreferencesWindowLevelTab');
|
||||
|
||||
// // Check recently added preset values
|
||||
// cy.get(description).should('have.value', 'Soft tissue New Description');
|
||||
// cy.get(window).should('have.value', '1220');
|
||||
// cy.get(level).should('have.value', '333');
|
||||
// });
|
||||
|
||||
it('checks if user can change the W/L by triggering different hotkeys with W/L presets', function() {
|
||||
// Close User Preferences modal
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
// Check if hotkey preset is working on viewport
|
||||
cy.get('body').type('3');
|
||||
cy.get('@viewportInfoBottomRight').should(
|
||||
'contains.text',
|
||||
'W: 150 L: 90'
|
||||
);
|
||||
|
||||
// Check if hotkey preset is working on viewport
|
||||
cy.get('body').type('4');
|
||||
cy.get('@viewportInfoBottomRight').should(
|
||||
'contains.text',
|
||||
'W: 2500 L: 480'
|
||||
);
|
||||
});
|
||||
|
||||
it('checks if user can change the W/L by triggering different hotkeys with W/L presets on multiple viewports', function() {
|
||||
// Close User Preferences modal
|
||||
cy.get('[data-cy="close-button"]').click();
|
||||
|
||||
// Set 3 viewports layout
|
||||
cy.setLayout(3, 1);
|
||||
cy.waitViewportImageLoading();
|
||||
|
||||
// Check if hotkey preset is working on viewport
|
||||
cy.get('body').type('3');
|
||||
cy.get('@viewportInfoBottomRight').should(
|
||||
'contains.text',
|
||||
'W: 150 L: 90'
|
||||
);
|
||||
|
||||
// Overlay information from 2nd viewport
|
||||
let second_viewport_overlay =
|
||||
'div:nth-child(2) > div > div.viewport-element > div.ViewportOverlay > div.bottom-right.overlay-element > div';
|
||||
|
||||
// Shift active viewport to Viewport #2
|
||||
cy.get('body').type('{rightarrow}');
|
||||
|
||||
// Check if hotkey preset is working on viewport #2
|
||||
cy.get('body').type('4');
|
||||
cy.get(second_viewport_overlay).should('contains.text', 'W: 2500 L: 480');
|
||||
|
||||
// Set 1 viewport layout
|
||||
cy.setLayout(1, 1);
|
||||
});
|
||||
});
|
||||
});*/
|
||||
@@ -0,0 +1,141 @@
|
||||
describe('OHIF MPR', () => {
|
||||
beforeEach(() => {
|
||||
cy.checkStudyRouteInViewer(
|
||||
'1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1'
|
||||
);
|
||||
cy.expectMinimumThumbnails(3);
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.initCommonElementsAliases();
|
||||
});
|
||||
|
||||
it('should not go MPR for non reconstructible displaySets', () => {
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
cy.get('.cornerstone-canvas').should('have.length', 1);
|
||||
});
|
||||
|
||||
it('should go MPR for reconstructible displaySets and come back', () => {
|
||||
cy.wait(250);
|
||||
cy.get(':nth-child(3) > [data-cy="study-browser-thumbnail"]').dblclick();
|
||||
cy.wait(250);
|
||||
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
|
||||
cy.get('.cornerstone-canvas').should('have.length', 3);
|
||||
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
|
||||
cy.get('.cornerstone-canvas').should('have.length', 1);
|
||||
});
|
||||
|
||||
it('should render correctly the MPR', () => {
|
||||
cy.wait(250);
|
||||
|
||||
cy.get(':nth-child(3) > [data-cy="study-browser-thumbnail"]').dblclick();
|
||||
cy.wait(250);
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
|
||||
cy.get('[data-cy="thumbnail-viewport-labels"]').should('have.length', 3);
|
||||
|
||||
cy.get('.cornerstone-canvas').should('have.length', 3);
|
||||
|
||||
cy.get('[data-cy="thumbnail-viewport-labels"]')
|
||||
.eq(2)
|
||||
.find('div')
|
||||
.should('have.length', 3)
|
||||
.each(($div, index) => {
|
||||
const text = $div.text();
|
||||
switch (index) {
|
||||
case 0:
|
||||
expect(text).to.equal('A');
|
||||
break;
|
||||
case 1:
|
||||
expect(text).to.equal('B');
|
||||
break;
|
||||
case 2:
|
||||
expect(text).to.equal('C');
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected div found with text: ${text}`);
|
||||
}
|
||||
});
|
||||
|
||||
// check cornerstone to see if each has images
|
||||
// we can later do visual testing to match the images with a baseline
|
||||
cy.window()
|
||||
.its('cornerstone')
|
||||
.then(cornerstone => {
|
||||
const viewports = cornerstone.getRenderingEngines()[0].getViewports();
|
||||
|
||||
const imageData1 = viewports[0].getImageData();
|
||||
const imageData2 = viewports[1].getImageData();
|
||||
const imageData3 = viewports[2].getImageData();
|
||||
|
||||
// for some reason map doesn't work here
|
||||
cy.wrap(imageData1).should('not.be', undefined);
|
||||
cy.wrap(imageData2).should('not.be', undefined);
|
||||
cy.wrap(imageData3).should('not.be', undefined);
|
||||
|
||||
cy.wrap(imageData1.dimensions).should(
|
||||
'deep.equal',
|
||||
imageData2.dimensions
|
||||
);
|
||||
|
||||
cy.wrap(imageData1.origin).should('deep.equal', imageData2.origin);
|
||||
});
|
||||
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
|
||||
cy.get('.cornerstone-canvas').should('have.length', 1);
|
||||
|
||||
// should not have any div under it
|
||||
cy.get('[data-cy="thumbnail-viewport-labels"]')
|
||||
.eq(2)
|
||||
.find('div')
|
||||
.should('have.length', 0);
|
||||
});
|
||||
|
||||
it('should correctly render Crosshairs for MPR', () => {
|
||||
cy.wait(250);
|
||||
|
||||
cy.get('[data-cy="Crosshairs"]').click();
|
||||
cy.window()
|
||||
.its('cornerstoneTools')
|
||||
.then(cornerstoneTools => {
|
||||
const state = cornerstoneTools.annotation.state.getAnnotationManager();
|
||||
|
||||
const fORMap = state.annotations;
|
||||
// it should not have crosshairs yet
|
||||
expect(Object.keys(fORMap)).to.have.length(0);
|
||||
});
|
||||
|
||||
cy.get(':nth-child(3) > [data-cy="study-browser-thumbnail"]').dblclick();
|
||||
cy.get('[data-cy="MPR"]').click();
|
||||
cy.get('[data-cy="Crosshairs"]').click();
|
||||
|
||||
cy.wait(250);
|
||||
|
||||
// check cornerstone to see if each has crosshairs
|
||||
// we can later do visual testing to match the images with a baseline
|
||||
cy.window()
|
||||
.its('cornerstoneTools')
|
||||
.then(cornerstoneTools => {
|
||||
const state = cornerstoneTools.annotation.state.getAnnotationManager();
|
||||
|
||||
const fORMap = state.annotations;
|
||||
const fOR = Object.keys(fORMap)[0];
|
||||
const fORAnnotation = fORMap[fOR];
|
||||
|
||||
// it should have crosshairs as the only key
|
||||
expect(Object.keys(fORAnnotation)).to.have.length(1);
|
||||
|
||||
const crosshairs = fORAnnotation.Crosshairs;
|
||||
|
||||
// it should have three
|
||||
expect(crosshairs).to.have.length(3);
|
||||
|
||||
expect(crosshairs[0].data.handles.toolCenter).to.deep.equal(
|
||||
crosshairs[1].data.handles.toolCenter
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,78 @@
|
||||
const dataTransfer = new DataTransfer();
|
||||
|
||||
export const DragSimulator = {
|
||||
MAX_TRIES: 1,
|
||||
DELAY_INTERVAL_MS: 10,
|
||||
counter: 0,
|
||||
rectsEqual(r1, r2) {
|
||||
return (
|
||||
r1.top === r2.top &&
|
||||
r1.right === r2.right &&
|
||||
r1.bottom === r2.bottom &&
|
||||
r1.left === r2.left
|
||||
);
|
||||
},
|
||||
get dropped() {
|
||||
const currentSourcePosition = this.source.getBoundingClientRect();
|
||||
return !this.rectsEqual(
|
||||
this.initialSourcePosition,
|
||||
currentSourcePosition
|
||||
);
|
||||
},
|
||||
get hasTriesLeft() {
|
||||
return this.counter < this.MAX_TRIES;
|
||||
},
|
||||
dragstart() {
|
||||
cy.log('**DRAG START**');
|
||||
cy.wrap(this.source)
|
||||
.trigger('mousedown', { which: 1, button: 0 })
|
||||
.trigger('dragstart', { dataTransfer })
|
||||
.trigger('drag', {});
|
||||
},
|
||||
drop() {
|
||||
cy.log('**DROP**');
|
||||
return cy
|
||||
.wrap(this.target)
|
||||
.trigger('mousemove', 'center')
|
||||
.trigger('dragover', { dataTransfer, force: true })
|
||||
.trigger('drop', { dataTransfer, force: true })
|
||||
.trigger('dragend', { dataTransfer })
|
||||
.trigger('mouseup', { which: 1, button: 0 });
|
||||
},
|
||||
dragover() {
|
||||
cy.log('**DRAGOVER**');
|
||||
if (!this.dropped && this.hasTriesLeft) {
|
||||
this.counter += 1;
|
||||
return cy
|
||||
.wrap(this.target)
|
||||
.trigger('mousemove', 'center')
|
||||
.trigger('dragover', {
|
||||
dataTransfer,
|
||||
position: this.position,
|
||||
})
|
||||
.wait(this.DELAY_INTERVAL_MS)
|
||||
.then(() => this.dragover());
|
||||
}
|
||||
return this.drop().then(() => true);
|
||||
},
|
||||
init(source, target, position) {
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
this.position = position;
|
||||
this.counter = 0;
|
||||
|
||||
this.dragstart();
|
||||
|
||||
return cy.wait(this.DELAY_INTERVAL_MS).then(() => {
|
||||
this.initialSourcePosition = this.source.getBoundingClientRect();
|
||||
return this.dragover();
|
||||
});
|
||||
},
|
||||
simulate(sourceWrapper, targetSelector, position = 'center') {
|
||||
return cy
|
||||
.get(targetSelector)
|
||||
.then(targetWrapper =>
|
||||
this.init(sourceWrapper.get(0), targetWrapper.get(0), position)
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
//Creating aliases for Cornerstone tools buttons
|
||||
export function initCornerstoneToolsAliases() {
|
||||
cy.get('[data-cy="StackScroll"]').as('stackScrollBtn');
|
||||
cy.get('[data-cy="Zoom"]').as('zoomBtn');
|
||||
cy.get('[data-cy="WindowLevel-split-button-primary"]').as('wwwcBtnPrimary');
|
||||
cy.get('[data-cy="WindowLevel-split-button-secondary"]').as(
|
||||
'wwwcBtnSecondary'
|
||||
);
|
||||
cy.get('[data-cy="Pan"]').as('panBtn');
|
||||
cy.get('[data-cy="MeasurementTools-split-button-primary"]').as(
|
||||
'measurementToolsBtnPrimary'
|
||||
);
|
||||
cy.get('[data-cy="MeasurementTools-split-button-secondary"]').as(
|
||||
'measurementToolsBtnSecondary'
|
||||
);
|
||||
// cy.get('[data-cy="Angle"]').as('angleBtn');
|
||||
cy.get('[data-cy="MoreTools-split-button-primary"]').as('moreBtnPrimary');
|
||||
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
|
||||
export function initCommonElementsAliases() {
|
||||
cy.get('[data-cy="trackedMeasurements-btn"]').as('measurementsBtn');
|
||||
cy.get('.cornerstone-viewport-element').as('viewport');
|
||||
cy.get('[data-cy="seriesList-btn"]').as('seriesBtn');
|
||||
cy.get('[data-cy="side-panel-header-right"]').as('RightCollapseBtn');
|
||||
cy.get('[data-cy="side-panel-header-left"]').as('LeftCollapseBtn');
|
||||
|
||||
// click on the measurements button
|
||||
cy.get('[data-cy="trackedMeasurements-btn"]').click();
|
||||
|
||||
// TODO: Panels are not in DOM when closed, move this somewhere else
|
||||
cy.get('[data-cy="trackedMeasurements-panel"]').as('measurementsPanel');
|
||||
cy.get('[data-cy="studyBrowser-panel"]').as('seriesPanel');
|
||||
cy.get('[data-cy="viewport-overlay-top-right"]').as('viewportInfoTopRight');
|
||||
cy.get('[data-cy="viewport-overlay-top-left"]').as('viewportInfoTopLeft');
|
||||
cy.get('[data-cy="viewport-overlay-bottom-right"]').as(
|
||||
'viewportInfoBottomRight'
|
||||
);
|
||||
cy.get('[data-cy="viewport-overlay-bottom-left"]').as(
|
||||
'viewportInfoBottomLeft'
|
||||
);
|
||||
|
||||
cy.get('.left-mid.orientation-marker').as('viewportInfoMidLeft');
|
||||
cy.get('.top-mid.orientation-marker').as('viewportInfoMidTop');
|
||||
}
|
||||
|
||||
//Creating aliases for Routes
|
||||
export function initRouteAliases() {
|
||||
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
|
||||
export function initStudyListAliasesOnDesktop() {
|
||||
cy.get('[data-cy="num-studies"]').as('numStudies');
|
||||
cy.get('[data-cy="input-patientName"]').as('PatientName');
|
||||
cy.get('[data-cy="input-mrn"]').as('MRN');
|
||||
cy.get('[data-cy="input-accession"]').as('AccessionNumber');
|
||||
cy.get('[data-cy="input-description"]').as('StudyDescription');
|
||||
cy.get('[data-cy="study-list-results"]').as('searchResult');
|
||||
cy.get('[data-cy="study-list-results"] > tr').as('searchResult2');
|
||||
|
||||
// We can't use data attributes (e.g. data--cy) for these since
|
||||
// they are using third party libraires (i.e. react-dates, react-select)
|
||||
cy.get('#date-range-studyDate-start-date').as('studyListStartDate');
|
||||
cy.get('#date-range-studyDate-end-date').as('studyListEndDate');
|
||||
cy.get('#input-modalities').as('modalities');
|
||||
}
|
||||
|
||||
//Creating aliases for User Preferences modal
|
||||
export function initPreferencesModalAliases() {
|
||||
cy.get('.OHIFModal').as('preferencesModal');
|
||||
cy.get('[data-cy="hotkeys"]').as('userPreferencesHotkeysTab');
|
||||
cy.get('[data-cy="general"]').as('userPreferencesGeneralTab');
|
||||
cy.get('[data-cy="window-level"]').as('userPreferencesWindowLevelTab');
|
||||
initPreferencesModalFooterBtnAliases();
|
||||
}
|
||||
|
||||
//Creating aliases for User Preferences modal
|
||||
export function initPreferencesModalFooterBtnAliases() {
|
||||
cy.get('.active [data-cy="reset-default-btn"]').as('restoreBtn');
|
||||
cy.get('.active [data-cy="cancel-btn"]').as('cancelBtn');
|
||||
cy.get('.active [data-cy="save-btn"]').as('saveBtn');
|
||||
}
|
||||
@@ -0,0 +1,647 @@
|
||||
import '@percy/cypress';
|
||||
import 'cypress-file-upload';
|
||||
import { DragSimulator } from './DragSimulator.js';
|
||||
import {
|
||||
initCornerstoneToolsAliases,
|
||||
initCommonElementsAliases,
|
||||
initRouteAliases,
|
||||
initStudyListAliasesOnDesktop,
|
||||
initStudyListAliasesOnTablet,
|
||||
initPreferencesModalAliases,
|
||||
initPreferencesModalFooterBtnAliases,
|
||||
} from './aliases.js';
|
||||
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add("login", (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
|
||||
/**
|
||||
* Command to search for a patient name and open his/her study.
|
||||
*
|
||||
* @param {string} PatientName - Patient name that we would like to search for
|
||||
*/
|
||||
Cypress.Commands.add('openStudy', PatientName => {
|
||||
cy.openStudyList();
|
||||
cy.get('#filter-patientNameOrId').type(PatientName);
|
||||
// cy.get('@getStudies').then(() => {
|
||||
cy.wait(1000);
|
||||
|
||||
cy.get('[data-cy="study-list-results"]', { timeout: 5000 })
|
||||
.contains(PatientName)
|
||||
.first()
|
||||
.click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add(
|
||||
'checkStudyRouteInViewer',
|
||||
(StudyInstanceUID, otherParams = '') => {
|
||||
cy.location('pathname').then($url => {
|
||||
cy.log($url);
|
||||
if (
|
||||
$url == 'blank' ||
|
||||
!$url.includes(`/basic-test/${StudyInstanceUID}${otherParams}`)
|
||||
) {
|
||||
cy.openStudyInViewer(StudyInstanceUID, otherParams);
|
||||
cy.waitDicomImage();
|
||||
cy.wait(2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Cypress.Commands.add(
|
||||
'openStudyInViewer',
|
||||
(StudyInstanceUID, otherParams = '') => {
|
||||
cy.visit(`/basic-test?StudyInstanceUIDs=${StudyInstanceUID}${otherParams}`);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Command to search for a Modality and open the study.
|
||||
*
|
||||
* @param {string} Modality - Modality type that we would like to search for
|
||||
*/
|
||||
Cypress.Commands.add('openStudyModality', Modality => {
|
||||
cy.initRouteAliases();
|
||||
cy.visit('/');
|
||||
|
||||
cy.get('#filter-accessionOrModalityOrDescription')
|
||||
.type(Modality)
|
||||
.wait(2000);
|
||||
|
||||
cy.get('[data-cy="study-list-results"]')
|
||||
.contains(Modality)
|
||||
.first()
|
||||
.click();
|
||||
});
|
||||
|
||||
/**
|
||||
* Command to wait and check if a new page was loaded
|
||||
*
|
||||
* @param {string} url - part of the expected url. Default value is /basic-test
|
||||
*/
|
||||
Cypress.Commands.add('isPageLoaded', (url = '/basic-test') => {
|
||||
return cy.location('pathname', { timeout: 60000 }).should('include', url);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openStudyList', () => {
|
||||
cy.initRouteAliases();
|
||||
cy.visit('/');
|
||||
|
||||
// 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', () => {
|
||||
cy.get('@searchResult').should($list => {
|
||||
expect($list).to.not.have.class('no-hover');
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('waitViewportImageLoading', () => {
|
||||
// Wait for finish loading
|
||||
cy.get('[data-cy="viewprt-grid"]', { timeout: 30000 }).should($grid => {
|
||||
expect($grid).not.to.contain.text('Load');
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Command to perform a drag and drop action. Before using this command, we must get the element that should be dragged first.
|
||||
* Example of usage: cy.get(element-to-be-dragged).drag(dropzone-element)
|
||||
*
|
||||
* @param {*} element - Selector for element that we want to use as dropzone
|
||||
*/
|
||||
Cypress.Commands.add('drag', { prevSubject: 'element' }, (...args) =>
|
||||
DragSimulator.simulate(...args)
|
||||
);
|
||||
|
||||
/**
|
||||
* Command to perform two clicks into two different positions. Each position must be [x, y].
|
||||
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
|
||||
*
|
||||
* @param {*} viewport - Selector for viewport we would like to interact with
|
||||
* @param {number[]} firstClick - Click position [x, y]
|
||||
* @param {number[]} secondClick - Click position [x, y]
|
||||
*/
|
||||
Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
|
||||
cy.get(viewport).then($viewport => {
|
||||
const [x1, y1] = firstClick;
|
||||
const [x2, y2] = secondClick;
|
||||
|
||||
// TODO: Added a wait which appears necessary in Cornerstone Tools >4?
|
||||
cy.wrap($viewport)
|
||||
.click(x1, y1)
|
||||
.wait(100)
|
||||
.trigger('mousemove', { clientX: x2, clientY: y2 })
|
||||
.click(x2, y2)
|
||||
.wait(100);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Command to perform three clicks into three different positions. Each position must be [x, y].
|
||||
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
|
||||
*
|
||||
* @param {*} viewport - Selector for viewport we would like to interact with
|
||||
* @param {number[]} firstClick - Click position [x, y]
|
||||
* @param {number[]} secondClick - Click position [x, y]
|
||||
* @param {number[]} thirdClick - Click position [x, y]
|
||||
*/
|
||||
Cypress.Commands.add(
|
||||
'addAngle',
|
||||
(viewport, firstClick, secondClick, thirdClick) => {
|
||||
cy.get(viewport).then($viewport => {
|
||||
const [x1, y1] = firstClick;
|
||||
const [x2, y2] = secondClick;
|
||||
const [x3, y3] = thirdClick;
|
||||
|
||||
cy.wrap($viewport)
|
||||
.click(x1, y1, { force: true })
|
||||
.trigger('mousemove', { clientX: x2, clientY: y2 })
|
||||
.click(x2, y2, { force: true })
|
||||
.trigger('mousemove', { clientX: x3, clientY: y3 })
|
||||
.click(x3, y3, { force: true });
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Cypress.Commands.add('expectMinimumThumbnails', (seriesToWait = 1) => {
|
||||
cy.get('[data-cy="study-browser-thumbnail"]', { timeout: 50000 }).should(
|
||||
$itemList => {
|
||||
expect($itemList.length >= seriesToWait).to.be.true;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
//Command to wait DICOM image to load into the viewport
|
||||
Cypress.Commands.add('waitDicomImage', (timeout = 50000) => {
|
||||
const loaded = cy.isPageLoaded();
|
||||
|
||||
if (loaded) {
|
||||
cy.window()
|
||||
.its('cornerstone')
|
||||
.then({ timeout }, $cornerstone => {
|
||||
return new Cypress.Promise(resolve => {
|
||||
const onEvent = renderedEvt => {
|
||||
const element = renderedEvt.detail.element;
|
||||
|
||||
element.removeEventListener(
|
||||
$cornerstone.Enums.Events.IMAGE_RENDERED,
|
||||
onEvent
|
||||
);
|
||||
$cornerstone.eventTarget.removeEventListener(
|
||||
$cornerstone.Enums.Events.IMAGE_RENDERED,
|
||||
onEvent
|
||||
);
|
||||
resolve();
|
||||
};
|
||||
const onEnabled = enabledEvt => {
|
||||
const element = enabledEvt.detail.element;
|
||||
|
||||
element.addEventListener(
|
||||
$cornerstone.Enums.Events.IMAGE_RENDERED,
|
||||
onEvent
|
||||
);
|
||||
|
||||
$cornerstone.eventTarget.removeEventListener(
|
||||
$cornerstone.Enums.Events.ELEMENT_ENABLED,
|
||||
onEnabled
|
||||
);
|
||||
};
|
||||
const enabledElements = $cornerstone.getEnabledElements();
|
||||
if (enabledElements && enabledElements.length) {
|
||||
// Sometimes the page finishes rendering before this gets run,
|
||||
// if so, just resolve immediately.
|
||||
resolve();
|
||||
} else {
|
||||
$cornerstone.eventTarget.addEventListener(
|
||||
$cornerstone.Enums.Events.ELEMENT_ENABLED,
|
||||
onEnabled
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Command to reset and clear all the changes made to the viewport
|
||||
Cypress.Commands.add('resetViewport', () => {
|
||||
//Click on More button
|
||||
cy.get('[data-cy="MoreTools-split-button-primary"]')
|
||||
.should('have.attr', 'data-tool', 'Reset')
|
||||
.as('moreBtn')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('imageZoomIn', () => {
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.get('@zoomBtn').click();
|
||||
|
||||
//drags the mouse inside the viewport to be able to interact with series
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'top', { buttons: 1 })
|
||||
.trigger('mousemove', 'center', { buttons: 1 })
|
||||
.trigger('mouseup');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('imageContrast', () => {
|
||||
cy.initCornerstoneToolsAliases();
|
||||
cy.get('@wwwcBtnPrimary').click();
|
||||
|
||||
//drags the mouse inside the viewport to be able to interact with series
|
||||
cy.get('@viewport')
|
||||
.trigger('mousedown', 'center', { buttons: 1 })
|
||||
.trigger('mousemove', 'top', { buttons: 1 })
|
||||
.trigger('mouseup');
|
||||
});
|
||||
|
||||
//Initialize aliases for Cornerstone tools buttons
|
||||
Cypress.Commands.add('initCornerstoneToolsAliases', () => {
|
||||
initCornerstoneToolsAliases();
|
||||
});
|
||||
|
||||
//Initialize aliases for Common page elements
|
||||
Cypress.Commands.add('initCommonElementsAliases', () => {
|
||||
initCommonElementsAliases();
|
||||
});
|
||||
|
||||
//Initialize aliases for Routes
|
||||
Cypress.Commands.add('initRouteAliases', () => {
|
||||
initRouteAliases();
|
||||
});
|
||||
|
||||
//Initialize aliases for Study List page elements
|
||||
Cypress.Commands.add('initStudyListAliasesOnDesktop', () => {
|
||||
initStudyListAliasesOnDesktop();
|
||||
});
|
||||
|
||||
//Add measurements in the viewport
|
||||
Cypress.Commands.add(
|
||||
'addLengthMeasurement',
|
||||
(firstClick = [150, 100], secondClick = [130, 170]) => {
|
||||
cy.get('@measurementToolsBtnPrimary')
|
||||
.should('have.attr', 'data-tool', 'Length')
|
||||
.click()
|
||||
.then($lengthBtn => {
|
||||
cy.wrap($lengthBtn).should('have.class', 'active');
|
||||
});
|
||||
|
||||
cy.addLine('.viewport-element', firstClick, secondClick);
|
||||
}
|
||||
);
|
||||
|
||||
//Add measurements in the viewport
|
||||
Cypress.Commands.add(
|
||||
'addAngleMeasurement',
|
||||
(initPos = [180, 390], midPos = [300, 410], finalPos = [180, 450]) => {
|
||||
cy.get('[data-cy="Angle"]').click();
|
||||
cy.addAngle('.viewport-element', initPos, midPos, finalPos);
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Tests if element is NOT in viewport, or does not exist in DOM
|
||||
*
|
||||
* @param {string} element - element selector string or alias
|
||||
* @returns
|
||||
*/
|
||||
Cypress.Commands.add('isNotInViewport', element => {
|
||||
cy.get(element, { timeout: 3000 }).should($el => {
|
||||
const bottom = Cypress.$(cy.state('window')).height() - 50;
|
||||
const right = Cypress.$(cy.state('window')).width() - 50;
|
||||
|
||||
// If it's not visible, it's not in the viewport
|
||||
if ($el) {
|
||||
const rect = $el[0].getBoundingClientRect();
|
||||
|
||||
// TODO: support leftOf, above
|
||||
const isBeneath = rect.top >= bottom && rect.bottom >= bottom;
|
||||
const isRightOf = rect.left >= right && rect.right >= right;
|
||||
const isNotInViewport = isBeneath && isRightOf;
|
||||
|
||||
expect(isNotInViewport).to.be.true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests if element is in viewport, or it does exist in DOM
|
||||
*
|
||||
* @param {string} element - element selector string or alias
|
||||
* @returns
|
||||
*/
|
||||
Cypress.Commands.add('isInViewport', element => {
|
||||
cy.get(element, { timeout: 3000 }).should($el => {
|
||||
const bottom = Cypress.$(cy.state('window')).height();
|
||||
const right = Cypress.$(cy.state('window')).width();
|
||||
|
||||
// If it's not visible, it's not in the viewport
|
||||
if ($el) {
|
||||
const rect = $el[0].getBoundingClientRect();
|
||||
|
||||
// TODO: support leftOf, above
|
||||
const isBeneath = rect.top < bottom && rect.bottom < bottom;
|
||||
const isRightOf = rect.left < right && rect.right < right;
|
||||
const isInViewport = isBeneath && isRightOf;
|
||||
|
||||
expect(isInViewport).to.be.true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Percy.io Canvas screenshot workaround
|
||||
*
|
||||
*/
|
||||
Cypress.Commands.add('percyCanvasSnapshot', (name, options = {}) => {
|
||||
cy.document().then(doc => {
|
||||
convertCanvas(doc);
|
||||
});
|
||||
|
||||
// `domTransformation` does not appear to be working
|
||||
// But modifying our immediate DOM does.
|
||||
cy.percySnapshot(name, { ...options }); //, domTransformation: convertCanvas });
|
||||
|
||||
cy.document().then(doc => {
|
||||
unconvertCanvas(doc);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('setLayout', (columns = 1, rows = 1) => {
|
||||
cy.get('[data-cy="layout"]').click();
|
||||
|
||||
cy.get('.layoutChooser')
|
||||
.find('tr')
|
||||
.eq(rows - 1)
|
||||
.find('td')
|
||||
.eq(columns - 1)
|
||||
.click();
|
||||
|
||||
cy.wait(1000);
|
||||
});
|
||||
|
||||
function convertCanvas(documentClone) {
|
||||
documentClone
|
||||
.querySelectorAll('canvas')
|
||||
.forEach(selector => canvasToImage(selector));
|
||||
|
||||
return documentClone;
|
||||
}
|
||||
|
||||
function unconvertCanvas(documentClone) {
|
||||
// Remove previously generated images
|
||||
documentClone
|
||||
.querySelectorAll('[data-percy-image]')
|
||||
.forEach(selector => selector.remove());
|
||||
// Restore canvas visibility
|
||||
documentClone.querySelectorAll('[data-percy-canvas]').forEach(selector => {
|
||||
selector.removeAttribute('data-percy-canvas');
|
||||
selector.style = '';
|
||||
});
|
||||
}
|
||||
|
||||
function canvasToImage(selectorOrEl) {
|
||||
let canvas =
|
||||
typeof selectorOrEl === 'object'
|
||||
? selectorOrEl
|
||||
: document.querySelector(selectorOrEl);
|
||||
let image = document.createElement('img');
|
||||
let canvasImageBase64 = canvas.toDataURL('image/png');
|
||||
|
||||
// Show Image
|
||||
image.src = canvasImageBase64;
|
||||
image.style = 'width: 100%';
|
||||
image.setAttribute('data-percy-image', true);
|
||||
// Hide Canvas
|
||||
canvas.setAttribute('data-percy-canvas', true);
|
||||
canvas.parentElement.appendChild(image);
|
||||
canvas.style = 'display: none';
|
||||
}
|
||||
|
||||
//Initialize aliases for User Preferences modal
|
||||
Cypress.Commands.add('initPreferencesModalAliases', () => {
|
||||
initPreferencesModalAliases();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openPreferences', () => {
|
||||
cy.log('Open User Preferences Modal');
|
||||
// Open User Preferences modal
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.OHIFModal').length === 0) {
|
||||
cy.get('[data-cy="options-chevron-down-icon"]')
|
||||
.scrollIntoView()
|
||||
.click()
|
||||
.then(() => {
|
||||
cy.get('[data-cy="options-dropdown"]')
|
||||
.last()
|
||||
.click()
|
||||
.wait(200);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
|
||||
cy.get('body').then(body => {
|
||||
// Close notification if displayed
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
}
|
||||
|
||||
// Close User Preferences Modal (if displayed)
|
||||
if (body.find('.OHIFModal__header').length > 0) {
|
||||
cy.get('[data-cy="close-button"]').click({ force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('selectPreferencesTab', tabAlias => {
|
||||
cy.initPreferencesModalAliases();
|
||||
cy.get(tabAlias)
|
||||
.click()
|
||||
.should('have.class', 'active');
|
||||
initPreferencesModalFooterBtnAliases();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('resetUserHotkeyPreferences', () => {
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
|
||||
cy.selectPreferencesTab('@userPreferencesHotkeysTab').then(() => {
|
||||
cy.log('Reset Hotkeys to Default Preferences');
|
||||
cy.get('@restoreBtn').click();
|
||||
});
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
}
|
||||
// Click on Save Button
|
||||
cy.get('@saveBtn').click();
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('resetUserGeneralPreferences', () => {
|
||||
// Open User Preferences modal
|
||||
cy.openPreferences();
|
||||
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab').then(() => {
|
||||
cy.log('Reset Language to Default Preferences');
|
||||
cy.get('@restoreBtn').click();
|
||||
});
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
}
|
||||
// Click on Save Button
|
||||
cy.get('@saveBtn').click();
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add(
|
||||
'setNewHotkeyShortcutOnUserPreferencesModal',
|
||||
(function_label, shortcut) => {
|
||||
// Within scopes all `.get` and `.contains` to within the matched elements
|
||||
// dom instead of checking from document
|
||||
cy.get('.HotkeysPreferences').within(() => {
|
||||
cy.contains(function_label) // label we're looking for
|
||||
.parent()
|
||||
.find('input') // closest input to that label
|
||||
.type(shortcut, { force: true }); // Set new shortcut for that function
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Cypress.Commands.add(
|
||||
'setWindowLevelPreset',
|
||||
(preset_index, description_value, window_value, level_value) => {
|
||||
let index = parseInt(preset_index) + 1;
|
||||
|
||||
// Set new Description value
|
||||
cy.get(':nth-child(' + index + ') > .description > .preferencesInput')
|
||||
.clear()
|
||||
.type(description_value, {
|
||||
force: true,
|
||||
})
|
||||
.blur();
|
||||
|
||||
// Set new Window value
|
||||
cy.get(':nth-child(' + index + ') > .window > .preferencesInput')
|
||||
.clear()
|
||||
.type(window_value, {
|
||||
force: true,
|
||||
})
|
||||
.blur();
|
||||
|
||||
// Set new Level value
|
||||
cy.get(':nth-child(' + index + ') > .level > .preferencesInput')
|
||||
.clear()
|
||||
.type(level_value, {
|
||||
force: true,
|
||||
})
|
||||
.blur();
|
||||
}
|
||||
);
|
||||
|
||||
Cypress.Commands.add('openDownloadImageModal', () => {
|
||||
// Click on More button
|
||||
cy.get('[data-cy="Capture"]')
|
||||
.as('captureBtn')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('setLanguage', (language, save = true) => {
|
||||
cy.openPreferences();
|
||||
cy.initPreferencesModalAliases();
|
||||
cy.selectPreferencesTab('@userPreferencesGeneralTab');
|
||||
|
||||
// Language dropdown should be displayed
|
||||
cy.get('#language-select').should('be.visible');
|
||||
|
||||
// Select Language and Save/Cancel
|
||||
cy.get('#language-select').select(language);
|
||||
|
||||
// Close Success Message overlay (if displayed)
|
||||
cy.get('body').then(body => {
|
||||
if (body.find('.sb-closeIcon').length > 0) {
|
||||
cy.get('.sb-closeIcon')
|
||||
.first()
|
||||
.click({ force: true });
|
||||
}
|
||||
|
||||
//Click on Save/Cancel button
|
||||
const toClick = save ? '@saveBtn' : '@cancelBtn';
|
||||
cy.get(toClick)
|
||||
.scrollIntoView()
|
||||
.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);
|
||||
};
|
||||
@@ -0,0 +1,2 @@
|
||||
import './aliases.js';
|
||||
import './commands.js';
|
||||
Reference in new issue
Block a user