Skip to content

Commit db2ff36

Browse files
authored
🐛✨ Add Dipole Antenna e2e test (ITISFoundation#3632)
1 parent e7a1efb commit db2ff36

File tree

4 files changed

+125
-8
lines changed

4 files changed

+125
-8
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// node sim4life-dipole.js [url] [user] [password] [timeout] [--demo]
2+
3+
const utils = require('../utils/utils');
4+
const tutorialBase = require('./tutorialBase');
5+
6+
const args = process.argv.slice(2);
7+
const {
8+
url,
9+
user,
10+
pass,
11+
newUser,
12+
startTimeout,
13+
enableDemoMode
14+
} = utils.parseCommandLineArguments(args)
15+
16+
const studyName = "Dipole Antenna";
17+
18+
async function runTutorial() {
19+
const tutorial = new tutorialBase.TutorialBase(url, studyName, user, pass, newUser, enableDemoMode);
20+
let studyId;
21+
try {
22+
await tutorial.start();
23+
24+
// make sure only sim4life-dy is available
25+
const services = tutorial.getReceivedServices();
26+
if (services.length && services.every(service => service.key === "simcore/services/dynamic/sim4life-dy")) {
27+
console.log("Expected services received");
28+
}
29+
else {
30+
throw "Check exposed services";
31+
}
32+
33+
// start Sim4Life Lite
34+
const studyData = await tutorial.openTemplate();
35+
studyId = studyData["data"]["uuid"];
36+
37+
const workbenchData = utils.extractWorkbenchData(studyData["data"]);
38+
console.log(workbenchData);
39+
const s4lNodeId = workbenchData["nodeIds"][0];
40+
await tutorial.waitForServices(
41+
workbenchData["studyId"],
42+
[s4lNodeId],
43+
startTimeout,
44+
false
45+
);
46+
47+
await tutorial.testS4LDipole(s4lNodeId);
48+
}
49+
catch (err) {
50+
tutorial.setTutorialFailed(true, false);
51+
console.log('Tutorial error: ' + err);
52+
throw "Tutorial Failed";
53+
}
54+
finally {
55+
await tutorial.leave(studyId);
56+
}
57+
58+
if (tutorial.getTutorialFailed()) {
59+
throw "Tutorial Failed";
60+
}
61+
}
62+
63+
runTutorial()
64+
.catch(error => {
65+
console.log('Puppeteer error: ' + error);
66+
process.exit(1);
67+
});

tests/e2e/tutorials/sim4life-light.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
enableDemoMode
1414
} = utils.parseCommandLineArguments(args)
1515

16-
const studyName = "sim4life-dy";
16+
const studyName = "sim4life";
1717

1818
async function runTutorial() {
1919
const tutorial = new tutorialBase.TutorialBase(url, studyName, user, pass, newUser, enableDemoMode);

tests/e2e/tutorials/sim4life.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
enableDemoMode
1414
} = utils.parseCommandLineArguments(args)
1515

16-
const serviceName = "sim4life-dy";
16+
const serviceName = "sim4life";
1717

1818
async function runTutorial() {
1919
const tutorial = new tutorialBase.TutorialBase(url, serviceName, user, pass, newUser, enableDemoMode);

tests/e2e/tutorials/tutorialBase.js

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,11 @@ class TutorialBase {
456456
}
457457
}
458458

