FEATURE: drops with-email-link and replaces it by with-email-button

This commit is contained in:
Joffrey JAFFEUX 2018-07-02 14:35:50 +02:00 committed by GitHub
parent cb86c5ae1e
commit c754ece8f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 120 additions and 110 deletions

View File

@ -5,7 +5,10 @@ export default Ember.Component.extend({
elementId: "login-buttons",
classNameBindings: ["hidden"],
hidden: Ember.computed.equal("buttons.length", 0),
@computed("buttons.length", "showLoginWithEmailLink")
hidden(buttonsCount, showLoginWithEmailLink) {
return buttonsCount === 0 && !showLoginWithEmailLink;
},
@computed
buttons() {

View File

@ -70,17 +70,9 @@ export default Ember.Controller.extend(ModalFunctionality, {
return this.get("loggingIn") || this.get("authenticate");
}.property("loggingIn", "authenticate"),
@computed("canLoginLocalWithEmail", "loginName", "processingEmailLink")
showLoginWithEmailLink(
canLoginLocalWithEmail,
loginName,
processingEmailLink
) {
return (
canLoginLocalWithEmail &&
!Ember.isEmpty(loginName) &&
!processingEmailLink
);
@computed("canLoginLocalWithEmail", "processingEmailLink")
showLoginWithEmailLink(canLoginLocalWithEmail, processingEmailLink) {
return canLoginLocalWithEmail && !processingEmailLink;
},
actions: {

View File

@ -2,7 +2,7 @@
<button class="btn btn-social {{b.name}}" {{action "externalLogin" b}}>{{b.title}}</button>
{{/each}}
{{#if canLoginLocalWithEmail}}
{{#if showLoginWithEmailLink}}
{{d-button
action="emailLogin"
label="email_login.button_label"

View File

@ -2,7 +2,7 @@
{{#d-modal-body title="login.title" class="login-modal"}}
{{#if showLoginButtons}}
{{login-buttons
canLoginLocalWithEmail=canLoginLocalWithEmail
showLoginWithEmailLink=showLoginWithEmailLink
processingEmailLink=processingEmailLink
emailLogin='emailLogin'
externalLogin='externalLogin'}}
@ -20,16 +20,6 @@
{{text-field value=loginName type="email" placeholderKey="login.email_placeholder" id="login-account-name" autocorrect="off" autocapitalize="off"}}
</td>
</tr>
{{#if showLoginWithEmailLink}}
<tr>
<td></td>
<td>
<a class="login-with-email-link" {{action "emailLogin"}}>
{{i18n 'email_login.link_label'}}
</a>
</td>
</tr>
{{/if}}
<tr>
<td>
<label for='login-account-password'>{{i18n 'login.password'}}</label>

View File

@ -8,13 +8,6 @@
<tr>
<td><label for='login-account-name'>{{i18n 'login.username'}}</label></td>
<td>{{text-field value=loginName placeholderKey="login.email_placeholder" id="login-account-name" autocorrect="off" autocapitalize="off" autofocus="autofocus"}}</td>
<td>
{{#if showLoginWithEmailLink}}
<a class="login-with-email-link" {{action "emailLogin"}}>
{{i18n 'email_login.link_label'}}
</a>
{{/if}}
</td>
</tr>
<tr>
<td><label for='login-account-password'>{{i18n 'login.password'}}</label></td>
@ -33,10 +26,9 @@
{{/second-factor-form}}
</form>
{{/if}}
{{#if showLoginButtons}}
{{login-buttons
canLoginLocalWithEmail=canLoginLocalWithEmail
showLoginWithEmailLink=showLoginWithEmailLink
processingEmailLink=processingEmailLink
emailLogin='emailLogin'
externalLogin='externalLogin'}}

View File

@ -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"
);
});
});

View File

@ -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"));
});
});

View File

@ -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"
);
});
});

View File

@ -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"
);
});
});