test(segmentation): switch getSegmentCount to expect(rows).toHaveCount in panel specs (#6105)

This commit is contained in:
diattamo 2026-06-24 11:05:27 -04:00 committed by GitHub
parent 8f6947b75d
commit 95200ec6e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 28 deletions

View File

@ -152,8 +152,7 @@ test('duplicated contour will be generated with a new color', async ({
);
// duplicate the segment
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to start with 4 segments').toBe(4);
await expect(panel.rows, 'Expected to start with 4 segments').toHaveCount(4);
await segment0.actions.duplicate();
await segment0.toggleVisibility(); // toggle original segment 0 visibility off to be able to grab the duplicated segment's path

View File

@ -20,16 +20,14 @@ test('should delete a contour segment and remove its row from the panel', async
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to load with 4 segments').toBe(4);
await expect(panel.rows, 'Expected to load with 4 segments').toHaveCount(4);
const segment0 = panel.nthSegment(0);
await expect(segment0.title).toHaveText(defaultSegment0Name);
await segment0.actions.delete();
const countAfterDelete = await panel.getSegmentCount();
expect(countAfterDelete, 'Expected one fewer segment row after deleting').toBe(3);
await expect(panel.rows, 'Expected one fewer segment row after deleting').toHaveCount(3);
// The deleted segment's label should no longer be present anywhere in the panel
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment0Name }),
@ -46,16 +44,13 @@ test('should delete a contour segment and remove its row from the panel', async
test('should delete multiple contour segments sequentially', async ({ rightPanelPageObject }) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to load with 4 segments').toBe(4);
await expect(panel.rows, 'Expected to load with 4 segments').toHaveCount(4);
await panel.nthSegment(0).actions.delete();
const countAfterFirstDelete = await panel.getSegmentCount();
expect(countAfterFirstDelete, 'Expected 3 segments after first delete').toBe(3);
await expect(panel.rows, 'Expected 3 segments after first delete').toHaveCount(3);
await panel.nthSegment(0).actions.delete();
const countAfterSecondDelete = await panel.getSegmentCount();
expect(countAfterSecondDelete, 'Expected 2 segments after second delete').toBe(2);
await expect(panel.rows, 'Expected 2 segments after second delete').toHaveCount(2);
await expect(
panel.getSegmentLabels().filter({ hasText: defaultSegment0Name }),

View File

@ -25,19 +25,20 @@ test('should duplicate a contour segment and add a new row to the panel', async
}) => {
const panel = rightPanelPageObject.contourSegmentationPanel.panel;
const initialCount = await panel.getSegmentCount();
expect(initialCount, 'Expected to load with 4 segments').toBe(4);
await expect(panel.rows, 'Expected to load with 4 segments').toHaveCount(4);
const segment0 = panel.nthSegment(0);
await expect(segment0.title).toHaveText(defaultSegment0Name);
await segment0.actions.duplicate();
const countAfterDuplicate = await panel.getSegmentCount();
expect(countAfterDuplicate, 'Expected one additional segment row after duplicating').toBe(5);
await expect(
panel.rows,
'Expected one additional segment row after duplicating'
).toHaveCount(5);
//New segment's default name is formatted as "Segment {segmentCount}"
const newSegmentLocator = panel.nthSegment(initialCount).title;
const newSegmentLocator = panel.nthSegment(4).title;
await expect(newSegmentLocator, 'Expected correct title for duplicated segment').toHaveText(
`Segment 5`
);
@ -53,10 +54,10 @@ test('should duplicate the same segment multiple times', async ({ rightPanelPage
const segment0 = panel.nthSegment(0);
await segment0.actions.duplicate();
expect(
await panel.getSegmentCount(),
await expect(
panel.rows,
'Expected one additional segment row after duplicating'
).toBe(5);
).toHaveCount(5);
const firstDuplicateTitleLocator = panel.nthSegment(4).title;
await expect(
@ -65,10 +66,10 @@ test('should duplicate the same segment multiple times', async ({ rightPanelPage
).toHaveText(`Segment 5`);
await segment0.actions.duplicate();
expect(
await panel.getSegmentCount(),
await expect(
panel.rows,
'Expected another segment row after duplicating the same segment again'
).toBe(6);
).toHaveCount(6);
const secondDuplicateTitleLocator = panel.nthSegment(5).title;
await expect(

View File

@ -34,7 +34,7 @@ test('should fully remove segmentation overlay after repeated load-and-delete cy
await rightPanelPageObject.labelMapSegmentationPanel.panel.moreMenu.delete();
await viewportRenderCycle;
expect(await rightPanelPageObject.labelMapSegmentationPanel.panel.getSegmentCount()).toBe(0);
await expect(rightPanelPageObject.labelMapSegmentationPanel.panel.rows).toHaveCount(0);
// reload SEG series
viewportRenderCycle = waitForViewportRenderCycle(page);
@ -57,7 +57,7 @@ test('should fully remove segmentation overlay after repeated load-and-delete cy
await rightPanelPageObject.labelMapSegmentationPanel.panel.moreMenu.delete();
await viewportRenderCycle;
expect(await rightPanelPageObject.labelMapSegmentationPanel.panel.getSegmentCount()).toBe(0);
await expect(rightPanelPageObject.labelMapSegmentationPanel.panel.rows).toHaveCount(0);
await checkForScreenshot(
page,

View File

@ -23,7 +23,8 @@ test.beforeEach(
);
test('should list segments in side panel for 3D only view', async ({ rightPanelPageObject }) => {
const numberOfSegments =
await rightPanelPageObject.labelMapSegmentationPanel.panel.getSegmentCount();
expect(numberOfSegments, 'The side panel should list 13 segments for the 3D only view.').toBe(13);
await expect(
rightPanelPageObject.labelMapSegmentationPanel.panel.rows,
'The side panel should list 13 segments for the 3D only view.'
).toHaveCount(13);
});