chore: 3.11 Recovery 1 (#5514)

This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2025-10-28 09:48:32 -04:00
1 parent 522531cc5c
commit 93dabb3805
147 files changed
+2948 -5922

No files matched your search

+144
View File
@@ -0,0 +1,144 @@
import { test, expect } from 'playwright-test-coverage';
import { visitStudy } from './utils';
import { viewportSVGPathLocator } from './utils/locators';
import { simulateNormalizedDragOnElement } from './utils/simulateDragOnElement';
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
test('should not allow contours to be edited in basic viewer mode', async ({ page }) => {
const mode = 'viewer';
await visitStudy(page, studyInstanceUID, mode, 2000);
await page.getByTestId('side-panel-header-right').click();
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
await page.getByTestId('yes-hydrate-btn').click();
// Wait for the segmentation to hydrate.
await page.waitForTimeout(5000);
const svgPathLocatorPreEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPreEdit.count(),
'Expected exactly 1 path element in the viewport'
).toBe(1);
const expectedPathCommands = await svgPathLocatorPreEdit.getAttribute('d');
// Try to drag one of the edges of the rectangular contour.
await simulateNormalizedDragOnElement({
locator: svgPathLocatorPreEdit,
start: { x: 0.1, y: 0 },
end: { x: 0.1, y: -0.2 },
});
const svgPathLocatorPostEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPostEdit.getAttribute('d'),
'Expected the path commands to be the same as the pre-edit path commands'
).toBe(expectedPathCommands);
});
test('should not allow contours to be edited when panelSegmentation.disableEditing is true', async ({
page,
}) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await page.getByTestId('side-panel-header-right').click();
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
// disable editing of segmentations via the customization service
await page.evaluate(() => {
window.services.customizationService.setGlobalCustomization(
'panelSegmentation.disableEditing',
{
$set: true,
}
);
});
await page.getByTestId('yes-hydrate-btn').click();
// Wait for the segmentation to hydrate.
await page.waitForTimeout(5000);
const svgPathLocatorPreEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPreEdit.count(),
'Expected exactly 1 path element in the viewport'
).toBe(1);
const expectedPathCommands = await svgPathLocatorPreEdit.getAttribute('d');
// Try to drag one of the edges of the rectangular contour.
await simulateNormalizedDragOnElement({
locator: svgPathLocatorPreEdit,
start: { x: 0.1, y: 0 },
end: { x: 0.1, y: -0.2 },
});
const svgPathLocatorPostEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPostEdit.getAttribute('d'),
'Expected the path commands to be the same as the pre-edit path commands'
).toBe(expectedPathCommands);
});
test('should allow contours to be edited when panelSegmentation.disableEditing is false', async ({
page,
}) => {
const mode = 'segmentation';
await visitStudy(page, studyInstanceUID, mode, 2000);
await page.getByTestId('side-panel-header-right').click();
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
// disable editing of segmentations via the customization service
await page.evaluate(() => {
window.services.customizationService.setGlobalCustomization(
'panelSegmentation.disableEditing',
{
$set: false,
}
);
});
await page.getByTestId('yes-hydrate-btn').click();
// Wait for the segmentation to hydrate.
await page.waitForTimeout(5000);
const svgPathLocatorPreEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPreEdit.count(),
'Expected exactly 1 path element in the viewport'
).toBe(1);
const preEditPathCommands = await svgPathLocatorPreEdit.getAttribute('d');
// Try to drag one of the edges of the rectangular contour.
await simulateNormalizedDragOnElement({
locator: svgPathLocatorPreEdit,
start: { x: 0.1, y: 0 },
end: { x: 0.1, y: -0.2 },
});
const svgPathLocatorPostEdit = viewportSVGPathLocator({ page, viewportId: 'default' });
expect(
await svgPathLocatorPostEdit.getAttribute('d'),
'Not expecting the path commands to be the same as the pre-edit path commands'
).not.toBe(preEditPathCommands);
});
+118
View File
@@ -0,0 +1,118 @@
import { test } from 'playwright-test-coverage';
import { visitStudy, checkForScreenshot, screenShotPaths } from './utils';
import { press } from './utils/keyboardUtils';
import { simulateNormalizedDragOnElement } from './utils/simulateDragOnElement';
import { viewportLocator } from './utils/locators';
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,
}) => {
// disable editing of segmentations via the customization service
await page.evaluate(() => {
window.services.customizationService.setGlobalCustomization(
'panelSegmentation.disableEditing',
{
$set: true,
}
);
});
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
await page.getByTestId('yes-hydrate-btn').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, page, screenShotPaths.labelMapSegLocking.globalLockedSegPreEdit);
// Attempt to erase the segmentations.
await page.getByTestId('Eraser-btn').click();
// Use the largest eraser radius to help ensure the entire image is erased.
await page.locator(`css=div[data-cy="eraser-radius"] input`).fill('1000');
// Attempt to erase the segmentations by dragging the eraser tool across the image several times.
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.25 },
end: { x: 1.0, y: 0.25 },
});
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.5 },
end: { x: 1.0, y: 0.5 },
});
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.75 },
end: { x: 1.0, y: 0.75 },
});
await checkForScreenshot(page, page, screenShotPaths.labelMapSegLocking.globalLockedSegPostEdit);
});
test('should allow editing of label map segmentations when panelSegmentation.disableEditing is false', async ({
page,
}) => {
// disable editing of segmentations via the customization service
await page.evaluate(() => {
window.services.customizationService.setGlobalCustomization(
'panelSegmentation.disableEditing',
{
$set: false,
}
);
});
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
// Wait for the segmentation to be loaded.
await page.waitForTimeout(5000);
await page.getByTestId('yes-hydrate-btn').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, page, screenShotPaths.labelMapSegLocking.globalUnlockedSegPreEdit);
// Attempt to erase the segmentations.
await page.getByTestId('Eraser-btn').click();
// Use the largest eraser radius to help ensure the eraser passes over the entire image.
await page.locator(`css=div[data-cy="eraser-radius"] input`).fill('1000');
// Attempt to erase the segmentations by dragging the eraser tool across the image several times.
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.25 },
end: { x: 1.0, y: 0.25 },
});
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.5 },
end: { x: 1.0, y: 0.5 },
});
await simulateNormalizedDragOnElement({
locator: viewportLocator({ page, viewportId: 'default' }),
start: { x: 0.01, y: 0.75 },
end: { x: 1.0, y: 0.75 },
});
await checkForScreenshot(
page,
page,
screenShotPaths.labelMapSegLocking.globalUnlockedSegPostEdit
);
});
+1 -1
View File
@@ -16,7 +16,7 @@ test('should launch MPR with unhydrated RTSTRUCT chosen from the data overlay me
await page.getByTestId('MPR').click();
// Wait 5 seconds for MPR to load. This is necessary in particular when screen shots are added or replaced.
await page.waitForTimeout(5000);
await page.waitForTimeout(10000);
await checkForScreenshot(
page,
+5
View File
@@ -10,9 +10,14 @@ test.beforeEach(async ({ page }) => {
test('should hydrate RT reports correctly', async ({ page }) => {
await page.getByTestId('side-panel-header-right').click();
await page.getByTestId('study-browser-thumbnail-no-image').dblclick();
await page.waitForTimeout(5000);
await checkForScreenshot(page, page, screenShotPaths.rtHydration.rtPreHydration);
await page.getByTestId('yes-hydrate-btn').click();
await page.waitForTimeout(5000);
await checkForScreenshot(page, page, screenShotPaths.rtHydration.rtPostHydration);
await page.getByText('Small Sphere').click();
await page.waitForTimeout(5000);
await checkForScreenshot(page, page, screenShotPaths.rtHydration.rtJumpToStructure);
});
+1 -1
View File
@@ -13,7 +13,7 @@ test('should hydrate an RTSTRUCT from MPR', async ({ page }) => {
await page.getByTestId('Layout').click();
await page.getByTestId('MPR').click();
await page.waitForTimeout(5000);
await page.waitForTimeout(10000);
await checkForScreenshot(page, page, screenShotPaths.rtHydrationFromMPR.mprBeforeRT);
+14 -5
View File
@@ -2,6 +2,7 @@ import { test, expect } from 'playwright-test-coverage';
import { visitStudy, simulateNormalizedClickOnElement } from './utils/index';
import { viewportLocator } from './utils/locators';
import { downloadAsString } from './utils/download';
import toArray from 'extensions/dicom-microscopy/src/utils/toArray';
test('should create and download the TMTV CSV report correctly', async ({ page }) => {
const studyInstanceUID = '1.2.840.113619.2.290.3.3767434740.226.1600859119.501';
@@ -26,14 +27,22 @@ test('should create and download the TMTV CSV report correctly', async ({ page }
'202009231_tmtv.csv'
);
const tmtvCSVReportContent = await downloadAsString(download);
const tmtvCSVReportContent: string = await downloadAsString(download);
const expectedHeaders =
'PatientID,PatientName,SeriesInstanceUID,StudyDate,StudyInstanceUID,center,count,id,kurtosis,label,lesionGlycolysis,max,maxLPS,mean,median,min,minLPS,peakLPS,peakValue,skewness,stdDev,volume';
const tmtvCSVReportHeaders = tmtvCSVReportContent
.substring(0, expectedHeaders.length)
.split(',')
.sort()
.join(',');
expect(
tmtvCSVReportContent,
tmtvCSVReportHeaders,
'Expected the file to start with specific column/value headers'
).toMatch(
/^id,label,min,max,mean,stdDev,median,skewness,kurtosis,count,maxLPS,minLPS,center,volume,peakValue,peakLPS,lesionGlycolysis,PatientID,PatientName,StudyInstanceUID,SeriesInstanceUID,StudyDate/
);
).toBe(expectedHeaders);
expect(tmtvCSVReportContent, 'Expected the patient name to be present').toContain(
'Water Phantom'
);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 KiB

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 KiB

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 271 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 270 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 259 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 254 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 284 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 KiB

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 KiB

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 KiB

After

Width:  |  Height:  |  Size: 459 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 KiB

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 319 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 KiB

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 343 KiB

+1 -1
View File
@@ -1,6 +1,6 @@
import { Readable } from 'stream';
const _streamToString = async (stream: Readable) => {
const _streamToString = async (stream: Readable): Promise<string> => {
return new Promise((resolve, reject) => {
const chunks = [];
stream.on('data', chunk => chunks.push(chunk));
+20
View File
@@ -9,3 +9,23 @@ export const viewportLocator = ({
}): Locator => {
return page.locator(`css=div[data-viewportid="${viewportId}"]`);
};
export const viewportSVGLocator = ({
page,
viewportId,
}: {
page: Page;
viewportId: string;
}): Locator => {
return page.locator(`css=div[data-viewportid="${viewportId}"] svg`);
};
export const viewportSVGPathLocator = ({
page,
viewportId,
}: {
page: Page;
viewportId: string;
}): Locator => {
return page.locator(`css=div[data-viewportid="${viewportId}"] svg path`);
};
+6
View File
@@ -26,6 +26,12 @@ const screenShotPaths = {
ellipse: {
ellipseDisplayedCorrectly: 'ellipseDisplayedCorrectly.png',
},
labelMapSegLocking: {
globalLockedSegPreEdit: 'lockedSegPreEdit.png',
globalLockedSegPostEdit: 'lockedSegPostEdit.png',
globalUnlockedSegPreEdit: 'unlockedSegPreEdit.png',
globalUnlockedSegPostEdit: 'unlockedSegPostEdit.png',
},
length: {
lengthDisplayedCorrectly: 'lengthDisplayedCorrectly.png',
},
+67
View File
@@ -0,0 +1,67 @@
import { Locator } from 'playwright';
/**
* Simulates a drag operation on an element using normalized coordinates.
*
* @param locator - The locator to drag on.
* @param start - The start point with x and y coordinates, normalized to the element's bounding box.
* @param end - The end point with x and y coordinates, normalized to the element's bounding box.
* @param button - The mouse button to use for the drag (default is 'left').
* @param delay - Milliseconds between steps (default is 50).
* @param steps - Number of intermediate positions for smooth dragging (default is 5).
*/
export async function simulateNormalizedDragOnElement({
locator,
start,
end,
button = 'left',
delay = 50,
steps = 10,
}: {
locator: Locator;
start: { x: number; y: number };
end: { x: number; y: number };
button?: 'left' | 'right' | 'middle';
delay?: number;
steps?: number;
}) {
const bBox = await locator.boundingBox();
if (!bBox) {
throw new Error('Element bounding box not found');
}
const startPosition = {
x: bBox.x + start.x * bBox.width,
y: bBox.y + start.y * bBox.height,
};
const endPosition = {
x: bBox.x + end.x * bBox.width,
y: bBox.y + end.y * bBox.height,
};
// Get the page from the locator context
const page = locator.page();
page.mouse.move(startPosition.x, startPosition.y);
// Start drag
await page.mouse.down({ button });
// Calculate intermediate positions for smooth dragging
const deltaX = (endPosition.x - startPosition.x) / steps;
const deltaY = (endPosition.y - startPosition.y) / steps;
// Move through intermediate positions
for (let i = 1; i <= steps; i++) {
const currentX = startPosition.x + deltaX * i;
const currentY = startPosition.y + deltaY * i;
// Add delay if specified
if (delay > 0) {
await page.waitForTimeout(delay);
}
await page.mouse.move(currentX, currentY);
}
// End drag
await page.mouse.up({ button });
}