From 43192a27691b1c1fde63c8d2fd8394ae80de9e79 Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Thu, 8 Dec 2022 11:01:06 +0100 Subject: [PATCH] e2e: publications (#3650) --- tests/e2e/{portal => publications}/Voila.js | 43 ++++++++----- .../e2e/{tutorials => s4l}/sim4life-dipole.js | 6 +- .../sim4life-lite.js} | 4 +- tests/e2e/{tutorials => s4l}/sim4life.js | 2 +- tests/e2e/tutorials/mattward.js | 63 ------------------- tests/e2e/tutorials/ti-plan.js | 25 ++------ tests/e2e/tutorials/tutorialBase.js | 46 +++++++++++--- tests/e2e/utils/utils.js | 13 ++++ 8 files changed, 91 insertions(+), 111 deletions(-) rename tests/e2e/{portal => publications}/Voila.js (51%) rename tests/e2e/{tutorials => s4l}/sim4life-dipole.js (88%) rename tests/e2e/{tutorials/sim4life-light.js => s4l/sim4life-lite.js} (92%) rename tests/e2e/{tutorials => s4l}/sim4life.js (95%) delete mode 100644 tests/e2e/tutorials/mattward.js diff --git a/tests/e2e/portal/Voila.js b/tests/e2e/publications/Voila.js similarity index 51% rename from tests/e2e/portal/Voila.js rename to tests/e2e/publications/Voila.js index fcfecd3d721..f819a67e664 100644 --- a/tests/e2e/portal/Voila.js +++ b/tests/e2e/publications/Voila.js @@ -12,7 +12,7 @@ const { } = utils.parseCommandLineArgumentsTemplate(args); const anonURL = urlPrefix + templateUuid; -const screenshotPrefix = "Voila_"; +const screenshotPrefix = "Voila"; async function runTutorial () { @@ -25,25 +25,40 @@ async function runTutorial () { const workbenchData = utils.extractWorkbenchData(studyData["data"]); console.log("Workbench Data:", workbenchData); const voilaIdViewer = workbenchData["nodeIds"][0]; - await tutorial.waitForServices(workbenchData["studyId"], [voilaIdViewer], startTimeout); + await tutorial.waitForServices( + workbenchData["studyId"], + [voilaIdViewer], + startTimeout + ); - await tutorial.waitFor(40000, 'Some time for starting the service'); + await tutorial.waitFor(2000, 'Service started'); await utils.takeScreenshot(page, screenshotPrefix + 'service_started'); - const frame = await tutorial.getIframe(voilaIdViewer); - - // check title says "VISUALIZATION" - const titleSelector = '#VISUALIZATION'; - const element = await frame.$(titleSelector); - const titleText = await frame.evaluate(el => el.innerText, element); - console.log("titleText", titleText); - if (titleText !== "VISUALIZATION") { - throw new Error("Voila page title doesn't match the expected"); + const voilaTimeout = 240000; + const checkFrequency = 5000; + // wait for iframe to be ready, it might take a while in Voila + let iframe = null; + for (let i=0; i console.log("Voila started successfully")) + .catch(() => console.log("Voila page not found")); } catch(err) { - await tutorial.setTutorialFailed(true); + await tutorial.setTutorialFailed(true, false); console.log('Tutorial error: ' + err); } finally { diff --git a/tests/e2e/tutorials/sim4life-dipole.js b/tests/e2e/s4l/sim4life-dipole.js similarity index 88% rename from tests/e2e/tutorials/sim4life-dipole.js rename to tests/e2e/s4l/sim4life-dipole.js index 24cea764720..77e803d43e8 100644 --- a/tests/e2e/tutorials/sim4life-dipole.js +++ b/tests/e2e/s4l/sim4life-dipole.js @@ -1,7 +1,7 @@ // node sim4life-dipole.js [url] [user] [password] [timeout] [--demo] const utils = require('../utils/utils'); -const tutorialBase = require('./tutorialBase'); +const tutorialBase = require('../tutorials/tutorialBase'); const args = process.argv.slice(2); const { @@ -13,10 +13,10 @@ const { enableDemoMode } = utils.parseCommandLineArguments(args) -const studyName = "Dipole Antenna"; +const tutorialName = "Dipole Antenna"; async function runTutorial() { - const tutorial = new tutorialBase.TutorialBase(url, studyName, user, pass, newUser, enableDemoMode); + const tutorial = new tutorialBase.TutorialBase(url, tutorialName, user, pass, newUser, enableDemoMode); let studyId; try { await tutorial.start(); diff --git a/tests/e2e/tutorials/sim4life-light.js b/tests/e2e/s4l/sim4life-lite.js similarity index 92% rename from tests/e2e/tutorials/sim4life-light.js rename to tests/e2e/s4l/sim4life-lite.js index 8bc84e140c5..be4183639f5 100644 --- a/tests/e2e/tutorials/sim4life-light.js +++ b/tests/e2e/s4l/sim4life-lite.js @@ -1,7 +1,7 @@ -// node sim4life-light.js [url] [user] [password] [timeout] [--demo] +// node sim4life-lite.js [url] [user] [password] [timeout] [--demo] const utils = require('../utils/utils'); -const tutorialBase = require('./tutorialBase'); +const tutorialBase = require('../tutorials/tutorialBase'); const args = process.argv.slice(2); const { diff --git a/tests/e2e/tutorials/sim4life.js b/tests/e2e/s4l/sim4life.js similarity index 95% rename from tests/e2e/tutorials/sim4life.js rename to tests/e2e/s4l/sim4life.js index 758558f4ecb..46904bcf4ed 100644 --- a/tests/e2e/tutorials/sim4life.js +++ b/tests/e2e/s4l/sim4life.js @@ -1,7 +1,7 @@ // node sim4life.js [url] [user] [password] [timeout] [--demo] const utils = require('../utils/utils'); -const tutorialBase = require('./tutorialBase'); +const tutorialBase = require('../tutorials/tutorialBase'); const args = process.argv.slice(2); const { diff --git a/tests/e2e/tutorials/mattward.js b/tests/e2e/tutorials/mattward.js deleted file mode 100644 index b21a4716890..00000000000 --- a/tests/e2e/tutorials/mattward.js +++ /dev/null @@ -1,63 +0,0 @@ -// node mattward.js [url] [user] [password] [--demo] - -const utils = require('../utils/utils'); -const tutorialBase = require('./tutorialBase'); - -const args = process.argv.slice(2); -const { - url, - user, - pass, - newUser, - startTimeout, - enableDemoMode -} = utils.parseCommandLineArguments(args) - -const templateName = "Mattward"; - -async function runTutorial() { - const tutorial = new tutorialBase.TutorialBase(url, templateName, user, pass, newUser, enableDemoMode); - let studyId; - try { - await tutorial.start(); - const studyData = await tutorial.openTemplate(1000); - studyId = studyData["data"]["uuid"]; - - const workbenchData = utils.extractWorkbenchData(studyData["data"]); - await tutorial.waitForServices(workbenchData["studyId"], [workbenchData["nodeIds"][0]], startTimeout); - - await tutorial.waitFor(30000, 'Wait for the output files to be pushed'); - - // This study opens in fullscreen mode - await tutorial.restoreIFrame(); - - const outFiles = [ - "CAP_plot.csv", - "CV_plot.csv", - "Lpred_plot.csv", - "V_pred_plot.csv", - "input.csv", - "t_plot.csv", - "tst_plot.csv" - ]; - - await tutorial.checkNodeOutputs(0, outFiles); - } - catch(err) { - await tutorial.setTutorialFailed(true); - console.log('Tutorial error: ' + err); - } - finally { - await tutorial.leave(studyId); - } - - if (tutorial.getTutorialFailed()) { - throw "Tutorial Failed"; - } -} - -runTutorial() - .catch(error => { - console.log('Puppeteer error: ' + error); - process.exit(1); - }); diff --git a/tests/e2e/tutorials/ti-plan.js b/tests/e2e/tutorials/ti-plan.js index 8ccce863183..bb93f013979 100644 --- a/tests/e2e/tutorials/ti-plan.js +++ b/tests/e2e/tutorials/ti-plan.js @@ -44,7 +44,7 @@ async function runTutorial() { // wait for the three services, except the optimizer await tutorial.waitForServices( workbenchData["studyId"], - [esId, tiId, ppId], + [esId], startTimeout, false ); @@ -81,7 +81,7 @@ async function runTutorial() { // Load Post Pro Analysis await tutorial.takeScreenshot("postpro_start"); - await tutorial.waitFor(6000, "Load iframe"); + await tutorial.waitFor(20000, "Load iframe"); const postProIframe = await tutorial.getIframe(tiId); // Click "Load Analysis" button const buttonsLoadAnalysis = await utils.getButtonsWithText(postProIframe, "Load Analysis"); @@ -111,7 +111,7 @@ async function runTutorial() { await tutorial.takeScreenshot("postpro_export_report"); const outFiles = [ - "temp_ti_field.cache", + "output_1.zip", "TIP_report.pdf", "results.csv" ]; @@ -119,24 +119,7 @@ async function runTutorial() { // Check s4l await tutorial.waitAndClick("AppMode_NextBtn"); - await tutorial.waitFor(5000, "Starting s4l"); - await tutorial.takeScreenshot("s4l"); - const s4lIframe = await tutorial.getIframe(ppId); - await tutorial.waitAndClick('mode-button-postro', s4lIframe); - await tutorial.takeScreenshot("Postpro"); - const postProItems = await utils.getVisibleChildrenIDs(s4lIframe, '[osparc-test-id="tree-algorithm'); - const nLabels = postProItems.length; - if (nLabels > 1) { - postProItems[0].click(); - await tutorial.waitFor(2000, 'Importer clicked'); - await tutorial.takeScreenshot('ImporterClicked'); - postProItems[1].click(); - await tutorial.waitFor(2000, 'Algorithm clicked'); - await tutorial.takeScreenshot('AlgorithmClicked'); - } - else { - throw("Post Pro tree missing"); - } + await tutorial.testS4LTIPostPro(ppId); } catch (err) { // if it fails because the optimizer times out, close the "Preparing Inputs" view first diff --git a/tests/e2e/tutorials/tutorialBase.js b/tests/e2e/tutorials/tutorialBase.js index c68d2247b7f..afddcb82b6b 100644 --- a/tests/e2e/tutorials/tutorialBase.js +++ b/tests/e2e/tutorials/tutorialBase.js @@ -612,21 +612,53 @@ class TutorialBase { async testS4L(s4lNodeId) { await this.waitFor(20000, 'Wait for the splash screen to disappear'); - // do some basic interaction const s4lIframe = await this.getIframe(s4lNodeId); - await this.waitAndClick('tree-model', s4lIframe); - const modelItems = await s4lIframe.$$('.MuiTreeItem-label'); - const nLabels = modelItems.length; - if (nLabels > 1) { - modelItems[0].click(); + await this.waitAndClick('mode-button-modeling', s4lIframe); + await this.takeScreenshot("Modeling"); + const modelTrees = await utils.getChildrenElementsBySelector(s4lIframe, '[osparc-test-id="tree-model'); + if (modelTrees.length !== 1) { + throw("Model tree missing"); + } + + const children = await utils.getChildrenElements(modelTrees[0]); + const nItems = children.length; + if (nItems > 1) { + children[0].click(); await this.waitFor(2000, 'Model clicked'); await this.takeScreenshot('ModelClicked'); - modelItems[1].click(); + children[1].click(); await this.waitFor(2000, 'Grid clicked'); await this.takeScreenshot('GridlClicked'); } } + async testS4LTIPostPro(s4lNodeId) { + await this.waitFor(20000, 'Wait for the splash screen to disappear'); + await this.takeScreenshot("s4l"); + + const s4lIframe = await this.getIframe(s4lNodeId); + await this.waitAndClick('mode-button-postro', s4lIframe); + await this.takeScreenshot("Postpro"); + const algorithmTrees = await utils.getChildrenElementsBySelector(s4lIframe, '[osparc-test-id="tree-algorithm'); + if (algorithmTrees.length !== 1) { + throw("Post Pro tree missing"); + } + + const children = await utils.getChildrenElements(algorithmTrees[0]); + const nItems = children.length; + if (nItems > 1) { + children[0].click(); + await this.waitFor(2000, 'Importer clicked'); + await this.takeScreenshot('ImporterClicked'); + children[1].click(); + await this.waitFor(2000, 'Algorithm clicked'); + await this.takeScreenshot('AlgorithmClicked'); + } + else { + throw("Post Pro tree items missing"); + } + } + async testS4LDipole(s4lNodeId) { await this.waitFor(20000, 'Wait for the splash screen to disappear'); diff --git a/tests/e2e/utils/utils.js b/tests/e2e/utils/utils.js index e9d30d3f165..4525fac8a5a 100644 --- a/tests/e2e/utils/utils.js +++ b/tests/e2e/utils/utils.js @@ -111,6 +111,17 @@ function getDomain(url) { return url; } +async function getChildrenElements(element) { + const children = await element.$$(':scope > *'); + return children; +} + +async function getChildrenElementsBySelector(page, selector) { + const parent = await page.$(selector); + const children = await getChildrenElements(parent); + return children; +} + async function getNodeTreeItemIDs(page) { const childrenIDs = await page.evaluate((selector) => { const children = []; @@ -527,6 +538,8 @@ module.exports = { makeRequest, getUserAndPass, getDomain, + getChildrenElements, + getChildrenElementsBySelector, getNodeTreeItemIDs, getFileTreeItemIDs, getVisibleChildrenIDs,