459-
async waitAndClick(osparcTestId) {
460-
await utils.waitAndClick(this.__page, `[osparc-test-id=${osparcTestId}]`);
459+
async waitAndClick(osparcTestId, page) {
460+
if (page === undefined) {
461+
page = this.__page;
462+
}
463+
await utils.waitAndClick(page, `[osparc-test-id=${osparcTestId}]`);
461464
}
462465

463466
async closeNodeFiles() {
@@ -607,8 +610,8 @@ class TutorialBase {
607610

608611
// do some basic interaction
609612
const s4lIframe = await this.getIframe(s4lNodeId);
610-
const modelTree = await s4lIframe.$('.model-tree');
611-
const modelItems = await modelTree.$$('.MuiTreeItem-label');
613+
await this.waitAndClick('tree-model', s4lIframe);
614+
const modelItems = await s4lIframe.$$('.MuiTreeItem-label');
612615
const nLabels = modelItems.length;
613616
if (nLabels > 1) {
614617
modelItems[0].click();
@@ -620,6 +623,53 @@ class TutorialBase {
620623
}
621624
}
622625

626+
async testS4LDipole(s4lNodeId) {
627+
await this.waitFor(20000, 'Wait for the splash screen to disappear');
628+
629+
const s4lIframe = await this.getIframe(s4lNodeId);
630+
await this.waitAndClick('mode-button-modeling', s4lIframe);
631+
await this.waitAndClick('tree-model', s4lIframe);
632+
await this.waitFor(2000, 'Model Mode clicked');
633+
await this.takeScreenshot("Model");
634+
const modelItems = await s4lIframe.$$('.MuiTreeItem-label');
635+
console.log("N items in model tree:", modelItems.length/2); // there are 2 trees
636+
637+
await this.waitAndClick('mode-button-simulation', s4lIframe);
638+
await this.waitFor(2000, 'Simulation Mode clicked');
639+
await this.takeScreenshot("Simulation");
640+
641+
// click on simulation root element
642+
const simulationsItems = await s4lIframe.$$('.MuiTreeItem-label');
643+
simulationsItems[0].click();
644+
await this.waitFor(2000, '1st item in Simulation Tree clicked');
645+
await this.waitAndClick('toolbar-tool-UpdateGrid', s4lIframe);
646+
await this.waitFor(2000, 'Updating grid...');
647+
await this.waitAndClick('toolbar-tool-CreateVoxels', s4lIframe);
648+
await this.waitFor(2000, 'Creating voxels...');
649+
await this.takeScreenshot("Creating voxels");
650+
const runButtons1 = await s4lIframe.$$('[osparc-test-id="toolbar-tool-Run"');
651+
await runButtons1[0].click();
652+
const runButtons2 = await s4lIframe.$$('[osparc-test-id="toolbar-tool-Run"');
653+
await runButtons2[1].click();
654+
await this.waitFor(2000, 'Running simulation...');
655+
await this.takeScreenshot("Running simulation");
656+
657+
// HACK: we need to switch modes to trigger the load of the postpro tree item
658+
const simulationPostproSwitchTries = 100;
659+
for (let i=0; i<simulationPostproSwitchTries; i++) {
660+
await this.waitFor(2000, 'Waiting for results');
661+
await this.waitAndClick('mode-button-postro', s4lIframe);
662+
await this.takeScreenshot("Postpro");
663+
const treeAlgItems = await utils.getVisibleChildrenIDs(s4lIframe, '[osparc-test-id="tree-algorithm');
664+
if (treeAlgItems.length) {
665+
await this.waitFor(2000, 'Results found');
666+
await this.takeScreenshot("Results found");
667+
break;
668+
}
669+
await this.waitAndClick('mode-button-simulation', s4lIframe);
670+
}
671+
}
672+
623673
async takeScreenshot(screenshotTitle) {
624674
// Generates an URL that points to the backend logs at this time
625675
const snapshotUrl = utils.getGrayLogSnapshotUrl(this.__url, 30);
@@ -638,8 +688,8 @@ class TutorialBase {
638688
return this.__failed;
639689
}
640690

641-
async setTutorialFailed(failed) {
642-
if (failed) {
691+
async setTutorialFailed(failed, loggerScreenshot = true) {
692+
if (failed && loggerScreenshot) {
643693
await this.takeLoggerScreenshot();
644694
}
645695
this.__failed = failed;

0 commit comments

Comments
 (0)