diff --git a/tests/e2e/portal/3D_Anatomical.js b/tests/e2e/portal/3D_Anatomical.js index 058076011b23..bd495358ab9a 100644 --- a/tests/e2e/portal/3D_Anatomical.js +++ b/tests/e2e/portal/3D_Anatomical.js @@ -25,9 +25,10 @@ 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 ); @@ -35,13 +36,18 @@ async function runTutorial () { 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(); diff --git a/tests/e2e/portal/3D_EM.js b/tests/e2e/portal/3D_EM.js index 29d7482931f4..8473c059f87a 100644 --- a/tests/e2e/portal/3D_EM.js +++ b/tests/e2e/portal/3D_EM.js @@ -25,9 +25,10 @@ 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 ); @@ -35,13 +36,17 @@ async function runTutorial () { 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(); diff --git a/tests/e2e/utils/utils.js b/tests/e2e/utils/utils.js index 432264196151..bed942de1366 100644 --- a/tests/e2e/utils/utils.js +++ b/tests/e2e/utils/utils.js @@ -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, @@ -671,4 +696,5 @@ module.exports = { isElementVisible, clickLoggerTitle, getButtonsWithText, + waitForLabelText, }