From 19b22c39ae9e84d1037448ad5ff56617559d0b08 Mon Sep 17 00:00:00 2001 From: Mirna Silva Date: Wed, 6 Nov 2019 01:46:38 -0300 Subject: [PATCH] test: Study list test cases: Patient Name, MRN, Modality, Description (#1121) * Study list tests: Patient Name, MRN, Modality, Description * Fixed field selector * Desktop tests * Fix for study list * Added tablet tests and small refactor on aliases * Fix based on reviews --- .../integration/common/OHIFStudyList.spec.js | 199 ++++++++++++++++++ .../common/OHIFStudyViewer.spec.js | 56 +++-- platform/viewer/cypress/support/aliases.js | 25 +++ platform/viewer/cypress/support/commands.js | 20 +- 4 files changed, 268 insertions(+), 32 deletions(-) create mode 100644 platform/viewer/cypress/integration/common/OHIFStudyList.spec.js diff --git a/platform/viewer/cypress/integration/common/OHIFStudyList.spec.js b/platform/viewer/cypress/integration/common/OHIFStudyList.spec.js new file mode 100644 index 000000000..e91c8d443 --- /dev/null +++ b/platform/viewer/cypress/integration/common/OHIFStudyList.spec.js @@ -0,0 +1,199 @@ +describe('OHIF Study List', function() { + context('Desktop resolution', function() { + beforeEach(function() { + cy.viewport(1750, 720); + cy.openStudyList(); + cy.initStudyListAliasesOnDesktop(); + }); + + it('searches Patient Name with exact string', function() { + cy.get('@patientName').type('Juno'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('Juno'); + }); + }); + + it('searches MRN with exact string', function() { + cy.get('@MRN').type('ProstateX-0000'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('ProstateX-0000'); + }); + }); + + it('searches Accession with exact string', function() { + cy.get('@accessionNumber').type('fpcben98890'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(1); + expect($list).to.contain('fpcben98890'); + }); + }); + + it('searches Modality with camel case', function() { + cy.get('@modalities').type('Mr'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(17); + expect($list).to.contain('MR'); + }); + }); + + it('searches Description with exact string', function() { + cy.get('@studyDescription').type('CHEST'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('CHEST'); + }); + }); + + 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('@studyCount') + .should($studyCount => { + expect(parseInt($studyCount.text())).to.be.at.most(numRows); //less than or equals to + }) + .then($studyCount => { + //Compare to the number of rows in the search result + cy.get('@searchResult').then($searchResult => { + let countResults = $searchResult.length; + expect($studyCount.text()).to.be.eq(countResults.toString()); + }); + }); + }); + }); + }); + + //TO-TO: This test should be uncommented once issue #1120 is fixed: + //https://github.com/OHIF/Viewers/issues/1120 + // it('filter study list by Study Date', function() { + // //Type Start and End dates + // cy.get('@studyListStartDate').type('01/01/2000'); + // cy.get('@studyListEndDate').type('01/01/2019'); + // //Display all results into one page + // cy.get('select').select('100'); + // //Checks if all expected results are displayed + // //Wait result list to be displayed + // cy.waitStudyList(); + // cy.get('@searchResult').should($list => { + // expect($list.length).to.be.eq(42); + // }); + // }); + }); + + context('Tablet resolution', function() { + beforeEach(function() { + cy.viewport(1000, 660); + cy.openStudyList(); + cy.initStudyListAliasesOnTablet(); + }); + + it('searches Patient Name with exact string', function() { + cy.get('@patientNameOrMRN').type('Juno'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('Juno'); + }); + }); + + it('searches MRN with with exact string', function() { + cy.get('@patientNameOrMRN').type('ProstateX-0000'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('ProstateX-0000'); + }); + }); + + it('searches Modality with exact string', function() { + cy.get('@accessionModalityDescription').type('MR'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(17); + expect($list).to.contain('MR'); + }); + }); + + it('searches Accession with exact string', function() { + cy.get('@accessionModalityDescription').type('fpcben98890'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(1); + expect($list).to.contain('fpcben98890'); + }); + }); + + it('searches Description with exact string', function() { + cy.get('@accessionModalityDescription').type('CHEST'); + //Wait result list to be displayed + cy.waitStudyList(); + cy.get('@searchResult').should($list => { + expect($list.length).to.be.eq(2); + expect($list).to.contain('CHEST'); + }); + }); + + 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('@studyCount') + .should($studyCount => { + expect(parseInt($studyCount.text())).to.be.at.most(numRows); //less than or equals to + }) + .then($studyCount => { + //Compare to the number of rows in the search result + cy.get('@searchResult').then($searchResult => { + let countResults = $searchResult.length; + expect($studyCount.text()).to.be.eq(countResults.toString()); + }); + }); + }); + }); + }); + + //TO-TO: This test should be uncommented once issue #1120 is fixed: + //https://github.com/OHIF/Viewers/issues/1120 + // it('filter study list by Study Date', function() { + // //Type Start and End dates + // cy.get('@studyListStartDate').type('01/01/2000'); + // cy.get('@studyListEndDate').type('01/01/2019'); + // //Display all results into one page + // cy.get('select').select('100'); + // //Checks if all expected results are displayed + // //Wait result list to be displayed + // cy.waitStudyList(); + // cy.get('@searchResult').should($list => { + // expect($list.length).to.be.eq(42); + // }); + // }); + }); +}); diff --git a/platform/viewer/cypress/integration/common/OHIFStudyViewer.spec.js b/platform/viewer/cypress/integration/common/OHIFStudyViewer.spec.js index daeb6c057..a58ea1004 100644 --- a/platform/viewer/cypress/integration/common/OHIFStudyViewer.spec.js +++ b/platform/viewer/cypress/integration/common/OHIFStudyViewer.spec.js @@ -72,30 +72,26 @@ describe('OHIF Study Viewer Page', function() { cy.get('@measurementsPanel').should('not.be.enabled'); }); - //TO-DO: Test case will fail due to issue #1013: https://github.com/OHIF/Viewers/issues/1013 + 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(); - // 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); - // }); + // 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); + }); 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 @@ -228,14 +224,12 @@ describe('OHIF Study Viewer Page', function() { cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText); }); - //TO-DO: this test is blocked due to issue #1072: https://github.com/OHIF/Viewers/issues/1072 - // Uncomment this once #1072 is fixed. - // it('performs single-click to load thumbnail in active viewport', () => { - // cy.get('[data-cy="thumbnail-list"]:nth-child(3)').click(); + it('performs single-click to load thumbnail in active viewport', () => { + cy.get('[data-cy="thumbnail-list"]:nth-child(3)').click(); - // const expectedText = 'Ser 3'; - // cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText); - // }); + const expectedText = 'Ser: 3'; + cy.get('@viewportInfoBottomLeft').should('contains.text', expectedText); + }); it('performs right click to zoom', function() { //Right click on viewport @@ -244,7 +238,7 @@ describe('OHIF Study Viewer Page', function() { .trigger('mousemove', 'center', { which: 3 }) .trigger('mouseup'); - const expectedText = 'Zoom: 442%'; + const expectedText = 'Zoom: 301%'; cy.get('@viewportInfoBottomRight').should('contains.text', expectedText); }); diff --git a/platform/viewer/cypress/support/aliases.js b/platform/viewer/cypress/support/aliases.js index 1f22d200f..c4b13e18f 100644 --- a/platform/viewer/cypress/support/aliases.js +++ b/platform/viewer/cypress/support/aliases.js @@ -52,3 +52,28 @@ export function initVTKToolsAliases() { cy.get('.ohif-check-label').as('modeCheckbox'); cy.get('.btn-group > .toolbar-button').as('layoutBtn'); } + +//Creating aliases for Study List page elements on Desktop experience +export function initStudyListAliasesOnDesktop() { + cy.get('.study-count').as('studyCount'); + cy.get('#filter-patientName').as('patientName'); + cy.get('#filter-patientId').as('MRN'); + cy.get('#filter-accessionNumber').as('accessionNumber'); + cy.get('#start-date').as('studyListStartDate'); + cy.get('#end-date').as('studyListEndDate'); + cy.get('#filter-modalities').as('modalities'); + cy.get('#filter-studyDescription').as('studyDescription'); + cy.get('[data-cy="study-list-results"] > tr').as('searchResult'); +} + +//Creating aliases for Study List page elements on Tablet experience +export function initStudyListAliasesOnTablet() { + cy.get('.study-count').as('studyCount'); + cy.get('#filter-patientNameOrId').as('patientNameOrMRN'); + cy.get('#filter-accessionOrModalityOrDescription').as( + 'accessionModalityDescription' + ); + cy.get('#start-date').as('studyListStartDate'); + cy.get('#end-date').as('studyListEndDate'); + cy.get('[data-cy="study-list-results"] > tr').as('searchResult'); +} diff --git a/platform/viewer/cypress/support/commands.js b/platform/viewer/cypress/support/commands.js index 4fa5be9eb..425681599 100644 --- a/platform/viewer/cypress/support/commands.js +++ b/platform/viewer/cypress/support/commands.js @@ -5,6 +5,8 @@ import { initCommonElementsAliases, initRouteAliases, initVTKToolsAliases, + initStudyListAliasesOnDesktop, + initStudyListAliasesOnTablet, } from './aliases.js'; // *********************************************** @@ -76,12 +78,18 @@ Cypress.Commands.add('isPageLoaded', (url = '/viewer/') => { return cy.location('pathname', { timeout: 60000 }).should('include', url); }); -Cypress.Commands.add('openStudyList', patientName => { +Cypress.Commands.add('openStudyList', () => { cy.initRouteAliases(); cy.visit('/'); cy.wait('@getStudies'); }); +Cypress.Commands.add('waitStudyList', () => { + cy.get('@searchResult').should($list => { + expect($list).to.not.have.class('no-hover'); + }); +}); + /** * 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) @@ -240,6 +248,16 @@ Cypress.Commands.add('initVTKToolsAliases', () => { initVTKToolsAliases(); }); +//Initialize aliases for Study List page elements +Cypress.Commands.add('initStudyListAliasesOnDesktop', () => { + initStudyListAliasesOnDesktop(); +}); + +//Initialize aliases for Study List page elements +Cypress.Commands.add('initStudyListAliasesOnTablet', () => { + initStudyListAliasesOnTablet(); +}); + //Add measurements in the viewport Cypress.Commands.add( 'addLengthMeasurement',