chore(test): add FreehandROI test that MEASUREMENT_ADDED does not fire when clicking annotation text (#5846)
This commit is contained in:
parent
c9dea4e6cc
commit
92011c587f
34
tests/FreehandROI.spec.ts
Normal file
34
tests/FreehandROI.spec.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { expect, test, visitStudy, subscribeToMeasurementAdded } from './utils';
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
const studyInstanceUID = '1.3.6.1.4.1.25403.345050719074.3824.20170125095438.5';
|
||||||
|
const mode = 'viewer';
|
||||||
|
await visitStudy(page, studyInstanceUID, mode, 2000);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not fire MEASUREMENT_ADDED when clicking the annotation text', async ({
|
||||||
|
page,
|
||||||
|
DOMOverlayPageObject,
|
||||||
|
mainToolbarPageObject,
|
||||||
|
viewportPageObject,
|
||||||
|
}) => {
|
||||||
|
await mainToolbarPageObject.measurementTools.freehandROI.click();
|
||||||
|
await viewportPageObject.active.normalizedDragAt({
|
||||||
|
start: { x: 0.35, y: 0.35 },
|
||||||
|
end: { x: 0.6, y: 0.55 },
|
||||||
|
config: { steps: 20, delay: 30 },
|
||||||
|
});
|
||||||
|
|
||||||
|
await DOMOverlayPageObject.viewport.measurementTracking.confirm.click();
|
||||||
|
|
||||||
|
const measurementAdded = await subscribeToMeasurementAdded(page);
|
||||||
|
try {
|
||||||
|
const annotation = viewportPageObject.active.nthAnnotation(0);
|
||||||
|
await annotation.text.click();
|
||||||
|
|
||||||
|
await expect(measurementAdded.waitFired(1000)).rejects.toThrow();
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
await measurementAdded.unsubscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -194,6 +194,17 @@ export class MainToolbarPageObject {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get freehandROI() {
|
||||||
|
const button = page.getByTestId('PlanarFreehandROI');
|
||||||
|
return {
|
||||||
|
button,
|
||||||
|
async click() {
|
||||||
|
await measurementTools.click();
|
||||||
|
await button.click();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,10 @@ export interface IViewportPageObject {
|
|||||||
contextMenu: {
|
contextMenu: {
|
||||||
open: () => Promise<void>;
|
open: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
text: {
|
||||||
|
locator: Locator;
|
||||||
|
click: () => Promise<void>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
clickAt: (
|
clickAt: (
|
||||||
points: { x: number; y: number }[],
|
points: { x: number; y: number }[],
|
||||||
@ -75,6 +79,7 @@ export class ViewportPageObject {
|
|||||||
const page = this.page;
|
const page = this.page;
|
||||||
const domOverlayPageObject = new DOMOverlayPageObject(page);
|
const domOverlayPageObject = new DOMOverlayPageObject(page);
|
||||||
const annotation = viewport.locator('g[data-annotation-uid]').nth(nth);
|
const annotation = viewport.locator('g[data-annotation-uid]').nth(nth);
|
||||||
|
const textLocator = annotation.locator('text').first();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
locator: annotation,
|
locator: annotation,
|
||||||
@ -86,6 +91,12 @@ export class ViewportPageObject {
|
|||||||
await domOverlayPageObject.viewport.annotationContextMenu.open(annotation);
|
await domOverlayPageObject.viewport.annotationContextMenu.open(annotation);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
text: {
|
||||||
|
locator: textLocator,
|
||||||
|
click: async () => {
|
||||||
|
await textLocator.click({ force: true });
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { scrollVolumeViewport } from './scrollVolumeViewport';
|
|||||||
import { attemptAction } from './attemptAction';
|
import { attemptAction } from './attemptAction';
|
||||||
import { addLengthMeasurement } from './addLengthMeasurement';
|
import { addLengthMeasurement } from './addLengthMeasurement';
|
||||||
import { test, expect } from './fixture';
|
import { test, expect } from './fixture';
|
||||||
|
import { subscribeToMeasurementAdded } from './subscribeToMeasurement';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
visitStudy,
|
visitStudy,
|
||||||
@ -36,6 +37,7 @@ export {
|
|||||||
scrollVolumeViewport,
|
scrollVolumeViewport,
|
||||||
attemptAction,
|
attemptAction,
|
||||||
addLengthMeasurement,
|
addLengthMeasurement,
|
||||||
|
subscribeToMeasurementAdded,
|
||||||
test,
|
test,
|
||||||
expect,
|
expect,
|
||||||
};
|
};
|
||||||
|
|||||||
34
tests/utils/subscribeToMeasurement.ts
Normal file
34
tests/utils/subscribeToMeasurement.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
export const subscribeToMeasurementAdded = async (page: any) => {
|
||||||
|
let measurementAddedFired = false;
|
||||||
|
let unsubscribeMeasurementAdded: () => void;
|
||||||
|
|
||||||
|
await page.evaluate(
|
||||||
|
({ services }: AppTypes.Test) => {
|
||||||
|
const { measurementService } = services;
|
||||||
|
|
||||||
|
const { unsubscribe } = measurementService.subscribe(
|
||||||
|
measurementService.EVENTS.MEASUREMENT_ADDED,
|
||||||
|
() => {
|
||||||
|
measurementAddedFired = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
unsubscribeMeasurementAdded = unsubscribe;
|
||||||
|
},
|
||||||
|
await page.evaluateHandle('window')
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
waitFired: async (timeout?: number) =>
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => measurementAddedFired === true,
|
||||||
|
timeout != null ? { timeout } : undefined
|
||||||
|
),
|
||||||
|
|
||||||
|
unsubscribe: async () => {
|
||||||
|
await page.evaluate(() => {
|
||||||
|
unsubscribeMeasurementAdded?.();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user