From 95200ec6e896a7e94f0884b9872c4fe1aa36ad7d Mon Sep 17 00:00:00 2001 From: diattamo Date: Wed, 24 Jun 2026 11:05:27 -0400 Subject: [PATCH] test(segmentation): switch getSegmentCount to expect(rows).toHaveCount in panel specs (#6105) --- tests/ContourSegmentColorChange.spec.ts | 3 +-- tests/ContourSegmentDelete.spec.ts | 15 +++++---------- tests/ContourSegmentDuplicate.spec.ts | 23 ++++++++++++----------- tests/SEGHydrationDeleteAndReload.spec.ts | 4 ++-- tests/SEGHydrationThen3DOnly.spec.ts | 7 ++++--- 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/tests/ContourSegmentColorChange.spec.ts b/tests/ContourSegmentColorChange.spec.ts index 168c1dd6c..b2cb5b693 100644 --- a/tests/ContourSegmentColorChange.spec.ts +++ b/tests/ContourSegmentColorChange.spec.ts @@ -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 diff --git a/tests/ContourSegmentDelete.spec.ts b/tests/ContourSegmentDelete.spec.ts index 9008e600a..225a1ea4e 100644 --- a/tests/ContourSegmentDelete.spec.ts +++ b/tests/ContourSegmentDelete.spec.ts @@ -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 }), diff --git a/tests/ContourSegmentDuplicate.spec.ts b/tests/ContourSegmentDuplicate.spec.ts index d32e98602..7cd5f50b7 100644 --- a/tests/ContourSegmentDuplicate.spec.ts +++ b/tests/ContourSegmentDuplicate.spec.ts @@ -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( diff --git a/tests/SEGHydrationDeleteAndReload.spec.ts b/tests/SEGHydrationDeleteAndReload.spec.ts index 8a1701bad..e8a747949 100644 --- a/tests/SEGHydrationDeleteAndReload.spec.ts +++ b/tests/SEGHydrationDeleteAndReload.spec.ts @@ -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, diff --git a/tests/SEGHydrationThen3DOnly.spec.ts b/tests/SEGHydrationThen3DOnly.spec.ts index 809683a4c..be634c69b 100644 --- a/tests/SEGHydrationThen3DOnly.spec.ts +++ b/tests/SEGHydrationThen3DOnly.spec.ts @@ -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); });