diff --git a/platform/viewer/cypress/integration/common/OHIFUserPreferences.spec.js b/platform/viewer/cypress/integration/common/OHIFUserPreferences.spec.js index 4fbd24e09..18e4d5f19 100644 --- a/platform/viewer/cypress/integration/common/OHIFUserPreferences.spec.js +++ b/platform/viewer/cypress/integration/common/OHIFUserPreferences.spec.js @@ -7,15 +7,22 @@ describe('OHIF User Preferences', () => { beforeEach(() => { // Open User Preferences modal cy.openPreferences(); - cy.initPreferencesModalAliases(); }); 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'); @@ -26,8 +33,7 @@ describe('OHIF User Preferences', () => { }); it('checks translation by selecting Spanish language', function() { - cy.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Language dropdown should be displayed cy.get('#language-select').should('be.visible'); @@ -92,16 +98,22 @@ describe('OHIF User Preferences', () => { cy.openPreferences(); // Go to general tab - cy.changePreferencesTab('@userPreferencesGeneralTab'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); cy.get('@restoreBtn') .scrollIntoView() .click(); - // Save - cy.get('@saveBtn') - .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') @@ -124,30 +136,54 @@ describe('OHIF User Preferences', () => { 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.changePreferencesTab('@userPreferencesHotkeysTab'); - cy.get('@userPreferencesHotkeysTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set new hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{shift}Q'); - // Save new hotkey - cy.get('@saveBtn') - .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(); + }); // Open User Preferences modal again cy.openPreferences(); // Go to General tab - cy.changePreferencesTab('@userPreferencesGeneralTab'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Set language to Spanish cy.setLanguage('Spanish'); // Go to Study Viewer page - cy.openStudyInViewer('1.2.840.113619.2.5.1762583153.215519.978957063.78'); - cy.waitDicomImage(); + cy.checkStudyRouteInViewer( + '1.2.840.113619.2.5.1762583153.215519.978957063.78' + ); cy.expectMinimumThumbnails(5); cy.initCommonElementsAliases(); @@ -178,7 +214,9 @@ describe('OHIF User Preferences', () => { context('Study Viewer Page', function() { before(() => { - cy.openStudyInViewer('1.2.840.113619.2.5.1762583153.215519.978957063.78'); + cy.checkStudyRouteInViewer( + '1.2.840.113619.2.5.1762583153.215519.978957063.78' + ); cy.expectMinimumThumbnails(5); }); @@ -186,29 +224,40 @@ describe('OHIF User Preferences', () => { cy.initCommonElementsAliases(); cy.resetViewport(); - cy.resetUserHoktkeyPreferences(); + 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'); - - cy.get('[data-cy="close-button"]').click(); //close User Preferences modal }); it('checks translation by selecting Spanish language', function() { - cy.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Language dropdown should be displayed cy.get('#language-select').should('be.visible'); @@ -232,9 +281,6 @@ describe('OHIF User Preferences', () => { 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() { @@ -260,13 +306,10 @@ describe('OHIF User Preferences', () => { 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() { - cy.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Language dropdown should be displayed cy.get('#language-select').should('be.visible'); @@ -278,12 +321,14 @@ describe('OHIF User Preferences', () => { cy.openPreferences(); // Go to general tab - cy.changePreferencesTab('@userPreferencesGeneralTab'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); + // click on restore button cy.get('@restoreBtn') .scrollIntoView() .click(); + // click on save button cy.get('@saveBtn') .scrollIntoView() .click(); @@ -303,15 +348,11 @@ describe('OHIF User Preferences', () => { cy.get('[data-cy="dd-item-menu"]') .last() .should('contain.text', 'Preferences'); - - // Close Options menu - cy.get('[data-cy="options-menu"]').click(); }); it('checks new hotkeys for "Rotate Right" and "Rotate Left"', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); - cy.get('@userPreferencesHotkeysTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set new hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal( @@ -324,10 +365,16 @@ describe('OHIF User Preferences', () => { '{shift}{leftarrow}' ); - //Save new hotkeys - cy.get('@saveBtn') - .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(); + }); //Rotate Right with new Hotkey cy.get('body').type('{shift}{rightarrow}'); @@ -340,8 +387,8 @@ describe('OHIF User Preferences', () => { it('checks new hotkeys for "Next" and "Previous" Image on Viewport', function() { // Update hotkeys for 'Next/Previous Viewport' - cy.changePreferencesTab('@userPreferencesHotkeysTab'); - cy.get('@userPreferencesHotkeysTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); + cy.setNewHotkeyShortcutOnUserPreferencesModal( 'Next Viewport', '{shift}{rightarrow}' @@ -350,9 +397,16 @@ describe('OHIF User Preferences', () => { 'Previous Viewport', '{shift}{leftarrow}' ); - cy.get('@saveBtn') - .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(); + }); // Set 3 viewports layout cy.setLayout(3, 1); @@ -391,7 +445,7 @@ describe('OHIF User Preferences', () => { it('checks error message when duplicated hotkeys are inserted', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set duplicated hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{i}'); @@ -404,15 +458,11 @@ describe('OHIF User Preferences', () => { .as('errorMsg') .should('have.text', '"Invert" is already using the "i" shortcut.'); }); - //Cancel hotkeys - cy.get('@cancelBtn') - .scrollIntoView() - .click(); }); it('checks error message when invalid hotkey is inserted', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set invalid hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal('Rotate Right', '{ctrl}Z'); @@ -425,16 +475,11 @@ describe('OHIF User Preferences', () => { .as('errorMsg') .should('have.text', '"ctrl+z" shortcut combination is not allowed'); }); - - //Cancel hotkeys - cy.get('@cancelBtn') - .scrollIntoView() - .click(); }); it('checks error message when only modifier keys are inserted', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set invalid modifier key: ctrl cy.setNewHotkeyShortcutOnUserPreferencesModal('Zoom Out', '{ctrl}'); @@ -465,16 +510,11 @@ describe('OHIF User Preferences', () => { 'have.text', "It's not possible to define only modifier keys (ctrl, alt and shift) as a shortcut" ); - - //Cancel hotkeys - cy.get('@cancelBtn') - .scrollIntoView() - .click(); }); it('checks if user can cancel changes made on User Preferences Hotkeys tab', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set new hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal( @@ -482,10 +522,16 @@ describe('OHIF User Preferences', () => { '{ctrl}{shift}S' ); - //Cancel hotkeys - cy.get('@cancelBtn') - .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 }); + } + //Cancel hotkeys + cy.get('@cancelBtn') + .scrollIntoView() + .click(); + }); // Open User Preferences modal again cy.openPreferences(); @@ -497,12 +543,11 @@ describe('OHIF User Preferences', () => { .find('input') .should('have.value', 'r'); }); - cy.get('[data-cy="close-button"]').click(); }); it('checks if user can reset to default values on User Preferences Hotkeys tab', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set new hotkey for 'Rotate Right' function cy.setNewHotkeyShortcutOnUserPreferencesModal( @@ -510,7 +555,7 @@ describe('OHIF User Preferences', () => { '{ctrl}{shift}S' ); - //Save hotkeys + // click on save button cy.get('@saveBtn') .scrollIntoView() .click(); @@ -523,9 +568,6 @@ describe('OHIF User Preferences', () => { .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 @@ -533,7 +575,183 @@ describe('OHIF User Preferences', () => { .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(5); + }); + + 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); + }); }); }); diff --git a/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFExtensionPDF.spec.js b/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFExtensionPDF.spec.js index 64079a706..3212f66fa 100644 --- a/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFExtensionPDF.spec.js +++ b/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFExtensionPDF.spec.js @@ -4,7 +4,7 @@ describe('Visual Regression - OHIF PDF Extension', () => { '1.2.826.0.13854362241694438965858641723883466450351448' ); cy.expectMinimumThumbnails(5); - });v + }); it('drags and drop a PDF thumbnail into viewport', () => { cy.get('[data-cy="thumbnail-list"]') diff --git a/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFUserPreferences.spec.js b/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFUserPreferences.spec.js index 8a7d1d49e..531507dda 100644 --- a/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFUserPreferences.spec.js +++ b/platform/viewer/cypress/integration/visual-regression/PercyCheckOHIFUserPreferences.spec.js @@ -7,10 +7,11 @@ describe('Visual Regression - OHIF User Preferences', () => { beforeEach(() => { // Open User Preferences modal cy.openPreferences(); - cy.initPreferencesModalAliases(); }); it('checks displayed information on User Preferences modal', function() { + // Go go hotkeys tab + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); cy.get('@restoreBtn').scrollIntoView(); // Visual comparison @@ -21,8 +22,7 @@ describe('Visual Regression - OHIF User Preferences', () => { }); it('checks translation by selecting Spanish language', function() { - cy.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Language dropdown should be displayed cy.get('#language-select').should('be.visible'); @@ -59,12 +59,14 @@ describe('Visual Regression - OHIF User Preferences', () => { cy.initCommonElementsAliases(); cy.resetViewport(); - cy.resetUserHoktkeyPreferences(); + cy.resetUserHotkeyPreferences(); // Open User Preferences modal cy.openPreferences(); }); it('checks displayed information on User Preferences modal', function() { + // Go go hotkeys tab + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); cy.get('@restoreBtn').scrollIntoView(); // Visual comparison @@ -74,9 +76,18 @@ describe('Visual Regression - OHIF User Preferences', () => { 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.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Visual comparison cy.percyCanvasSnapshot( @@ -100,8 +111,7 @@ describe('Visual Regression - OHIF User Preferences', () => { }); it('checks if user can restore to default the language selection and application will be in English', function() { - cy.changePreferencesTab('@userPreferencesGeneralTab'); - cy.get('@userPreferencesGeneralTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Set language to Spanish cy.setLanguage('Spanish'); @@ -110,7 +120,7 @@ describe('Visual Regression - OHIF User Preferences', () => { cy.openPreferences(); // Go to general tab - cy.changePreferencesTab('@userPreferencesGeneralTab'); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); cy.get('@restoreBtn') .scrollIntoView() @@ -136,8 +146,7 @@ describe('Visual Regression - OHIF User Preferences', () => { it('checks new hotkeys for "Next" and "Previous" Image on Viewport', function() { // Go go hotkeys tab - cy.changePreferencesTab('@userPreferencesHotkeysTab'); - cy.get('@userPreferencesHotkeysTab').should('have.class', 'active'); + cy.selectPreferencesTab('@userPreferencesHotkeysTab'); // Set new hotkey for 'Next Image Viewport' function cy.setNewHotkeyShortcutOnUserPreferencesModal( diff --git a/platform/viewer/cypress/support/aliases.js b/platform/viewer/cypress/support/aliases.js index 9c3f69781..d73646631 100644 --- a/platform/viewer/cypress/support/aliases.js +++ b/platform/viewer/cypress/support/aliases.js @@ -84,6 +84,7 @@ 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(); } diff --git a/platform/viewer/cypress/support/commands.js b/platform/viewer/cypress/support/commands.js index 4640587d2..487b56f2d 100644 --- a/platform/viewer/cypress/support/commands.js +++ b/platform/viewer/cypress/support/commands.js @@ -121,7 +121,7 @@ Cypress.Commands.add('waitVTKReformatting', () => { Cypress.Commands.add('waitViewportImageLoading', () => { // Wait for finish loading - cy.get('[data-cy="viewprt-grid"]', { timeout: 20000 }).should($grid => { + cy.get('[data-cy="viewprt-grid"]', { timeout: 30000 }).should($grid => { expect($grid).not.to.contain.text('Load'); }); }); @@ -466,21 +466,54 @@ Cypress.Commands.add('openPreferences', () => { }); }); -Cypress.Commands.add('changePreferencesTab', tabAlias => { +Cypress.Commands.add('selectPreferencesTab', tabAlias => { cy.initPreferencesModalAliases(); - cy.get(tabAlias).click(); + cy.get(tabAlias) + .click() + .should('have.class', 'active'); initPreferencesModalFooterBtnAliases(); }); -Cypress.Commands.add('resetUserHoktkeyPreferences', () => { +Cypress.Commands.add('resetUserHotkeyPreferences', () => { // Open User Preferences modal cy.openPreferences(); - cy.initPreferencesModalAliases(); + cy.selectPreferencesTab('@userPreferencesHotkeysTab').then(() => { + cy.log('Reset Hotkeys to Default Preferences'); + cy.get('@restoreBtn').click(); + }); - cy.log('Reset to Default Preferences'); - cy.get('@restoreBtn').click(); - cy.get('@saveBtn').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( @@ -499,6 +532,37 @@ Cypress.Commands.add( } ); +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="more"]') @@ -513,12 +577,8 @@ Cypress.Commands.add('openDownloadImageModal', () => { Cypress.Commands.add('setLanguage', (language, save = true) => { cy.openPreferences(); - - cy.get('@userPreferencesGeneralTab') - .click() - .should('have.class', 'active'); - - initPreferencesModalFooterBtnAliases(); + cy.initPreferencesModalAliases(); + cy.selectPreferencesTab('@userPreferencesGeneralTab'); // Language dropdown should be displayed cy.get('#language-select').should('be.visible'); @@ -526,8 +586,18 @@ Cypress.Commands.add('setLanguage', (language, save = true) => { // Select Language and Save/Cancel cy.get('#language-select').select(language); - const toClick = save ? '@saveBtn' : '@cancelBtn'; - cy.get(toClick) - .scrollIntoView() - .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/Cancel button + const toClick = save ? '@saveBtn' : '@cancelBtn'; + cy.get(toClick) + .scrollIntoView() + .click(); + }); });