Test: Playwright tests for tmtv (#4331)

Co-authored-by: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com>
Co-authored-by: Ibrahim <ibrahim.mdev@gmail.com>
This commit is contained in:
authored and GitHub committed 2024-08-15 21:57:04 -04:00
1 parent 4068488bb2
commit b2c0faf29d
13 files changed
+294 -13

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
const getTMTVModalityUnit = async (page, attempts = 20) => {
for (let i = 0; i < attempts; i++) {
try {
const modalityUnit = await page.evaluate(
({ cornerstoneTools }: AppTypes.Test) => {
const annotations = cornerstoneTools.annotation.state.getAllAnnotations();
const stats = annotations[0].data.cachedStats;
const targetIds = Object.keys(stats);
const targetStats = stats[targetIds[1]];
return targetStats.modalityUnit;
},
await page.evaluateHandle('window')
);
if (modalityUnit) {
return modalityUnit;
}
} catch (error) {
console.error('Failed to get modalityUnit', error);
}
await new Promise(resolve => setTimeout(resolve, 1000));
}
throw new Error('Failed to get modalityUnit after multiple attempts');
};
export { getTMTVModalityUnit };