Skip to content
This repository has been archived by the owner. It is now read-only.

refactor(mailer): Increase comprehensibility of device description #227

Merged
merged 7 commits into from Nov 8, 2016

Conversation

@RPraneetha
Copy link
Contributor

@RPraneetha RPraneetha commented Oct 15, 2016

fix #193

@rfk rfk self-assigned this Oct 17, 2016
@rfk
Copy link
Member

@rfk rfk commented Oct 17, 2016

Hi @RPraneetha, thanks for the contribution!

There's one tricky part of this bug that we should have said more words about over in #193 - localization. The current device description string is not localized because it doesn't contain any additional words. Now that we're saying "X on Y", we need to connect this to the translation machinery so that it can be localized into all supported locales.

Take a look at the _constructLocationString further down in the file for an example of what we'll need to do here.

The logic for _formatUserAgentInfo will have to change to do something similar, along the lines of:

  • If there's a value for uaBrowser but not uaOS, then just return that as a string
  • If there's a value of uaOS but not uaBrowser, then just return that as a string
  • If there's a value for both, use translator.format(translator.gettext('%(uaBrowser)s on %(usOS)'), { uaBrowser: uaBrowser, uaOS: uaOS }) to render then together as a localizable string

The call to translator.gettext will ensure that the new message gets picked up by our translation toolchain and provided to localizers.

There is also a suite of tests that will need to be updated to match the new logic, at [1].

The strings that @ryanfeeley provided in [2] might make good additional test cases, if they're not covered by the ones already there.

[1] https://github.com/mozilla/fxa-auth-mailer/blob/master/test/local/mailer_tests.js#L481
[2] https://github.com/mozilla/fxa-auth-mailer/issues/193#issuecomment-240537533

@rfk
Copy link
Member

@rfk rfk commented Oct 17, 2016

(By the way, there's no need to close this PR and open a fresh you, you can just make additional commits to your git branch and push them, and they'll show up as modifications to this PR)

@RPraneetha
Copy link
Contributor Author

@RPraneetha RPraneetha commented Oct 18, 2016

Okay! I'll get working on that!

@RPraneetha
Copy link
Contributor Author

@RPraneetha RPraneetha commented Oct 21, 2016

@rfk Something like this?

var uaOSVersion = message.uaOSVersion

if (uaBrowser && uaOS) {
return translator.format(translator.gettext('%(uaBrowser)s on %(uaOS)%(uaOSVersion)'), { uaBrowser: uaBrowser, uaOS: uaOS, uaOSVersion: uaOSVersion })

This comment has been minimized.

@vladikoff

vladikoff Oct 21, 2016
Contributor

line 143 seems really long, i suggest adding a line break right after on %(uaOS)%(uaOSVersion)'),

This comment has been minimized.

@vladikoff

vladikoff Oct 21, 2016
Contributor

hm interesting that there is no space between %(uaOS)%(uaOSVersion) but tests still have a space between OS and Version

var os = message.uaOS
if (message.uaOSVersion) {
os += ' ' + message.uaOSVersion
else{

This comment has been minimized.

@vladikoff

vladikoff Oct 21, 2016
Contributor

need a space between else and {

if (message.uaOSVersion) {
os += ' ' + message.uaOSVersion
else{
if (uaBrowser){

This comment has been minimized.

@vladikoff

vladikoff Oct 21, 2016
Contributor

need a space before {

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Oct 21, 2016

Running "eslint:app" (eslint) task
/home/travis/build/mozilla/fxa-auth-mailer/mailer.js
  141:1  error  Trailing spaces not allowed  no-trailing-spaces
✖ 1 problem (1 error, 0 warnings)
if (uaBrowser){
return uaBrowser
}
else if (uaOS) {

This comment has been minimized.

@vladikoff

vladikoff Oct 21, 2016
Contributor

bring else if to the same line as 148 so it is: } else if (uaOS) {

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Oct 24, 2016

@RPraneetha seems like there are test failures:

test/local/db_tests.js ................................ 3/3 1s
test/local/mailer_tests.js ........................ 123/127
  test user-agent info rendering
  not ok should be equal
    +++ found                                                          
    --- wanted                                                         
    -Firefox on Windows 8.1                                            
    +Firefox on %(uaOS) %(uaOSVersion)                                 
    compare: ===
    at:
      line: 461
      column: 11
      file: test/local/mailer_tests.js
    stack: >
      test/local/mailer_tests.js:461:11

      test/local/mailer_tests.js:456:5

You can check that locally by using npm test from fxa-auth-mailer directory.

@RPraneetha
Copy link
Contributor Author

@RPraneetha RPraneetha commented Oct 24, 2016

Sorry, committed by accident! Was previewing changes but clicked on commit by mistake.

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Oct 24, 2016

Sorry, committed by accident! Was previewing changes but clicked on commit by mistake.

No worries!

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Nov 7, 2016

Thanks for fixing up the tests, going to review this now in detail! 👍

@vladikoff vladikoff merged commit 013f136 into mozilla:master Nov 8, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.04%) to 93.819%
Details
@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Nov 8, 2016

@RPraneetha thank you!

@rfk rfk added this to the FxA-0: quality milestone Dec 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants