Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions tests/e2e/portal/3D_Anatomical.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,29 @@ async function runTutorial () {
const studyData = await tutorial.openStudyLink();

const workbenchData = utils.extractWorkbenchData(studyData["data"]);
const vtkNodeId = workbenchData["nodeIds"][1];
await tutorial.waitForServices(
workbenchData["studyId"],
[workbenchData["nodeIds"][1]],
[vtkNodeId],
startTimeout,
false
);

await tutorial.waitFor(10000, 'Some time for starting the service');
await utils.takeScreenshot(page, screenshotPrefix + 'service_started');

// This study opens in fullscreen mode
await tutorial.restoreIFrame();

const outFiles = [
"data.zip"
const iframe = await tutorial.getIframe(vtkNodeId);
const entitiesListed = [
"Vein.vtk",
"Artery.vtk",
"Bones.e",
];
await tutorial.checkNodeOutputs(1, outFiles);
for (const text of entitiesListed) {
const found = await utils.waitForLabelText(iframe, text);
if (!found) {
throw new Error(`Text "${text}" not visible on the page within timeout.`);
}
}
}
catch(err) {
await tutorial.setTutorialFailed();
Expand Down
19 changes: 12 additions & 7 deletions tests/e2e/portal/3D_EM.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,28 @@ async function runTutorial () {
const studyData = await tutorial.openStudyLink();

const workbenchData = utils.extractWorkbenchData(studyData["data"]);
const vtkNodeId = workbenchData["nodeIds"][2];
await tutorial.waitForServices(
workbenchData["studyId"],
[workbenchData["nodeIds"][2]],
[vtkNodeId],
startTimeout,
false
);

await tutorial.waitFor(10000, 'Some time for starting the service');
await utils.takeScreenshot(page, screenshotPrefix + 'service_started');

// This study opens in fullscreen mode
await tutorial.restoreIFrame();

const outFiles = [
"data.zip"
const iframe = await tutorial.getIframe(vtkNodeId);
const entitiesListed = [
"EM_02mm.vtk",
"CellDatatoPointData1",
];
await tutorial.checkNodeOutputs(2, outFiles);
for (const text of entitiesListed) {
const found = await utils.waitForLabelText(iframe, text);
if (!found) {
throw new Error(`Text "${text}" not visible on the page within timeout.`);
}
}
}
catch(err) {
await tutorial.setTutorialFailed();
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,31 @@ async function getButtonsWithText(page, text) {
return buttons;
}

async function waitForLabelText(page, text, timeout = 10000) {
console.log("Waiting for label text:", text);
try {
await page.waitForFunction(
(text) => {
return [...document.body.querySelectorAll('*')].some(el => {
if (typeof el.innerText !== 'string') return false;

const lines = el.innerText.split('\n').map(line => line.trim());
return lines.some(line =>
line.includes(text) &&
!!(el.offsetWidth || el.offsetHeight || el.getClientRects().length)
);
});
},
{ timeout },
text
);
return true;
} catch (err) {
console.error("waitForLabelText failed:", err);
return false;
}
}


module.exports = {
makeRequest,
Expand Down Expand Up @@ -671,4 +696,5 @@ module.exports = {
isElementVisible,
clickLoggerTitle,
getButtonsWithText,
waitForLabelText,
}
Loading