fix(segmentation): Lock all rehydrated segmentation segments when panelSegmentation.disableEditing is true. (#5503)
* fix(segmentation): Lock all rehydrated segmentation segments when panelSegmentation.disableEditing is true. * PR feedback. * PR feedback. * Added tests for disableEditing and utilities for simulating drag operations. * Update bun.lock file after merging master.
This commit is contained in:
1 parent
3e1d50c8d2
commit
170e860aa1
23 files changed
+625
-242
No files matched your search
@@ -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`);
|
||||
};
|
||||
@@ -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',
|
||||
},
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
Reference in new issue
Block a user