ohif-viewer/tests/LabelMapSegLocking.spec.ts
Joe Boccanfuso fe16e80cf3
test(e2e): update Playwright screenshots and add better tests and assertions for area calculations (#6022)
* Add (better) assertions for area calculation fixes.
* Add SVG and measurement side panel area for freehand ROI test.
* Add Playwright viewport screenshot scope migration guide.
* Update cornerstonjs dependencies to 4.22.8. Ensure all versions of @babel/preset-env are 7.29.5.

---------

Co-authored-by: Ghadeer Albattarni <165973963+GhadeerAlbattarni@users.noreply.github.com>
2026-05-18 10:36:05 -04:00

133 lines
4.2 KiB
TypeScript

import {
addOHIFGlobalCustomizations,
checkForScreenshot,
screenShotPaths,
test,
visitStudy,
} from './utils';
import { press } from './utils/keyboardUtils';
test.beforeEach(async ({ page }) => {
const studyInstanceUID = '1.3.6.1.4.1.14519.5.2.1.256467663913010332776401703474716742458';
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
});
test('should prevent editing of label map segmentations when panelSegmentation.disableEditing is true', async ({
page,
DOMOverlayPageObject,
leftPanelPageObject,
rightPanelPageObject,
viewportPageObject,
}) => {
// disable editing of segmentations via the customization service
await addOHIFGlobalCustomizations(page, {
'panelSegmentation.disableEditing': true,
});
await rightPanelPageObject.labelMapSegmentationPanel.select();
await leftPanelPageObject.loadSeriesByModality('SEG');
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
// Wait for the segmentation to hydrate.
await page.waitForTimeout(5000);
// navigate to the 12th image and ensure the correct overlay is displayed
await press({ page, key: 'ArrowDown', nTimes: 11 });
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.labelMapSegLocking.globalLockedSegPreEdit
);
// Attempt to erase the segmentations.
await rightPanelPageObject.labelMapSegmentationPanel.tools.eraser.click();
// Use the largest eraser radius to help ensure the entire image is erased.
await rightPanelPageObject.labelMapSegmentationPanel.tools.eraser.setRadius(1000);
// Attempt to erase the segmentations by dragging the eraser tool across the image several times.
const defaultViewport = await viewportPageObject.getById('default');
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.25 },
end: { x: 1.0, y: 0.25 },
});
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.5 },
end: { x: 1.0, y: 0.5 },
});
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.75 },
end: { x: 1.0, y: 0.75 },
});
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.labelMapSegLocking.globalLockedSegPostEdit
);
});
test('should allow editing of label map segmentations when panelSegmentation.disableEditing is false', async ({
page,
DOMOverlayPageObject,
leftPanelPageObject,
rightPanelPageObject,
viewportPageObject,
}) => {
// disable editing of segmentations via the customization service
await addOHIFGlobalCustomizations(page, {
'panelSegmentation.disableEditing': false,
});
await rightPanelPageObject.labelMapSegmentationPanel.select();
await leftPanelPageObject.loadSeriesByModality('SEG');
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
await DOMOverlayPageObject.viewport.segmentationHydration.yes.click();
// Wait for the segmentation to hydrate.
await page.waitForTimeout(5000);
// navigate to the 12th image and ensure the correct overlay is displayed
await press({ page, key: 'ArrowDown', nTimes: 11 });
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.labelMapSegLocking.globalUnlockedSegPreEdit
);
// Attempt to erase the segmentations.
await rightPanelPageObject.labelMapSegmentationPanel.tools.eraser.click();
// Use the largest eraser radius to help ensure the eraser passes over the entire image.
await rightPanelPageObject.labelMapSegmentationPanel.tools.eraser.setRadius(1000);
// Attempt to erase the segmentations by dragging the eraser tool across the image several times.
const defaultViewport = await viewportPageObject.getById('default');
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.25 },
end: { x: 1.0, y: 0.25 },
});
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.5 },
end: { x: 1.0, y: 0.5 },
});
await defaultViewport.normalizedDragAt({
start: { x: 0.01, y: 0.75 },
end: { x: 1.0, y: 0.75 },
});
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.labelMapSegLocking.globalUnlockedSegPostEdit
);
});