feat(test): Playwright testing integration (#4146)

This commit is contained in:
Ibrahim authored and GitHub committed 2024-05-21 14:48:35 -04:00
1 parent 856cd17531
commit fe1a706446
26 files changed
+434 -215

No files matched your search

+1
View File
@@ -1 +1,2 @@
.vercel
test-results
@@ -1,25 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy Layout Advanced Presets', () => {
beforeEach(() => {
cy.openStudyInViewer('1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1');
cy.wait(5000);
cy.expectMinimumThumbnails(3);
});
it('should display each layout preset correctly', () => {
cy.get('[data-cy="study-browser-thumbnail"]').eq(2).dblclick();
cy.selectLayoutPreset('MPR', true);
cy.percyCanvasSnapshot('MPR Preset');
cy.selectLayoutPreset('3D four up');
cy.percyCanvasSnapshot('3D four up Preset');
cy.selectLayoutPreset('3D main');
cy.percyCanvasSnapshot('3D main Preset');
cy.selectLayoutPreset('Axial Primary');
cy.percyCanvasSnapshot('Axial Primary Preset');
cy.selectLayoutPreset('3D only');
cy.percyCanvasSnapshot('3D only Preset');
cy.selectLayoutPreset('3D primary');
cy.percyCanvasSnapshot('3D primary Preset');
});
});
@@ -1,31 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy MPR Crosshairs', () => {
beforeEach(() => {
cy.openStudyInViewer(
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
'&hangingProtocolId=default',
'/viewer'
);
cy.wait(5000);
cy.expectMinimumThumbnails(4);
});
it('should enabled crosshairs in MPR and reset them when another series is loaded', () => {
cy.get('[data-cy="study-browser-thumbnail"]').eq(2).dblclick();
cy.selectLayoutPreset('MPR');
cy.get('[data-cy="Crosshairs"]').click();
cy.wait(500);
cy.percyCanvasSnapshot('Crosshairs enabled');
cy.wait(100);
cy.get('[data-viewport-uid="mpr-axial"] > .viewport-element > .cornerstone-canvas').click(
45,
100
);
cy.wait(200);
cy.percyCanvasSnapshot('Crosshairs are moved');
cy.get('[data-cy="study-browser-thumbnail"]').eq(0).dblclick();
cy.wait(500);
cy.percyCanvasSnapshot('Another series dropped, Crosshairs are centered');
});
});
@@ -1,13 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy PDF Display', () => {
beforeEach(() => {
cy.openStudyInViewer('1.2.826.0.13854362241694438965858641723883466450351448');
cy.wait(5000);
cy.expectMinimumThumbnails(1);
});
it('should display PDFs correctly', () => {
cy.percyCanvasSnapshot('PDF');
});
});
@@ -1,26 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy SR', () => {
beforeEach(() => {
cy.openStudyInViewer('1.2.840.113619.2.5.1762583153.215519.978957063.78');
cy.wait(5000);
cy.expectMinimumThumbnails(3);
});
it('should hydrate SR correctly and Jump to Measurements', () => {
cy.get('[data-cy="study-browser-thumbnail-no-image"]').first().dblclick();
cy.wait(200);
cy.percyCanvasSnapshot('SR Preview');
cy.get('body').type('{enter}');
cy.wait(200);
cy.percyCanvasSnapshot('SR Hydrated');
cy.get('[data-cy="trackedMeasurements-btn"]').click();
cy.percyCanvasSnapshot('Opened Measurement Panel');
cy.get('body').type('{downarrow}');
cy.get('body').type('{downarrow}');
cy.get('body').type('{downarrow}');
cy.percyCanvasSnapshot('Scrolled away from measurements');
cy.get('[data-cy="measurement-item"]').first().click();
cy.percyCanvasSnapshot('Jumped to Measurement');
});
});
@@ -1,42 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy Segmentation Tools', () => {
beforeEach(() => {
Cypress.on('uncaught:exception', () => false);
cy.openStudyInViewer(
'1.3.6.1.4.1.25403.345050719074.3824.20170125113417.1',
'&hangingProtocolId=default',
'/segmentation'
);
cy.wait(5000);
cy.expectMinimumThumbnails(3);
});
it('should be able to use all segmentation tools and have them render correctly', () => {
cy.get('[data-cy="study-browser-thumbnail"]').eq(1).dblclick();
cy.percyCanvasSnapshot('Segmentation tools are disabled');
cy.get('span').contains('Add segmentation').should('have.css', 'pointer-events', 'none');
cy.percyCanvasSnapshot(
'Add segmentation button is disabled when the displayset is none reconstructable'
);
cy.get('[data-cy="study-browser-thumbnail"]').eq(2).dblclick();
cy.get('span').contains('Add segmentation').click();
cy.wait(500);
cy.percyCanvasSnapshot('Segmentation added and tools are enabled');
cy.get('[data-cy="Brush"]').click();
cy.percyCanvasSnapshot('Brush tool selected');
cy.addBrush('.cornerstone-canvas');
cy.percyCanvasSnapshot('Brush tool applied');
cy.get('[data-cy="Eraser"]').click();
cy.percyCanvasSnapshot('Eraser tool selected');
cy.addEraser('.cornerstone-canvas');
cy.percyCanvasSnapshot('Eraser tool applied');
cy.selectLayoutPreset('MPR');
cy.get('[data-cy="Brush"]').click();
cy.percyCanvasSnapshot('Brush tool selected in MPR');
cy.get('button').contains('Sphere').click();
cy.percyCanvasSnapshot('Sphere mode for Brush tool selected');
cy.addBrush('[data-viewport-uid="mpr-axial"] > .viewport-element > .cornerstone-canvas');
cy.percyCanvasSnapshot('Sphere stroke for Brush tool applied');
});
});
@@ -1,38 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy TMTV', () => {
beforeEach(() => {
cy.openStudyInViewer(
'1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
'',
'/tmtv'
);
cy.wait(10000);
});
it('should maintain VOI when going 1 up and back', () => {
cy.percyCanvasSnapshot('TMTV Loaded');
cy.get('[data-viewport-uid="mipSagittal"] > .viewport-element > .cornerstone-canvas').dblclick(
100,
100
);
cy.wait(500);
cy.percyCanvasSnapshot('TMTV One up view loaded');
cy.get('[data-viewport-uid="mipSagittal"] > .viewport-element > .cornerstone-canvas').dblclick(
100,
100
);
cy.wait(500);
cy.percyCanvasSnapshot('TMTV Back to original view');
});
it('should still look fine when changing patient data', () => {
cy.get('[data-cy="petSUV-btn"]').click();
cy.percyCanvasSnapshot('TMTV Patient Panel Opened');
cy.get('[data-cy="input-weight-input"]').type('191');
cy.percyCanvasSnapshot('TMTV Patient Panel Weight Changed');
cy.get('button').contains('Reload Data').click();
cy.wait(5000);
cy.percyCanvasSnapshot('TMTV Reloaded Data');
});
});
@@ -1,13 +0,0 @@
import '@percy/cypress';
describe('OHIF Percy Video Display', () => {
beforeEach(() => {
cy.openStudyInViewer('2.25.96975534054447904995905761963464388233');
cy.wait(5000);
cy.expectMinimumThumbnails(0);
});
it('should display Videos correctly', () => {
cy.percyCanvasSnapshot('Video');
});
});
+2 -1
View File
@@ -36,7 +36,6 @@
"dev:viewer": "yarn run dev",
"start": "yarn run dev",
"test:e2e": "cypress open",
"test:e2e:ci": "percy exec -- cypress run --config video=false --browser chrome --spec 'cypress/integration/visual-regression/**/*'",
"test:e2e:local": "cypress run --config video=false --browser chrome --spec 'cypress/integration/common/**/*,cypress/integration/pwa/**/*'",
"test:e2e:dist": "start-server-and-test test:e2e:serve http://localhost:3000 test:e2e:ci",
"test:e2e:serve": "cross-env APP_CONFIG=config/e2e.js yarn start",
@@ -99,6 +98,8 @@
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@percy/cypress": "^3.1.1",
"@playwright/test": "^1.44.0",
"@types/node": "^20.12.12",
"cypress": "13.7.2",
"cypress-file-upload": "^3.5.3",
"glob": "^8.0.3",
@@ -270,6 +270,7 @@ function WorkList({
return {
dataCY: `studyRow-${studyInstanceUid}`,
clickableCY: studyInstanceUid,
row: [
{
key: 'patientName',
@@ -630,7 +631,7 @@ function _getQueryFilterValues(params) {
sortBy: params.get('sortby'),
sortDirection: params.get('sortdirection'),
pageNumber: _tryParseInt(params.get('pagenumber'), undefined),
resultsPerPage: _tryParseInt(params.get('resultsperpage'), undefined),
resultsPerPage: _tryParseInt(params.get('resultsPerPage'), undefined),
datasources: params.get('datasources'),
configUrl: params.get('configurl'),
};