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 7 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ prof/

# outputs from make
.stack-*.yml

Copy link
Member

Choose a reason for hiding this comment

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

MINOR: For non-generics, I prefer if we create a specific .gitignore ... e.g. in this case it would be in tests/e2e/.gitignore

# coverage for e2e testing
coverage/
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
26 changes: 26 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## To run the tests locally
```bash
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.
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