mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: drops with-email-link and replaces it by with-email-button
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Login with email - hide email address taken", {
|
||||
settings: {
|
||||
enable_local_logins_via_email: true,
|
||||
hide_email_address_taken: true
|
||||
},
|
||||
beforeEach() {
|
||||
const response = object => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
|
||||
// prettier-ignore
|
||||
server.post("/u/email-login", () => { // eslint-disable-line no-undef
|
||||
return response({ success: "OK" });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("with hide_email_address_taken enabled", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
fillIn("#login-account-name", "someuser@example.com");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-success")
|
||||
.html()
|
||||
.trim(),
|
||||
I18n.t("email_login.complete_email_found", {
|
||||
email: "someuser@example.com"
|
||||
}),
|
||||
"it should display the success message for any email address"
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Login with email - no social logins", {
|
||||
settings: {
|
||||
enable_local_logins_via_email: true
|
||||
},
|
||||
beforeEach() {
|
||||
const response = object => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
|
||||
// prettier-ignore
|
||||
server.post("/u/email-login", () => { // eslint-disable-line no-undef
|
||||
return response({ success: "OK" });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("with login with email enabled", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(exists(".login-with-email-button"));
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("with login with email disabled", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.notOk(find(".login-buttons").is(":visible"));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("Login with email disabled", {
|
||||
settings: {
|
||||
enable_local_logins_via_email: false,
|
||||
enable_facebook_logins: true
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("with email button", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(
|
||||
exists(".btn-social.facebook"),
|
||||
"it displays the facebook login button"
|
||||
);
|
||||
|
||||
assert.notOk(
|
||||
exists(".login-with-email-button"),
|
||||
"it displays the login with email button"
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -19,20 +19,24 @@ acceptance("Login with email", {
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("logging in via email (link)", assert => {
|
||||
QUnit.test("with email button", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.notOk(
|
||||
exists(".login-with-email-link"),
|
||||
"it displays the link only when field is filled"
|
||||
assert.ok(
|
||||
exists(".btn-social.facebook"),
|
||||
"it displays the facebook login button"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(".login-with-email-button"),
|
||||
"it displays the login with email button"
|
||||
);
|
||||
userFound = false;
|
||||
});
|
||||
|
||||
fillIn("#login-account-name", "someuser");
|
||||
click(".login-with-email-link");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
@@ -45,7 +49,7 @@ QUnit.test("logging in via email (link)", assert => {
|
||||
});
|
||||
|
||||
fillIn("#login-account-name", "someuser@gmail.com");
|
||||
click(".login-with-email-link");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
@@ -63,7 +67,7 @@ QUnit.test("logging in via email (link)", assert => {
|
||||
userFound = true;
|
||||
});
|
||||
|
||||
click(".login-with-email-link");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
@@ -78,7 +82,7 @@ QUnit.test("logging in via email (link)", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
fillIn("#login-account-name", "someuser@gmail.com");
|
||||
click(".login-with-email-link");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
@@ -96,71 +100,3 @@ QUnit.test("logging in via email (link)", assert => {
|
||||
userFound = false;
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("logging in via email (button)", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-error").html(),
|
||||
I18n.t("login.blank_username"),
|
||||
"it should display an error for blank username"
|
||||
);
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
userFound = true;
|
||||
});
|
||||
|
||||
fillIn("#login-account-name", "someuser");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-success")
|
||||
.html()
|
||||
.trim(),
|
||||
I18n.t("email_login.complete_username_found", { username: "someuser" }),
|
||||
"it should display a success message for a valid username"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Login with email", {
|
||||
settings: {
|
||||
enable_local_logins_via_email: true,
|
||||
enable_facebook_logins: true,
|
||||
hide_email_address_taken: true
|
||||
},
|
||||
beforeEach() {
|
||||
const response = object => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
|
||||
// prettier-ignore
|
||||
server.post("/u/email-login", () => { // eslint-disable-line no-undef
|
||||
return response({ success: "OK" });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("login via email with hide_email_address_taken enabled", assert => {
|
||||
visit("/");
|
||||
click("header .login-button");
|
||||
fillIn("#login-account-name", "someuser@example.com");
|
||||
click(".login-with-email-button");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(
|
||||
find(".alert-success")
|
||||
.html()
|
||||
.trim(),
|
||||
I18n.t("email_login.complete_email_found", {
|
||||
email: "someuser@example.com"
|
||||
}),
|
||||
"it should display the success message for any email address"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user