mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: login by a link from email
Co-authored-by: tgxworld <tgx@discourse.org>
This commit is contained in:
committed by
Guo Xiang Tan
parent
f9280617d0
commit
03b3e57a44
90
test/javascripts/acceptance/forgot-password-test.js.es6
Normal file
90
test/javascripts/acceptance/forgot-password-test.js.es6
Normal file
@@ -0,0 +1,90 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
let userFound = false;
|
||||
|
||||
acceptance("Forgot password", {
|
||||
settings: {
|
||||
enable_local_logins_via_email: true
|
||||
},
|
||||
beforeEach() {
|
||||
const response = object => {
|
||||
return [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
object
|
||||
];
|
||||
};
|
||||
|
||||
server.post('/u/email-login', () => { // eslint-disable-line no-undef
|
||||
return response({ "user_found": userFound });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("logging in via email", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.login-modal'), "it shows the login modal");
|
||||
});
|
||||
|
||||
click('#forgot-password-link');
|
||||
|
||||
fillIn("#username-or-email", 'someuser');
|
||||
click('.email-login');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-error").html(),
|
||||
I18n.t('email_login.complete_username_not_found', { username: 'someuser' }),
|
||||
'it should display the right error message'
|
||||
);
|
||||
});
|
||||
|
||||
fillIn("#username-or-email", 'someuser@gmail.com');
|
||||
click('.email-login');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-error").html(),
|
||||
I18n.t('email_login.complete_email_not_found', { email: 'someuser@gmail.com' }),
|
||||
'it should display the right error message'
|
||||
);
|
||||
});
|
||||
|
||||
fillIn("#username-or-email", 'someuser');
|
||||
|
||||
andThen(() => {
|
||||
userFound = true;
|
||||
});
|
||||
|
||||
click('.email-login');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".modal-body").html().trim(),
|
||||
I18n.t('email_login.complete_username_found', { username: 'someuser' }),
|
||||
'it should display the right message'
|
||||
);
|
||||
});
|
||||
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists('.login-modal'), "it shows the login modal");
|
||||
});
|
||||
|
||||
click('#forgot-password-link');
|
||||
fillIn("#username-or-email", 'someuser@gmail.com');
|
||||
click('.email-login');
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".modal-body").html().trim(),
|
||||
I18n.t('email_login.complete_email_found', { email: 'someuser@gmail.com' }),
|
||||
'it should display the right message'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user