Skip to content

Commit

Permalink
e2e: publications (#3650)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Dec 8, 2022
1 parent 1f4aa36 commit 43192a2
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 111 deletions.
43 changes: 29 additions & 14 deletions tests/e2e/portal/Voila.js → tests/e2e/publications/Voila.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
} = utils.parseCommandLineArgumentsTemplate(args);

const anonURL = urlPrefix + templateUuid;
const screenshotPrefix = "Voila_";
const screenshotPrefix = "Voila";


async function runTutorial () {
Expand All @@ -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<voilaTimeout; i+=checkFrequency) {
iframe = await tutorial.getIframe(voilaIdViewer);
if (iframe) {
break;
}
await tutorial.waitFor(checkFrequency, `iframe not ready yet: ${i/1000}s`);
}
await utils.takeScreenshot(page, screenshotPrefix + 'iFrame1');

// Voila says: "Ok, voila is still executing...". At this point we can only wait
await tutorial.waitFor(50000, "Load iframe");
await utils.takeScreenshot(page, screenshotPrefix + 'iFrame');

// look for "rendered_cells" which is the root div of a Voila document
await iframe.waitForSelector('#rendered_cells', {
timeout: 5000
})
.then(() => 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
63 changes: 0 additions & 63 deletions tests/e2e/tutorials/mattward.js

This file was deleted.

25 changes: 4 additions & 21 deletions tests/e2e/tutorials/ti-plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -111,32 +111,15 @@ async function runTutorial() {
await tutorial.takeScreenshot("postpro_export_report");

const outFiles = [
"temp_ti_field.cache",
"output_1.zip",
"TIP_report.pdf",
"results.csv"
];
await tutorial.checkNodeOutputsAppMode(tiId, outFiles, true);

// 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
Expand Down
46 changes: 39 additions & 7 deletions tests/e2e/tutorials/tutorialBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
13 changes: 13 additions & 0 deletions tests/e2e/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -527,6 +538,8 @@ module.exports = {
makeRequest,
getUserAndPass,
getDomain,
getChildrenElements,
getChildrenElementsBySelector,
getNodeTreeItemIDs,
getFileTreeItemIDs,
getVisibleChildrenIDs,
Expand Down

0 comments on commit 43192a2

Please sign in to comment.