fix(emails): enable change email for users (#5851), r=@philbooth
This commit is contained in:
Родитель
d676a7b07f
Коммит
bdb690bd6d
|
@ -30,11 +30,9 @@
|
|||
</div>
|
||||
<div class="settings-button-group">
|
||||
{{#verified}}
|
||||
{{#canChangePrimaryEmail }}
|
||||
<button class="settings-button secondary set-primary" data-id="{{email}}">
|
||||
{{#t}}Make primary{{/t}}
|
||||
</button>
|
||||
{{/canChangePrimaryEmail }}
|
||||
<button class="settings-button secondary set-primary" data-id="{{email}}">
|
||||
{{#t}}Make primary{{/t}}
|
||||
</button>
|
||||
{{/verified}}
|
||||
<button class="settings-button warning email-disconnect" data-id="{{email}}">
|
||||
{{#t}}Remove{{/t}}
|
||||
|
@ -44,11 +42,9 @@
|
|||
<li class="email-options">
|
||||
<div class="settings-button-group">
|
||||
{{#verified}}
|
||||
{{#canChangePrimaryEmail }}
|
||||
<button class="settings-button secondary set-primary" data-id="{{email}}">
|
||||
{{#t}}Make primary{{/t}}
|
||||
</button>
|
||||
{{/canChangePrimaryEmail }}
|
||||
{{/verified}}
|
||||
<button class="settings-button warning email-disconnect" data-id="{{email}}">
|
||||
{{#t}}Remove{{/t}}
|
||||
|
|
|
@ -58,7 +58,6 @@ define(function (require, exports, module) {
|
|||
setInitialContext (context) {
|
||||
context.set({
|
||||
buttonClass: this._hasSecondaryEmail() ? 'secondary' : 'primary',
|
||||
canChangePrimaryEmail: this._canChangePrimaryEmail(),
|
||||
emails: this._emails,
|
||||
hasSecondaryEmail: this._hasSecondaryEmail(),
|
||||
hasSecondaryVerifiedEmail: this._hasSecondaryVerifiedEmail(),
|
||||
|
@ -74,14 +73,6 @@ define(function (require, exports, module) {
|
|||
}
|
||||
},
|
||||
|
||||
_canChangePrimaryEmail () {
|
||||
if (this.getSearchParam('canChangeEmail')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
_hasSecondaryEmail () {
|
||||
return this._emails.length > 1;
|
||||
},
|
||||
|
|
|
@ -56,8 +56,6 @@ define(function (require, exports, module) {
|
|||
translator = new Translator({forceEnglish: true});
|
||||
user = new User();
|
||||
windowMock = new WindowMock();
|
||||
windowMock.location.search = '?canChangeEmail=true';
|
||||
|
||||
account = user.initAccount({
|
||||
email: email,
|
||||
sessionToken: 'abc123',
|
||||
|
@ -281,40 +279,6 @@ define(function (require, exports, module) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('does not show change email when `canChangeEmail` not set', () => {
|
||||
const newEmail = 'secondary@email.com';
|
||||
beforeEach(() => {
|
||||
emails = [{
|
||||
email: 'primary@email.com',
|
||||
isPrimary: true,
|
||||
verified: true
|
||||
}, {
|
||||
email: newEmail,
|
||||
isPrimary: false,
|
||||
verified: true
|
||||
}];
|
||||
|
||||
windowMock.location.search = '';
|
||||
|
||||
return initView()
|
||||
.then(function () {
|
||||
// click events require the view to be in the DOM
|
||||
$('#container').html(view.el);
|
||||
});
|
||||
});
|
||||
|
||||
it('can render', () => {
|
||||
assert.equal(view.$('.email-address').length, 1);
|
||||
assert.lengthOf(view.$('.email-address .address'), 1);
|
||||
assert.equal(view.$('.email-address .address').html(), 'secondary@email.com');
|
||||
assert.equal(view.$('.email-address .details .verified').length, 1);
|
||||
assert.equal(view.$('.email-address .settings-button.warning.email-disconnect').length, 1);
|
||||
assert.equal(view.$('.email-address .settings-button.warning.email-disconnect').attr('data-id'), 'secondary@email.com');
|
||||
assert.equal(view.$('.email-address .settings-button.secondary.set-primary').length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('can change email', () => {
|
||||
const newEmail = 'secondary@email.com';
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -374,9 +374,6 @@ if they perform a reset password.
|
|||
|
||||
## Secondary email parameters
|
||||
|
||||
### `canChangeEmail`
|
||||
Shows the option to change a user's primary email address.
|
||||
|
||||
#### Options
|
||||
* `true`
|
||||
* `false` (default)
|
||||
|
|
|
@ -11,10 +11,9 @@ const selectors = require('./lib/selectors');
|
|||
|
||||
const config = intern._config;
|
||||
|
||||
const SIGNUP_URL = config.fxaContentRoot + 'signup?canChangeEmail=true';
|
||||
const SIGNIN_URL = config.fxaContentRoot + 'signin?canChangeEmail=true';
|
||||
const SETTINGS_URL = config.fxaContentRoot + 'settings?canChangeEmail=true';
|
||||
const SIGNIN_URL_NO_CHANGE_EMAIL = config.fxaContentRoot + 'signin';
|
||||
const SIGNUP_URL = config.fxaContentRoot + 'signup';
|
||||
const SIGNIN_URL = config.fxaContentRoot + 'signin';
|
||||
const SETTINGS_URL = config.fxaContentRoot + 'settings';
|
||||
const PASSWORD = 'password';
|
||||
const NEW_PASSWORD = 'password1';
|
||||
|
||||
|
@ -33,7 +32,6 @@ const {
|
|||
openPage,
|
||||
openVerificationLinkInNewTab,
|
||||
openVerificationLinkInSameTab,
|
||||
noSuchElement,
|
||||
switchToWindow,
|
||||
testElementExists,
|
||||
testElementTextEquals,
|
||||
|
@ -59,11 +57,7 @@ registerSuite('settings change email', {
|
|||
.then(type(selectors.EMAIL.INPUT, secondaryEmail))
|
||||
.then(click(selectors.EMAIL.ADD_BUTTON))
|
||||
.then(testElementExists(selectors.EMAIL.NOT_VERIFIED_LABEL))
|
||||
.then(openVerificationLinkInSameTab(secondaryEmail, 0, {
|
||||
query: {
|
||||
canChangeEmail: true
|
||||
}
|
||||
}))
|
||||
.then(openVerificationLinkInSameTab(secondaryEmail, 0, {}))
|
||||
.then(testSuccessWasShown())
|
||||
|
||||
// set new primary email
|
||||
|
@ -79,20 +73,6 @@ registerSuite('settings change email', {
|
|||
return this.remote.then(clearBrowserState());
|
||||
},
|
||||
tests: {
|
||||
'does no show change email option if query `canChangeEmail` not set': function () {
|
||||
return this.remote
|
||||
// sign out
|
||||
.then(click(selectors.SETTINGS.SIGNOUT))
|
||||
.then(testElementExists(selectors.SIGNIN.HEADER))
|
||||
|
||||
// sign in and does not show change primary email button
|
||||
.then(openPage(SIGNIN_URL_NO_CHANGE_EMAIL, selectors.SIGNIN.HEADER))
|
||||
.then(testElementExists(selectors.SIGNIN.HEADER))
|
||||
.then(fillOutSignIn(secondaryEmail, PASSWORD))
|
||||
.then(click(selectors.EMAIL.MENU_BUTTON))
|
||||
.then(noSuchElement(selectors.EMAIL.SET_PRIMARY_EMAIL_BUTTON));
|
||||
},
|
||||
|
||||
'can change primary email and login': function () {
|
||||
return this.remote
|
||||
// sign out
|
||||
|
|
Загрузка…
Ссылка в новой задаче