Skip to content

[bugfix] Fix for is1499 #1516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ services/docker-compose.stack.*.yml
*secret*
*ignore*
!.dockerignore
!.gitignore

# Any generated output folder (e.g. codegen, build, ...)
out/
Expand Down
16 changes: 16 additions & 0 deletions .vscode-template/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@
"remoteRoot": "/devel"
}
]
},
{
"type": "node",
"request": "launch",
"name": "Debug e2e tests",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/tests/e2e/node_modules/.bin/jest",
"--runInBand",
"--colors"
],
"cwd": "${workspaceFolder}/tests/e2e",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
]
}
3 changes: 2 additions & 1 deletion services/web/client/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
{
"ignoreChainWithDepth": 3
}
]
],
"no-eq-null": 0
},
"env": {
"browser": true
Expand Down
7 changes: 6 additions & 1 deletion services/web/client/source/class/osparc/auth/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ qx.Class.define("osparc.auth.LoginPage", {
login.resetValues();
}, this);

[register, resetRequest, reset].forEach(srcPage => {
register.addListener("done", msg => {
osparc.utils.Utils.cookie.deleteCookie("user");
this.fireDataEvent("done", msg);
});

[resetRequest, reset].forEach(srcPage => {
srcPage.addListener("done", msg => {
pages.setSelection([login]);
srcPage.resetValues();
Expand Down
11 changes: 2 additions & 9 deletions services/web/client/source/class/osparc/auth/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,14 @@ qx.Class.define("osparc.auth.Manager", {
.finally(this.__logoutUser());
},

register: function(userData, successCbk, failCbk, context) {
console.debug("Registering user ...");
register: function(userData) {
const params = {
data: userData
};
osparc.data.Resources.fetch("auth", "postRegister", params)
.then(data => {
successCbk.call(context, data);
})
.catch(err => failCbk.call(context, err.message));
return osparc.data.Resources.fetch("auth", "postRegister", params);
},

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

resetPassword: function(newPassword, confirmation, code, successCbk, failCbk, context) {
console.debug("Reseting password ...");
const params = {
url: {
code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ qx.Class.define("osparc.auth.ui.RegistrationView", {
email.activate();
});

// const uname = new qx.ui.form.TextField().set({
// required: true,
// placeholder: this.tr("Introduce a user name")
// });
// this.add(uname);

const pass1 = new qx.ui.form.PasswordField().set({
required: true,
placeholder: this.tr("Introduce a password")
Expand Down Expand Up @@ -88,7 +82,6 @@ qx.Class.define("osparc.auth.ui.RegistrationView", {
return osparc.auth.core.Utils.checkSamePasswords(pass1, pass2);
});


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

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

__submit: function(userData) {
console.debug("Registering new user");

let manager = osparc.auth.Manager.getInstance();

let successFun = function(log) {
this.fireDataEvent("done", log.message);
osparc.component.message.FlashMessenger.getInstance().log(log);
};

let failFun = function(msg) {
msg = msg || this.tr("Cannot register user");
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
};

manager.register(userData, successFun, failFun, this);
osparc.auth.Manager.getInstance().register(userData)
.then(log => {
this.fireDataEvent("done", log.message);
osparc.component.message.FlashMessenger.getInstance().log(log);
})
.catch(err => {
const msg = err.message || this.tr("Cannot register user");
osparc.component.message.FlashMessenger.getInstance().logAs(msg, "ERROR");
});
},

_onAppear: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ qx.Class.define("osparc.component.form.tag.TagToggleButton", {
this._add(control, {
flex: 1
});
if (this.getLabel() == null || this.getShow() === "icon") { // eslint-disable-line no-eq-null
if (this.getLabel() == null || this.getShow() === "icon") {
control.exclude();
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ qx.Class.define("osparc.component.service.NodeStatus", {
return "@FontAwesome5Solid/check/12";
},
onUpdate: (source, target) => {
if (source.getInteractiveStatus() === "ready") {
if (source.getInteractiveStatus() == null) {
this.__removeClass(this.__icon.getContentElement(), "rotate");
} else if (source.getInteractiveStatus() === "ready") {
this.__removeClass(this.__icon.getContentElement(), "rotate");
target.setTextColor("ready-green");
} else if (source.getInteractiveStatus() === "failed") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qx.Class.define("osparc.component.service.ServiceJumbo", {
const text = serviceModel.getDescription ? serviceModel.getDescription() : "";
const footer = serviceModel.getContact ? serviceModel.getContact() : "";
this.base(arguments, label, text, icon, footer);
if (serviceModel != null) { // eslint-disable-line no-eq-null
if (serviceModel != null) {
this.setServiceModel(serviceModel);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ qx.Class.define("osparc.component.service.ServiceList", {
* @return True if no item is selected, false if there one or more item selected.
*/
isSelectionEmpty: function() {
if (this.__buttonGroup == null) { // eslint-disable-line no-eq-null
if (this.__buttonGroup == null) {
return true;
}
return this.__buttonGroup.getSelection().length === 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ qx.Class.define("osparc.component.service.manager.ActivityTree", {
const queued = activity[key].queued;
const limits = activity[key].limits;
if (stats) {
row[4] = stats.cpuUsage == null ? null : (Math.round(stats.cpuUsage * 10) / 10) + (limits && limits.cpus ? `/${limits.cpus * 100}` : ""); // eslint-disable-line no-eq-null
row[5] = stats.memUsage == null ? null : (Math.round(stats.memUsage * 10) / 10) + (limits && limits.mem ? `/${limits.mem}` : ""); // eslint-disable-line no-eq-null
row[4] = stats.cpuUsage == null ? null : (Math.round(stats.cpuUsage * 10) / 10) + (limits && limits.cpus ? `/${limits.cpus * 100}` : "");
row[5] = stats.memUsage == null ? null : (Math.round(stats.memUsage * 10) / 10) + (limits && limits.mem ? `/${limits.mem}` : "");
row[3] = this.tr("Running");
}
if (queued) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ qx.Class.define("osparc.component.widget.inputs.NodeOutputTree", {
portData.open = true;
} else {
portData.icon = osparc.data.Converters.fromTypeToIcon(ports[portKey].type);
portData.value = ports[portKey].value == null ? this.tr("no value") : ports[portKey].value; // eslint-disable-line no-eq-null
portData.value = ports[portKey].value == null ? this.tr("no value") : ports[portKey].value;
}
data.children.push(portData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ qx.Class.define("osparc.component.workbench.ServiceCatalog", {
},

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

Expand Down
4 changes: 2 additions & 2 deletions services/web/client/source/class/osparc/data/Resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,14 @@ qx.Class.define("osparc.data.Resources", {
*/
fetch: function(resource, endpoint, params = {}, deleteId) {
return new Promise((resolve, reject) => {
if (this.self().resources[resource] == null) { // eslint-disable-line no-eq-null
if (this.self().resources[resource] == null) {
reject(Error(`Error while fetching ${resource}: the resource is not defined`));
}

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ qx.Class.define("osparc.desktop.NavigationBar", {
this.tr("To create an issue in GitHub, you must have an account in GitHub and be already logged-in.")
);
const contBtn = new qx.ui.toolbar.Button(this.tr("Continue"), "@FontAwesome5Solid/external-link-alt/12");
contBtn.addListener("execute", () => window.open(osparc.component.widget.NewGHIssue.getNewIssueUrl()), this);
contBtn.addListener("execute", () => {
window.open(osparc.component.widget.NewGHIssue.getNewIssueUrl());
issueConfirmationWindow.close();
}, this);
const loginBtn = new qx.ui.toolbar.Button(this.tr("Log in in GitHub"), "@FontAwesome5Solid/external-link-alt/12");
loginBtn.addListener("execute", () => window.open("https://github.com/login"), this);
issueConfirmationWindow.addButton(contBtn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ qx.Class.define("osparc.desktop.SidePanel", {

__getSplitpaneContainer: function() {
const splitpane = this.__getParentSplitpane();
if (splitpane == null) { // eslint-disable-line no-eq-null
if (splitpane == null) {
return this;
}
let container = this;
Expand Down
2 changes: 1 addition & 1 deletion services/web/client/source/class/osparc/file/FilesTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ qx.Class.define("osparc.file.FilesTree", {
},

__getFilesInTree: function(item, leaves) {
if (item.getChildren == null) { // eslint-disable-line no-eq-null
if (item.getChildren == null) {
leaves.push(item);
} else {
for (let i=0; i<item.getChildren().length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion services/web/client/source/class/osparc/store/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ qx.Class.define("osparc.store.Store", {
this.reset(resources);
} else {
let propertyArray;
if (resources == null) { // eslint-disable-line no-eq-null
if (resources == null) {
propertyArray = Object.keys(qx.util.PropertyUtil.getProperties(osparc.store.Store));
} else if (Array.isArray(resources)) {
propertyArray = resources;
Expand Down
4 changes: 2 additions & 2 deletions services/web/client/source/class/osparc/ui/form/Jumbo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ qx.Class.define("osparc.ui.form.Jumbo", {
height: 90
});

if (text != null) { // eslint-disable-line no-eq-null
if (text != null) {
this.setText(text);
}
if (footer != null) { // eslint-disable-line no-eq-null
if (footer != null) {
this.setFooter(footer);
}
},
Expand Down
2 changes: 1 addition & 1 deletion services/web/client/source/class/osparc/ui/hint/Hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ qx.Class.define("osparc.ui.hint.Hint", {
this.__root.add(this);

if (element) {
if (element.getContentElement().getDomElement() == null) { // eslint-disable-line no-eq-null
if (element.getContentElement().getDomElement() == null) {
element.addListenerOnce("appear", () => this.setElement(element), this);
} else {
this.setElement(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ qx.Class.define("osparc.ui.table.cellrenderer.Percentage", {
members: {
// overridden
_getContentHtml: function(cellInfo) {
if (cellInfo.value == null || cellInfo.value < 0) { // eslint-disable-line no-eq-null
if (cellInfo.value == null || cellInfo.value < 0) {
return "";
}
const splitted = cellInfo.value.split("/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ qx.Class.define("osparc.ui.table.cellrenderer.Unit", {
members: {
// overridden
_getContentHtml: function(cellInfo) {
if (cellInfo.value == null || cellInfo.value < 0) { // eslint-disable-line no-eq-null
if (cellInfo.value == null || cellInfo.value < 0) {
return "";
}
return `${cellInfo.value} ${this.getUnit()}`;
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# coverage and screenshots for e2e testing
coverage/
screenshots/
32 changes: 32 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## To run the tests locally
```bash
cd tests/e2e
npm install
npm test
```
## To debug the tests locally with VSCode
Add the following configuration to your local ``launch.json``:
```json
{
"type": "node",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice but It would even be better if you add it in .vscode-template/lauch.json ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"request": "launch",
"name": "Debug e2e tests",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/tests/e2e/node_modules/.bin/jest",
"--runInBand",
"--colors"
],
"cwd": "${workspaceFolder}/tests/e2e",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
}
```
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.
## To run the tutorials
```bash
cd tests/e2e
node tutorials/<tutorial>.js [<user> <password>]
```
4 changes: 2 additions & 2 deletions tests/e2e/tests/register.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ beforeAll(async () => {
await page.goto(url);
}, ourTimeout);

test('Register, Log In and Log Out', async () => {
test('Register and Log Out', async () => {
page.on('response', async response => {
if (response.url().endsWith("/config")) {
try {
Expand Down Expand Up @@ -55,6 +55,6 @@ test('Register, Log In and Log Out', async () => {
}
}
});
await auto.logIn(page, user, pass);

await auto.logOut(page);
}, 30000);
5 changes: 1 addition & 4 deletions tests/e2e/tests/startupCalls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ const {

beforeAll(async () => {
await page.goto(url);

await auto.register(page, user, pass);
await auto.logIn(page, user, pass);
await page.waitFor(1000);
}, ourTimeout);

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

describe('Calls after logging in', () => {
page.waitFor(1000);

test('Profile', async () => {
const responseEnv = await utils.fetch('me');
expect(responseEnv.data["login"]).toBe(user);
Expand Down
8 changes: 5 additions & 3 deletions tests/e2e/tutorials/sleepers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tutorialBase = require('./tutorialBase');

const args = process.argv.slice(2);
if (args.length < 1) {
console.log('More arguments expented');
console.log('More arguments expected');
process.exit(1);
}
const url = args[0];
Expand All @@ -24,8 +24,10 @@ async function runTutorial () {
await tutorial.beforeScript();
await tutorial.goTo();

await tutorial.registerIfNeeded();
await tutorial.login();
const needsRegister = await tutorial.registerIfNeeded();
if (!needsRegister) {
await tutorial.login();
}
await tutorial.openTemplate(1000);

// Some time for loading the workbench
Expand Down
Loading