tests(increase-coverage): weekly tests PR (#4202)
This commit is contained in:
1 parent
f93cdf326d
commit
9f8ad28d71
27 files changed
+382
-39
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { visitStudy } from './visitStudy';
|
||||
import { checkForScreenshot } from './checkForScreenshot';
|
||||
import { screenShotPaths } from './screenShotPaths';
|
||||
import { simulateDrag } from './simulateDrag';
|
||||
import { simulateClicksOnElement } from './simulateClicksOnElement';
|
||||
|
||||
export { visitStudy, checkForScreenshot, screenShotPaths, simulateDrag };
|
||||
export { visitStudy, checkForScreenshot, screenShotPaths, simulateClicksOnElement };
|
||||
@@ -2,12 +2,39 @@
|
||||
* Paths to the screenshots of the tests.
|
||||
*/
|
||||
const screenShotPaths = {
|
||||
mpr: {
|
||||
mprDisplayedCorrectly: 'mprDisplayedCorrectly.png',
|
||||
angle: {
|
||||
angleDisplayedCorrectly: 'angleDisplayedCorrectly.png',
|
||||
},
|
||||
bidirectional: {
|
||||
bidirectionalDisplayedCorrectly: 'bidirectionalDisplayedCorrectly.png',
|
||||
},
|
||||
circle: {
|
||||
circleDisplayedCorrectly: 'circleDisplayedCorrectly.png',
|
||||
},
|
||||
cobbangle: {
|
||||
cobbangleDisplayedCorrectly: 'cobbangleDisplayedCorrectly.png',
|
||||
},
|
||||
ellipse: {
|
||||
ellipseDisplayedCorrectly: 'ellipseDisplayedCorrectly.png',
|
||||
},
|
||||
length: {
|
||||
lengthDisplayedCorrectly: 'lengthDisplayedCorrectly.png',
|
||||
},
|
||||
livewire: {
|
||||
livewireDisplayedCorrectly: 'livewireDisplayedCorrectly.png',
|
||||
},
|
||||
mpr: {
|
||||
mprDisplayedCorrectly: 'mprDisplayedCorrectly.png',
|
||||
},
|
||||
probe: {
|
||||
probeDisplayedCorrectly: 'probeDisplayedCorrectly.png',
|
||||
},
|
||||
rectangle: {
|
||||
rectangleDisplayedCorrectly: 'rectangleDisplayedCorrectly.png',
|
||||
},
|
||||
spline: {
|
||||
splineDisplayedCorrectly: 'splineDisplayedCorrectly.png',
|
||||
},
|
||||
};
|
||||
|
||||
export { screenShotPaths };
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Locator } from 'playwright';
|
||||
|
||||
/**
|
||||
*
|
||||
* @parm locator - The locator to click on
|
||||
* @param points - The points to click on
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
export async function simulateClicksOnElement({
|
||||
locator,
|
||||
points,
|
||||
}: {
|
||||
locator: Locator;
|
||||
points: { x: number; y: number }[];
|
||||
}) {
|
||||
for (const { x, y } of points) {
|
||||
await locator.click({ delay: 100, position: { x, y } });
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Locator, Page } from 'playwright';
|
||||
|
||||
/**
|
||||
*
|
||||
* @param page - The page to simulate the drag on
|
||||
* @param locator - The locator of the element to perform the drag on
|
||||
*/
|
||||
|
||||
export async function simulateDrag(page: Page, locator: Locator) {
|
||||
const box = await locator.boundingBox();
|
||||
if (!box) {
|
||||
throw new Error('Element is not visible');
|
||||
}
|
||||
const { x, y, width, height } = box;
|
||||
const centerX = x + width / 2;
|
||||
const centerY = y + height / 2;
|
||||
|
||||
// Calculate the maximum possible movement distances within the element's bounds
|
||||
const maxMoveX = Math.min(100, x + width - centerX);
|
||||
const maxMoveY = Math.min(100, y + height - centerY);
|
||||
|
||||
const newX = centerX + maxMoveX;
|
||||
const newY = centerY + maxMoveY;
|
||||
|
||||
await page.mouse.move(centerX, centerY);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(newX, newY);
|
||||
await page.mouse.up();
|
||||
}
|
||||
@@ -5,12 +5,19 @@ import { Page } from '@playwright/test';
|
||||
* @param page - The page to interact with
|
||||
* @param title - The study instance UID of the study to visit
|
||||
* @param mode - The mode to visit the study in
|
||||
* @param delay - The delay to wait after visiting the study
|
||||
*/
|
||||
export async function visitStudy(page: Page, studyInstanceUID: string, mode: string) {
|
||||
export async function visitStudy(
|
||||
page: Page,
|
||||
studyInstanceUID: string,
|
||||
mode: string,
|
||||
delay: number = 0
|
||||
) {
|
||||
await page.goto('/?resultsPerPage=100');
|
||||
await page.getByTestId('confirm-and-hide-button').click();
|
||||
await page.getByTestId(studyInstanceUID).click();
|
||||
await page.getByRole('button', { name: mode }).click();
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForTimeout(delay);
|
||||
}
|
||||
Reference in new issue
Block a user