Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
feat(client): Add email prefill on the /signin page if the email ad…
Browse files Browse the repository at this point in the history
…dress is passed as a search parameter.
  • Loading branch information
Shane Tomlinson committed Jun 25, 2014
1 parent af7ad38 commit f704906
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/scripts/views/sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ function (_, p, BaseView, FormView, SignInTemplate, Constants, Session, Password
},

context: function () {
// Session.prefillEmail comes first because users can edit the email,
// go to another screen, edit the email again, and come back here. We
// want the last used email.
var email = Session.prefillEmail || Url.searchParam('email', this.window.location.search);

return {
service: this.service,
serviceName: this.serviceName,
email: Session.prefillEmail,
email: email,
password: Session.prefillPassword,
isSync: Session.isSync()
};
Expand Down
18 changes: 16 additions & 2 deletions app/tests/spec/views/sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ function (chai, $, p, View, Session, AuthErrors, Metrics, WindowMock, RouterMock
var wrapAssertion = TestHelpers.wrapAssertion;

describe('views/sign_in', function () {
var view, email, routerMock, metrics;
var view, email, routerMock, metrics, windowMock;

beforeEach(function () {
email = 'testuser.' + Math.random() + '@testuser.com';

Session.clear();

routerMock = new RouterMock();
windowMock = new WindowMock();
metrics = new Metrics();

view = new View({
router: routerMock,
metrics: metrics
metrics: metrics,
window: windowMock
});

return view.render()
Expand Down Expand Up @@ -63,6 +67,16 @@ function (chai, $, p, View, Session, AuthErrors, Metrics, WindowMock, RouterMock
});
});


it('prefills email with email from search parameter if Session.prefillEmail is not set', function () {
windowMock.location.search = '?email=' + encodeURIComponent('testuser@testuser.com');

return view.render()
.then(function () {
assert.equal(view.$('[type=email]').val(), 'testuser@testuser.com');
});
});

describe('updatePasswordVisibility', function () {
it('pw field set to text when clicked', function () {
$('.show-password').click();
Expand Down
1 change: 0 additions & 1 deletion app/tests/spec/views/sign_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ function (chai, _, $, p, View, Session, AuthErrors, Metrics, RouterMock, WindowM

return view.render()
.then(function () {
assert.ok($('#fxa-signup-header').length);
assert.equal(view.$('[type=email]').val(), 'testuser@testuser.com');
});
});
Expand Down

0 comments on commit f704906

Please sign in to comment.