Skip to content

Commit d70285c

Browse files
ignapasodeimaiz
andauthored
[bugfix] Fix for is1499 (#1516)
* Fix for is1499 * fix e2e (#9) * Added README to e2e testing * Solved bug with rotating Idle icon * Disabled no-eq-null rule to be able to check for null or undefined * Added e2e debug config to vscode templates. Moved gitignores to new file * Allowed new gitignores * Continue button in feedback dialog now closes the window Co-authored-by: Odei Maiz <[email protected]>
1 parent 3e7e5e6 commit d70285c

File tree

28 files changed

+105
-61
lines changed

28 files changed

+105
-61
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ services/docker-compose.stack.*.yml
126126
*secret*
127127
*ignore*
128128
!.dockerignore
129+
!.gitignore
129130

130131
# Any generated output folder (e.g. codegen, build, ...)
131132
out/

.vscode-template/launch.json

+16
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@
6868
"remoteRoot": "/devel"
6969
}
7070
]
71+
},
72+
{
73+
"type": "node",
74+
"request": "launch",
75+
"name": "Debug e2e tests",
76+
"runtimeArgs": [
77+
"--inspect-brk",
78+
"${workspaceRoot}/tests/e2e/node_modules/.bin/jest",
79+
"--runInBand",
80+
"--colors"
81+
],
82+
"cwd": "${workspaceFolder}/tests/e2e",
83+
"restart": true,
84+
"console": "integratedTerminal",
85+
"internalConsoleOptions": "neverOpen",
86+
"port": 9229
7187
}
7288
]
7389
}

