Closed
Bug 840495
Opened 13 years ago
Closed 13 years ago
[keyboard] Fix & restore unit tests
Categories
(Firefox OS Graveyard :: Gaia::Keyboard, defect)
Firefox OS Graveyard
Gaia::Keyboard
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: jugglinmike, Assigned: jugglinmike)
References
Details
Attachments
(1 file, 4 obsolete files)
|
6.72 KB,
patch
|
djf
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Steps to reproduce:
Ran the unit test suite
Actual results:
The Keyboard application's tests failed
Expected results:
The Keyboard application's tests should have passed.
| Assignee | ||
Comment 1•13 years ago
|
||
Note: the failing tests were disabled in Bug 838993, this bug is to enable them
back.
| Assignee | ||
Updated•13 years ago
|
Summary: [keyboard] Fix failing unit tests → [keyboard] Fix & restore unit tests
| Assignee | ||
Comment 2•13 years ago
|
||
Tackling these today...
| Assignee | ||
Updated•13 years ago
|
Assignee: nobody → mike
| Assignee | ||
Comment 3•13 years ago
|
||
Attachment #715246 -
Flags: review?(felash)
Comment 4•13 years ago
|
||
Comment on attachment 715246 [details] [diff] [review]
Fix and re-enable keyboard unit tests
seems good to me but I don't know enough this code to give my review, giving this to :djf.
Also, the fix might be related to Bug 827414 ?
Attachment #715246 -
Flags: review?(felash)
Attachment #715246 -
Flags: review?(dflanagan)
Attachment #715246 -
Flags: feedback+
Comment 5•13 years ago
|
||
Comment on attachment 715246 [details] [diff] [review]
Fix and re-enable keyboard unit tests
Review of attachment 715246 [details] [diff] [review]:
-----------------------------------------------------------------
Mike,
The special handling for colon and semicolon were in there, but were taken out because it made it impossible to type smileys :-) and ;-). So I think you need to leave the code as it is, but adjust the comments and the test cases to match.
I don't recall clearly, but I suspect that I removed the code and didn't adjust the tests (because this was back before we had any automated way to run the tests). So my bad for breaking the test. Thanks for fixing it!
Attachment #715246 -
Flags: review?(dflanagan) → review-
| Assignee | ||
Comment 6•13 years ago
|
||
I'm just glad you caught this, David. Gaia would have been a much more emotionless place if you hadn't :P
I'll try to make this requirement more explicit in my next pass. If not new dedicated tests, at least some comments around the colon and semicolon test cases.
| Assignee | ||
Comment 7•13 years ago
|
||
Attachment #715246 -
Attachment is obsolete: true
Attachment #718661 -
Flags: review?(dflanagan)
Comment 8•13 years ago
|
||
Comment on attachment 718661 [details] [diff] [review]
[patch] Fix and re-enable keyboard unit tests (v2)
Review of attachment 718661 [details] [diff] [review]:
-----------------------------------------------------------------
If I'm reading your commit message correctly, it sounds like it is describing the first version of your patch, not the second, so you might want to update that.
r+ with the nits below addressed.
If you've got gjslint and fixjsstyle installed, go ahead and run them over the file to get rid of the trailing whitespace that was already in the file in various spots.
Also note that I'm assuming that you've run the test and have verified that it works now. I haven't tried to do that myself.
::: apps/keyboard/test/unit/latin_test.js
@@ +172,5 @@
> if (!mode && type !== 'textarea')
> return input;
> + // If input is a space followed by a colon or semicolon, do not transpose.
> + // This facilitates the entry of emoticons such as :O
> + if (input === ' :' || input === ' ;')
Since you're explicitly testing for semicolon here, please add ' ;':expectedPunctuation to the inputs object, so we actually test both colon and semicolon cases.
@@ +178,3 @@
>
> // If the previous character is a letter, transpose otherwise don't
> + if (cursor > 0 && /[a-zA-Z]/.test(value.charAt(cursor-1)))
I'm not sure why you'd change [] to charAt() here, but not in the line below. I'd prefer [] here.
Attachment #718661 -
Flags: review?(dflanagan) → review+
| Assignee | ||
Comment 9•13 years ago
|
||
> If I'm reading your commit message correctly, it sounds like it is
> describing the first version of your patch, not the second, so you might
> want to update that.
Yup, looks like I forgot to update the message.
> If you've got gjslint and fixjsstyle installed, go ahead and run them over
> the file to get rid of the trailing whitespace that was already in the file
> in various spots.
Would you like this in a separate commit?
> Also note that I'm assuming that you've run the test and have verified that
> it works now. I haven't tried to do that myself.
Yes--all 910 tests pass.
> ::: apps/keyboard/test/unit/latin_test.js
> @@ +172,5 @@
> > if (!mode && type !== 'textarea')
> > return input;
> > + // If input is a space followed by a colon or semicolon, do not transpose.
> > + // This facilitates the entry of emoticons such as :O
> > + if (input === ' :' || input === ' ;')
>
> Since you're explicitly testing for semicolon here, please add '
> ;':expectedPunctuation to the inputs object, so we actually test both colon
> and semicolon cases.
Are you looking for the string where a newline is followed by a semicolon ("\n;")? The strings " ;" and " :" are both already covered in the suite:
https://github.com/mozilla-b2g/gaia/blob/e47143b2024ea803fede35b9b1b33a77166bb483/apps/keyboard/test/unit/latin_test.js#L140-L149
> @@ +178,3 @@
> >
> > // If the previous character is a letter, transpose otherwise don't
> > + if (cursor > 0 && /[a-zA-Z]/.test(value.charAt(cursor-1)))
>
> I'm not sure why you'd change [] to charAt() here, but not in the line
> below. I'd prefer [] here.
The reason is to guard against the case where `cursor-1` is out of bounds. In such cases, `value[cursor-1]` will return `undefined`, which will be coerced into a string and yield a false positive for this conditional. Using `String#charAt` ensures that in such cases, the empty string is returned, which fails the test as expected. At the moment, it doesn't seem that any test cases will trigger this behavior, but I thought this was a safer approach.
Comment 10•13 years ago
|
||
(In reply to Mike Pennisi [:jugglinmike] from comment #9)
>
> The reason is to guard against the case where `cursor-1` is out of bounds.
> In such cases, `value[cursor-1]` will return `undefined`, which will be
> coerced into a string and yield a false positive for this conditional. Using
> `String#charAt` ensures that in such cases, the empty string is returned,
> which fails the test as expected. At the moment, it doesn't seem that any
> test cases will trigger this behavior, but I thought this was a safer
> approach.
Let's just say that the test was wrong and you fixed it. Yay :)
| Assignee | ||
Comment 11•13 years ago
|
||
Implementing feedback from :djf
Attachment #718661 -
Attachment is obsolete: true
Attachment #719054 -
Flags: review?(dflanagan)
Comment 12•13 years ago
|
||
Comment on attachment 719054 [details] [diff] [review]
Fix and re-enable keyboard unit tests (v3)
Thanks for running the linter. Its something we try to be pretty consistent about, but obviously I hadn't done it on the original version of this file. I think that people who have to deal with these things are pretty adamant about one commit per bug, so you'll need to squash the two commits before landing.
Thanks also for the charAt() vs [] explanation. I'd never thought about that out-of-bounds case. Nice catch.
As a general thing, since I gave r+ on the second review you could have landed it without requesting a third review, but this way is fine, too.
Attachment #719054 -
Flags: review?(dflanagan) → review+
| Assignee | ||
Comment 13•13 years ago
|
||
Squash the two commits in the previous patch into a single commit.
Attachment #719054 -
Attachment is obsolete: true
| Assignee | ||
Comment 14•13 years ago
|
||
Alright, squashed! Thanks for the explanation regarding patch reviews--I didn't request a review on this latest version. I do not have commit rights, though, so I will need someone to land this for me.
| Assignee | ||
Comment 15•13 years ago
|
||
The previous patch was never merged and fell behind `master`. I've rebased and re-verified that all 910 tests pass after this patch is applied. (It looks like someone has run gjslint and fixjsstyle over the file. That simplifies this patch, as the style changes are limited to those lines that were previously commented out.)
@djf: I know you've already given this work a review, but I'm not able to land it myself. If there's a way to specifically request a merge (but not necessarily a review), please let me know!
Attachment #719083 -
Attachment is obsolete: true
Attachment #734644 -
Flags: review?(dflanagan)
Comment 16•13 years ago
|
||
"checkin-needed" as a keyword works fine ;)
I'll let David re-review this just in case.
Comment 17•13 years ago
|
||
Landed on master: https://github.com/mozilla-b2g/gaia/commit/5dd3f0d1ec469c53880194b297227874a4795e3a
Mike,
Another way to get this landed would have been to set r? again just to get my attention or to use needinfo to get my attention or to just send me an email about it.
I don't actually know how to handle patches like this other than to create a pull request from them and land them that way, so that's what I did.
Updated•13 years ago
|
Attachment #734644 -
Flags: review?(dflanagan) → review+
Updated•13 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 18•13 years ago
|
||
Got it; thanks, David!
You need to log in
before you can comment on or make changes to this bug.
Description
•