test: add E2E test for contour combine intersect and subtract operations (#6131)

This commit is contained in:
Ghadeer Albattarni authored and GitHub committed 2026-07-11 02:21:39 -04:00
1 parent f0e2f64397
commit 01939e2236
7 files changed
+189 -4

No files matched your search

+118
View File
@@ -0,0 +1,118 @@
import {
test,
expect,
waitForViewportRenderCycle,
checkForScreenshot,
screenShotPaths,
visitStudyAndHydrate,
} from './utils';
const segments = {
bigSphere: 'Big Sphere',
smallSphere: 'Small Sphere',
result: 'Segment 5',
} as const;
test.beforeEach(
async ({ page, leftPanelPageObject, DOMOverlayPageObject, rightPanelPageObject }) => {
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
await visitStudyAndHydrate({
page,
leftPanelPageObject,
DOMOverlayPageObject,
studyInstanceUID,
modality: 'RTSTRUCT',
});
}
);
test.describe('Intersect operation', () => {
test('intersect Big Sphere with Small Sphere (nested, no edge crossing) produces Small Sphere', async ({
page,
rightPanelPageObject,
viewportPageObject,
}) => {
const contourSegmentationPanel = rightPanelPageObject.contourSegmentationPanel;
const activeViewport = await viewportPageObject.active;
await activeViewport.pane.dblclick();
await contourSegmentationPanel.config.toggle.click();
await contourSegmentationPanel.config.display.fillAndOutline();
await contourSegmentationPanel.panel.segmentByText(segments.bigSphere).click();
const combineContours = rightPanelPageObject.contourSegmentationPanel.combineContours;
await combineContours.open();
await combineContours.selectOperation('intersect');
await combineContours.selectSegmentA(segments.bigSphere);
await combineContours.selectSegmentB(segments.smallSphere);
await combineContours.enableCreateNewSegment();
let viewportRenderCycle = waitForViewportRenderCycle(page);
await combineContours.apply();
await viewportRenderCycle;
await expect(contourSegmentationPanel.panel.rows).toHaveCount(5);
await expect(contourSegmentationPanel.panel.nthSegment(4).title).toHaveText(segments.result);
await contourSegmentationPanel.segmentsVisibilityToggle.click();
viewportRenderCycle = waitForViewportRenderCycle(page);
await contourSegmentationPanel.panel.segmentByText(segments.result).toggleVisibility();
await viewportRenderCycle;
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.contourCombineOperations.intersectBigSphereSmallSphereResult
);
});
});
test.describe('Subtract operation', () => {
test('subtract Big Sphere minus Small Sphere (nested, no edge crossing) produces Big Sphere with a hole', async ({
page,
rightPanelPageObject,
viewportPageObject,
}) => {
const contourSegmentationPanel = rightPanelPageObject.contourSegmentationPanel;
const activeViewport = await viewportPageObject.active;
await activeViewport.pane.dblclick();
await contourSegmentationPanel.config.toggle.click();
await contourSegmentationPanel.config.display.fillAndOutline();
await contourSegmentationPanel.panel.segmentByText(segments.bigSphere).click();
const combineContours = rightPanelPageObject.contourSegmentationPanel.combineContours;
await combineContours.open();
await combineContours.selectOperation('subtract');
await combineContours.selectSegmentA(segments.bigSphere);
await combineContours.selectSegmentB(segments.smallSphere);
await combineContours.enableCreateNewSegment();
let viewportRenderCycle = waitForViewportRenderCycle(page);
await combineContours.apply();
await viewportRenderCycle;
await expect(contourSegmentationPanel.panel.rows).toHaveCount(5);
await expect(contourSegmentationPanel.panel.nthSegment(4).title).toHaveText(segments.result);
await contourSegmentationPanel.segmentsVisibilityToggle.click();
viewportRenderCycle = waitForViewportRenderCycle(page);
await contourSegmentationPanel.panel.segmentByText(segments.result).toggleVisibility();
await viewportRenderCycle;
await checkForScreenshot(
page,
viewportPageObject.grid,
screenShotPaths.contourCombineOperations.subtractBigSphereMinusSmallSphereResult
);
});
});
+48
View File
@@ -395,6 +395,54 @@ export class RightPanelPageObject {
};
},
},
get config() {
const configToggle = page.getByTestId('segmentation-config-toggle-Contour');
return {
toggle: {
locator: configToggle,
click: async () => {
await configToggle.click();
},
},
display: {
fillAndOutline: async () => {
await page
.getByTestId(`segmentation-config-display-fill-and-outline-Contour`)
.click();
},
outline: async () => {
await page.getByTestId(`segmentation-config-display-outline-Contour`).click();
},
fill: async () => {
await page.getByTestId(`segmentation-config-display-fill-Contour`).click();
},
},
};
},
get combineContours() {
return {
open: async () => {
await page.getByTestId('LogicalContourOperations').click();
},
selectOperation: async (operation: 'merge' | 'intersect' | 'subtract') => {
await page.getByTestId(`logical-contour-operation-${operation}`).click();
},
selectSegmentA: async (label: string) => {
await page.getByTestId('logical-contour-segment-a-trigger').click();
await page.getByRole('option', { name: label }).click();
},
selectSegmentB: async (label: string) => {
await page.getByTestId('logical-contour-segment-b-trigger').click();
await page.getByRole('option', { name: label }).click();
},
apply: async () => {
await page.getByTestId('apply-logical-contour-operation').click();
},
enableCreateNewSegment: async () => {
await page.getByTestId('logical-contour-create-new-segment-switch').click();
},
};
},
};
}
get labelMapSegmentationPanel() {
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

+4
View File
@@ -221,6 +221,10 @@ const screenShotPaths = {
overlaysDisplayed: 'overlaysDisplayed.png',
overlaySEGsAndRTDisplayed: 'overlaySEGsAndRTDisplayed.png',
},
contourCombineOperations: {
subtractBigSphereMinusSmallSphereResult: 'subtractBigSphereMinusSmallSphereResult.png',
intersectBigSphereSmallSphereResult: 'intersectBigSphereSmallSphereResult.png',
},
workList: {
scrollBarRenderedProperly: 'scrollBarRenderedProperly.png',
},