2026-07-07 15:30:27 -04:00
|
|
|
import type { Page } from '@playwright/test';
|
|
|
|
|
|
|
|
|
|
type VisitStudyOptions = {
|
|
|
|
|
mode?: string;
|
|
|
|
|
delay?: number;
|
|
|
|
|
datasources?: string;
|
|
|
|
|
customization?: string;
|
|
|
|
|
};
|
2024-05-21 14:48:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Visit the study
|
|
|
|
|
* @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
|
2024-06-05 13:09:53 -04:00
|
|
|
* @param delay - The delay to wait after visiting the study
|
2024-07-09 11:13:07 -04:00
|
|
|
* @param datasources - the data source to load the study from
|
2024-05-21 14:48:35 -04:00
|
|
|
*/
|
2026-07-07 15:30:27 -04:00
|
|
|
export async function visitStudyOptions(
|
2024-06-05 13:09:53 -04:00
|
|
|
page: Page,
|
|
|
|
|
studyInstanceUID: string,
|
2026-07-07 15:30:27 -04:00
|
|
|
options: VisitStudyOptions = {}
|
2024-06-05 13:09:53 -04:00
|
|
|
) {
|
2026-07-07 15:30:27 -04:00
|
|
|
const mode = options.mode || 'viewer';
|
|
|
|
|
const resolvedDelay = options.delay ?? 0;
|
|
|
|
|
const resolvedDatasources = options.datasources || 'ohif';
|
|
|
|
|
const { customization } = options;
|
|
|
|
|
|
2025-01-29 13:36:52 -05:00
|
|
|
// await page.goto(`/?resultsPerPage=100&datasources=${datasources}`);
|
|
|
|
|
// await page.getByTestId(studyInstanceUID).click();
|
|
|
|
|
// await page.getByRole('button', { name: mode }).click();
|
2026-07-07 15:30:27 -04:00
|
|
|
// studyInstanceUID may itself carry extra query params appended with `&`
|
|
|
|
|
// (e.g. `<uid>&hangingprotocolid=mpr`), so concatenate it raw rather than
|
|
|
|
|
// running it through URLSearchParams, which would percent-encode the `&`/`=`
|
|
|
|
|
// and collapse everything into a single invalid StudyInstanceUIDs value.
|
|
|
|
|
let url = `/${mode}/${resolvedDatasources}?StudyInstanceUIDs=${studyInstanceUID}`;
|
|
|
|
|
if (customization) {
|
|
|
|
|
url += `&customization=${encodeURIComponent(customization)}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await page.goto(url);
|
2024-05-21 14:48:35 -04:00
|
|
|
await page.waitForLoadState('domcontentloaded');
|
|
|
|
|
await page.waitForLoadState('networkidle');
|
2026-07-07 15:30:27 -04:00
|
|
|
await page.waitForTimeout(resolvedDelay);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function visitStudy(
|
|
|
|
|
page: Page,
|
|
|
|
|
studyInstanceUID: string,
|
|
|
|
|
mode = 'viewer',
|
|
|
|
|
delay: number = 0,
|
|
|
|
|
datasources = 'ohif'
|
|
|
|
|
) {
|
|
|
|
|
return visitStudyOptions(page, studyInstanceUID, {
|
|
|
|
|
mode,
|
|
|
|
|
delay,
|
|
|
|
|
datasources,
|
|
|
|
|
});
|
2024-05-21 14:48:35 -04:00
|
|
|
}
|