services/web/client/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
{
3434
"ignoreChainWithDepth": 3
3535
}
36-
]
36+
],
37+
"no-eq-null": 0
3738
},
3839
"env": {
3940
"browser": true

services/web/client/source/class/osparc/auth/LoginPage.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ qx.Class.define("osparc.auth.LoginPage", {
9292
login.resetValues();
9393
}, this);
9494

95-
[register, resetRequest, reset].forEach(srcPage => {
95+
register.addListener("done", msg => {
96+
osparc.utils.Utils.cookie.deleteCookie("user");
97+
this.fireDataEvent("done", msg);
98+
});
99+
100+
[resetRequest, reset].forEach(srcPage => {
96101
srcPage.addListener("done", msg => {
97102
pages.setSelection([login]);
98103
srcPage.resetValues();

services/web/client/source/class/osparc/auth/Manager.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,14 @@ qx.Class.define("osparc.auth.Manager", {
108108
.finally(this.__logoutUser());
109109
},
110110

111-
register: function(userData, successCbk, failCbk, context) {
112-
console.debug("Registering user ...");
111+
register: function(userData) {
113112
const params = {
114113
data: userData
115114
};
116-
osparc.data.Resources.fetch("auth", "postRegister", params)
117-
.then(data => {
118-
successCbk.call(context, data);
119-
})
120-
.catch(err => failCbk.call(context, err.message));
115+
return osparc.data.Resources.fetch("auth", "postRegister", params);
121116
},
122117

123118
resetPasswordRequest: function(email, successCbk, failCbk, context) {
124-
console.debug("Requesting reset password ...");
125119
const params = {
126120
data: {
127121
email
@@ -135,7 +129,6 @@ qx.Class.define("osparc.auth.Manager", {
135129
},
136130

137131
resetPassword: function(newPassword, confirmation, code, successCbk, failCbk, context) {
138-
console.debug("Reseting password ...");
139132
const params = {
140133
url: {
141134
code

services/web/client/source/class/osparc/auth/ui/RegistrationView.js

+9-22
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ qx.Class.define("osparc.auth.ui.RegistrationView", {
5454
email.activate();
5555
});
5656

57-
// const uname = new qx.ui.form.TextField().set({
58-
// required: true,
59-
// placeholder: this.tr("Introduce a user name")
60-
// });
61-
// this.add(uname);
62-
6357
const pass1 = new qx.ui.form.PasswordField().set({
6458
required: true,
6559
placeholder: this.tr("Introduce a password")
@@ -88,7 +82,6 @@ qx.Class.define("osparc.auth.ui.RegistrationView", {
8882
return osparc.auth.core.Utils.checkSamePasswords(pass1, pass2);
8983
});
9084

91-
9285
// submit & cancel buttons
9386
const grp = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
9487

@@ -123,21 +116,15 @@ qx.Class.define("osparc.auth.ui.RegistrationView", {
123116
},
124117

125118
__submit: function(userData) {
126-
console.debug("Registering new user");
127-
128-
let manager = osparc.auth.Manager.getInstance();
129-
130-
let successFun = function(log) {
131-
this.fireDataEvent("done", log.message);
132-
osparc.component.message.FlashMessenger.getInstance().log(log);
133-
};
134-
135-
let failFun = function(msg) {
136-
msg = msg || this.tr("Cannot register user");
137-
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
138-
};
139-
140-
manager.register(userData, successFun, failFun, this);
119+
osparc.auth.Manager.getInstance().register(userData)
120+
.then(log => {
121+
this.fireDataEvent("done", log.message);
122+
osparc.component.message.FlashMessenger.getInstance().log(log);
123+
})
124+
.catch(err => {
125+
const msg = err.message || this.tr("Cannot register user");
126+
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
127+
});
141128
},
142129

143130
_onAppear: function() {

services/web/client/source/class/osparc/component/form/tag/TagToggleButton.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ qx.Class.define("osparc.component.form.tag.TagToggleButton", {
5050
this._add(control, {
5151
flex: 1
5252
});
53-
if (this.getLabel() == null || this.getShow() === "icon") { // eslint-disable-line no-eq-null
53+
if (this.getLabel() == null || this.getShow() === "icon") {
5454
control.exclude();
5555
}
5656
break;

services/web/client/source/class/osparc/component/service/NodeStatus.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ qx.Class.define("osparc.component.service.NodeStatus", {
9090
return "@FontAwesome5Solid/check/12";
9191
},
9292
onUpdate: (source, target) => {
93-
if (source.getInteractiveStatus() === "ready") {
93+
if (source.getInteractiveStatus() == null) {
94+
this.__removeClass(this.__icon.getContentElement(), "rotate");
95+
} else if (source.getInteractiveStatus() === "ready") {
9496
this.__removeClass(this.__icon.getContentElement(), "rotate");
9597
target.setTextColor("ready-green");
9698
} else if (source.getInteractiveStatus() === "failed") {

services/web/client/source/class/osparc/component/service/ServiceJumbo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qx.Class.define("osparc.component.service.ServiceJumbo", {
3232
const text = serviceModel.getDescription ? serviceModel.getDescription() : "";
3333
const footer = serviceModel.getContact ? serviceModel.getContact() : "";
3434
this.base(arguments, label, text, icon, footer);
35-
if (serviceModel != null) { // eslint-disable-line no-eq-null
35+
if (serviceModel != null) {
3636
this.setServiceModel(serviceModel);
3737
}
3838
},

services/web/client/source/class/osparc/component/service/ServiceList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ qx.Class.define("osparc.component.service.ServiceList", {
100100
* @return True if no item is selected, false if there one or more item selected.
101101
*/
102102
isSelectionEmpty: function() {
103-
if (this.__buttonGroup == null) { // eslint-disable-line no-eq-null
103+
if (this.__buttonGroup == null) {
104104
return true;
105105
}
106106
return this.__buttonGroup.getSelection().length === 0;

services/web/client/source/class/osparc/component/service/manager/ActivityTree.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ qx.Class.define("osparc.component.service.manager.ActivityTree", {
215215
const queued = activity[key].queued;
216216
const limits = activity[key].limits;
217217
if (stats) {
218-
row[4] = stats.cpuUsage == null ? null : (Math.round(stats.cpuUsage * 10) / 10) + (limits && limits.cpus ? `/${limits.cpus * 100}` : ""); // eslint-disable-line no-eq-null
219-
row[5] = stats.memUsage == null ? null : (Math.round(stats.memUsage * 10) / 10) + (limits && limits.mem ? `/${limits.mem}` : ""); // eslint-disable-line no-eq-null
218+
row[4] = stats.cpuUsage == null ? null : (Math.round(stats.cpuUsage * 10) / 10) + (limits && limits.cpus ? `/${limits.cpus * 100}` : "");
219+
row[5] = stats.memUsage == null ? null : (Math.round(stats.memUsage * 10) / 10) + (limits && limits.mem ? `/${limits.mem}` : "");
220220
row[3] = this.tr("Running");
221221
}
222222
if (queued) {

services/web/client/source/class/osparc/component/widget/inputs/NodeOutputTree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ qx.Class.define("osparc.component.widget.inputs.NodeOutputTree", {
151151
portData.open = true;
152152
} else {
153153
portData.icon = osparc.data.Converters.fromTypeToIcon(ports[portKey].type);
154-
portData.value = ports[portKey].value == null ? this.tr("no value") : ports[portKey].value; // eslint-disable-line no-eq-null
154+
portData.value = ports[portKey].value == null ? this.tr("no value") : ports[portKey].value;
155155
}
156156
data.children.push(portData);
157157
}

services/web/client/source/class/osparc/component/workbench/ServiceCatalog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ qx.Class.define("osparc.component.workbench.ServiceCatalog", {
261261
},
262262

263263
__onAddService: function(model) {
264-
if (model == null && this.__serviceBrowser.isSelectionEmpty()) { // eslint-disable-line no-eq-null
264+
if (model == null && this.__serviceBrowser.isSelectionEmpty()) {
265265
return;
266266
}
267267

services/web/client/source/class/osparc/data/Resources.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ qx.Class.define("osparc.data.Resources", {
460460
*/
461461
fetch: function(resource, endpoint, params = {}, deleteId) {
462462
return new Promise((resolve, reject) => {
463-
if (this.self().resources[resource] == null) { // eslint-disable-line no-eq-null
463+
if (this.self().resources[resource] == null) {
464464
reject(Error(`Error while fetching ${resource}: the resource is not defined`));
465465
}
466466

467467
const resourceDefinition = this.self().resources[resource];
468468
const res = new osparc.io.rest.Resource(resourceDefinition.endpoints);
469469

470-
if (!res.includesRoute(endpoint)) { // eslint-disable-line no-eq-null
470+
if (!res.includesRoute(endpoint)) {
471471
reject(Error(`Error while fetching ${resource}: the endpoint is not defined`));
472472
}
473473

services/web/client/source/class/osparc/desktop/NavigationBar.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ qx.Class.define("osparc.desktop.NavigationBar", {
327327
this.tr("To create an issue in GitHub, you must have an account in GitHub and be already logged-in.")
328328
);
329329
const contBtn = new qx.ui.toolbar.Button(this.tr("Continue"), "@FontAwesome5Solid/external-link-alt/12");
330-
contBtn.addListener("execute", () => window.open(osparc.component.widget.NewGHIssue.getNewIssueUrl()), this);
330+
contBtn.addListener("execute", () => {
331+
window.open(osparc.component.widget.NewGHIssue.getNewIssueUrl());
332+
issueConfirmationWindow.close();
333+
}, this);
331334
const loginBtn = new qx.ui.toolbar.Button(this.tr("Log in in GitHub"), "@FontAwesome5Solid/external-link-alt/12");
332335
loginBtn.addListener("execute", () => window.open("https://github.com/login"), this);
333336
issueConfirmationWindow.addButton(contBtn);

services/web/client/source/class/osparc/desktop/SidePanel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ qx.Class.define("osparc.desktop.SidePanel", {
141141

142142
__getSplitpaneContainer: function() {
143143
const splitpane = this.__getParentSplitpane();
144-
if (splitpane == null) { // eslint-disable-line no-eq-null
144+
if (splitpane == null) {
145145
return this;
146146
}
147147
let container = this;

services/web/client/source/class/osparc/file/FilesTree.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ qx.Class.define("osparc.file.FilesTree", {
466466
},
467467

468468
__getFilesInTree: function(item, leaves) {
469-
if (item.getChildren == null) { // eslint-disable-line no-eq-null
469+
if (item.getChildren == null) {
470470
leaves.push(item);
471471
} else {
472472
for (let i=0; i<item.getChildren().length; i++) {

services/web/client/source/class/osparc/store/Store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ qx.Class.define("osparc.store.Store", {
243243
this.reset(resources);
244244
} else {
245245
let propertyArray;
246-
if (resources == null) { // eslint-disable-line no-eq-null
246+
if (resources == null) {
247247
propertyArray = Object.keys(qx.util.PropertyUtil.getProperties(osparc.store.Store));
248248
} else if (Array.isArray(resources)) {
249249
propertyArray = resources;

services/web/client/source/class/osparc/ui/form/Jumbo.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ qx.Class.define("osparc.ui.form.Jumbo", {
3737
height: 90
3838
});
3939

40-
if (text != null) { // eslint-disable-line no-eq-null
40+
if (text != null) {
4141
this.setText(text);
4242
}
43-
if (footer != null) { // eslint-disable-line no-eq-null
43+
if (footer != null) {
4444
this.setFooter(footer);
4545
}
4646
},

services/web/client/source/class/osparc/ui/hint/Hint.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ qx.Class.define("osparc.ui.hint.Hint", {
3030
this.__root.add(this);
3131

3232
if (element) {
33-
if (element.getContentElement().getDomElement() == null) { // eslint-disable-line no-eq-null
33+
if (element.getContentElement().getDomElement() == null) {
3434
element.addListenerOnce("appear", () => this.setElement(element), this);
3535
} else {
3636
this.setElement(element);

services/web/client/source/class/osparc/ui/table/cellrenderer/Percentage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ qx.Class.define("osparc.ui.table.cellrenderer.Percentage", {
2828
members: {
2929
// overridden
3030
_getContentHtml: function(cellInfo) {
31-
if (cellInfo.value == null || cellInfo.value < 0) { // eslint-disable-line no-eq-null
31+
if (cellInfo.value == null || cellInfo.value < 0) {
3232
return "";
3333
}
3434
const splitted = cellInfo.value.split("/");

services/web/client/source/class/osparc/ui/table/cellrenderer/Unit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ qx.Class.define("osparc.ui.table.cellrenderer.Unit", {
2323
members: {
2424
// overridden
2525
_getContentHtml: function(cellInfo) {
26-
if (cellInfo.value == null || cellInfo.value < 0) { // eslint-disable-line no-eq-null
26+
if (cellInfo.value == null || cellInfo.value < 0) {
2727
return "";
2828
}
2929
return `${cellInfo.value} ${this.getUnit()}`;

tests/e2e/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# coverage and screenshots for e2e testing
2+
coverage/
3+
screenshots/

tests/e2e/README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## To run the tests locally
2+
```bash
3+
cd tests/e2e
4+
npm install
5+
npm test
6+
```
7+
## To debug the tests locally with VSCode
8+
Add the following configuration to your local ``launch.json``:
9+
```json
10+
{
11+
"type": "node",
12+
"request": "launch",
13+
"name": "Debug e2e tests",
14+
"runtimeArgs": [
15+
"--inspect-brk",
16+
"${workspaceRoot}/tests/e2e/node_modules/.bin/jest",
17+
"--runInBand",
18+
"--colors"
19+
],
20+
"cwd": "${workspaceFolder}/tests/e2e",
21+
"restart": true,
22+
"console": "integratedTerminal",
23+
"internalConsoleOptions": "neverOpen",
24+
"port": 9229
25+
}
26+
```
27+
Now you can run the tests by clicking on the Play button, using that configuration. It should allow you to insert breakpoints and inspect variables.
28+
## To run the tutorials
29+
```bash
30+
cd tests/e2e
31+
node tutorials/<tutorial>.js [<user> <password>]
32+
```

tests/e2e/tests/register.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ beforeAll(async () => {
1010
await page.goto(url);
1111
}, ourTimeout);
1212

13-
test('Register, Log In and Log Out', async () => {
13+
test('Register and Log Out', async () => {
1414
page.on('response', async response => {
1515
if (response.url().endsWith("/config")) {
1616
try {
@@ -55,6 +55,6 @@ test('Register, Log In and Log Out', async () => {
5555
}
5656
}
5757
});
58-
await auto.logIn(page, user, pass);
58+
5959
await auto.logOut(page);
6060
}, 30000);

tests/e2e/tests/startupCalls.test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ const {
88

99
beforeAll(async () => {
1010
await page.goto(url);
11-
1211
await auto.register(page, user, pass);
13-
await auto.logIn(page, user, pass);
12+
await page.waitFor(1000);
1413
}, ourTimeout);
1514

1615
afterAll(async () => {
1716
await auto.logOut(page);
1817
}, ourTimeout);
1918

2019
describe('Calls after logging in', () => {
21-
page.waitFor(1000);
22-
2320
test('Profile', async () => {
2421
const responseEnv = await utils.fetch('me');
2522
expect(responseEnv.data["login"]).toBe(user);

tests/e2e/tutorials/sleepers.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const tutorialBase = require('./tutorialBase');
66

77
const args = process.argv.slice(2);
88
if (args.length < 1) {
9-
console.log('More arguments expented');
9+
console.log('More arguments expected');
1010
process.exit(1);
1111
}
1212
const url = args[0];
@@ -24,8 +24,10 @@ async function runTutorial () {
2424
await tutorial.beforeScript();
2525
await tutorial.goTo();
2626

27-
await tutorial.registerIfNeeded();
28-
await tutorial.login();
27+
const needsRegister = await tutorial.registerIfNeeded();
28+
if (!needsRegister) {
29+
await tutorial.login();
30+
}
2931
await tutorial.openTemplate(1000);
3032

3133
// Some time for loading the workbench

0 commit comments

Comments
 (0)