Mailing list functionality is not tested
Categories
(Thunderbird :: Address Book, task, P3)
Tracking
(Not tracked)
People
(Reporter: pmorris, Assigned: pmorris)
References
Details
Attachments
(1 file, 7 obsolete files)
|
27.95 KB,
patch
|
darktrojan
:
review+
|
Details | Diff | Splinter Review |
We could use some test coverage for mailing list functionality. Recently there were a number of regressions in this area that were fixed. Tests will help detect and prevent such regressions.
| Assignee | ||
Comment 1•6 years ago
|
||
A WIP patch on adding some basic mochitests. Working with secondary windows, dialogs, and trees is a little tricky. Currently the test fails due to bug 1588795.
Geoff, feedback is welcome if you have a moment, not urgent.
| Assignee | ||
Updated•6 years ago
|
| Assignee | ||
Comment 2•6 years ago
|
||
Tests creating a new mailing list and then editing it. Passes with the fix for bug 1588795 applied. Still need to figure out where to put mochitest utility functions where they'll be generally accessible.
Comment 3•6 years ago
|
||
| Assignee | ||
Comment 4•6 years ago
|
||
Thanks for the review and the help navigating this mochitest world.
Before the previous patch I had tried using EventUtils.sendString but I wasn't waiting for the dialog to be ready to handle the input so it wasn't working. Now I'm starting to get the swing of it.
So this addresses all of your comments and adds a few other things. I've made a couple of functions more generally accessible as utility functions. There might be ways to improve the implementation of making that work.
Try run (using an artifact build): https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=28d265c58b51bb30b492eebfef8d801a55d8f726
Comment 5•6 years ago
|
||
| Assignee | ||
Comment 6•6 years ago
|
||
OK, thanks Magnus. I've made those changes.
| Assignee | ||
Comment 7•6 years ago
|
||
Geoff asked me to "create a test address book to put your contacts in, and make sure it gets removed at the end. See if you can get rid of the setTimeout(resolve, 500) too".
This patch does that, but now there are 4 failing subtests. For some reason deleting addresses from the mailing list doesn't work. Everything works fine when doing the steps manually. (sigh) Here's the error:
0:05.38 GECKO(13224) JavaScript error: chrome://messenger/content/addressbook/abMailListDialog.js, line 144: NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIAbDirectory.deleteCards]
0:05.38 INFO Console message: [JavaScript Error: "NS_ERROR_NOT_AVAILABLE: Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIAbDirectory.deleteCards]" {file: "chrome://messenger/content/addressbook/abMailListDialog.js" line: 144}]
updateMailListMembers@chrome://messenger/content/addressbook/abMailListDialog.js:144:14
EditListOKButton@chrome://messenger/content/addressbook/abMailListDialog.js:241:26
_fireButtonEvent@chrome://global/content/elements/dialog.js:533:19
_doButtonCommand@chrome://global/content/elements/dialog.js:512:29
_handleButtonCommand@chrome://global/content/elements/dialog.js:504:39
mailingListWindowPromise2<@chrome://mochitests/content/browser/comm/mailnews/addrbook/test/browser/browser_mailing_lists.js:289:40
async*promiseAlertDialogOpen@resource://testing-common/BrowserTestUtils.jsm:2150:13
async*promiseAlertDialog@resource://testing-common/BrowserTestUtils.jsm:2178:26
@chrome://mochitests/content/browser/comm/mailnews/addrbook/test/browser/browser_mailing_lists.js:195:52
Async*Tester_execTest/<@chrome://mochikit/content/browser-test.js:1069:34
Tester_execTest@chrome://mochikit/content/browser-test.js:1104:11
nextTest/<@chrome://mochikit/content/browser-test.js:932:14
SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:805:67
There's also a number of these errors:
0:05.14 INFO Console message: [JavaScript Error: "ERROR: failed to set status text: TypeError: getSelectedDirectory(...) is null" {file: "chrome://messenger/content/addressbook/addressbook.js" line: 541}]
SetStatusText@chrome://messenger/content/addressbook/addressbook.js:541:8
onCountChanged@chrome://messenger/content/addressbook/addressbook.js:144:18
updateMailListMembers@chrome://messenger/content/addressbook/abMailListDialog.js:140:14
MailListOKButton@chrome://messenger/content/addressbook/abMailListDialog.js:170:28
_fireButtonEvent@chrome://global/content/elements/dialog.js:533:19
_doButtonCommand@chrome://global/content/elements/dialog.js:512:29
_handleButtonCommand@chrome://global/content/elements/dialog.js:504:39
mailingListWindowPromise1<@chrome://mochitests/content/browser/comm/mailnews/addrbook/test/browser/browser_mailing_lists.js:140:40
async*promiseAlertDialogOpen@resource://testing-common/BrowserTestUtils.jsm:2150:13
async*promiseAlertDialog@resource://testing-common/BrowserTestUtils.jsm:2178:26
@chrome://mochitests/content/browser/comm/mailnews/addrbook/test/browser/browser_mailing_lists.js:91:52
Async*Tester_execTest/<@chrome://mochikit/content/browser-test.js:1069:34
Tester_execTest@chrome://mochikit/content/browser-test.js:1104:11
nextTest/<@chrome://mochikit/content/browser-test.js:932:14
SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:805:67
And as described in the patch, creating the address book by going through the UI was not reliable. Sometimes it worked and sometimes it didn't, so I'm currently calling the function directly to avoid making a flaky test. Doing a short timeout seemed to fix it, but that's no longer allowed by eslint, and I don't know of any other events to listen for since we're already waiting for "load" on the address book window.
Any insights on any of this are welcome, of course. (I'm starting to see why these tests weren't written before...)
Comment 8•6 years ago
|
||
I don't yet know why, but the error is coming from somewhere in the Mork address book code. This shouldn't be happening, we should only be using JS address books now, but I forgot to switch some code over. I'm now fixing that in bug 1594246.
| Assignee | ||
Comment 9•6 years ago
|
||
Rebased and bug 1594246 fixes the first error. This patch now fixes the other error in addressbook.js -- a problem with trying to access a directory name before the directory is there. I'd prefer creating the address book by using the UI, but I'm not sure how to do that in a reliable way. (See comments in the patch.)
| Assignee | ||
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
| Assignee | ||
Comment 12•6 years ago
|
||
Thanks for the review. I'm figuring out the quirks of testing with mochitest as I go, so it's... a process. This patch addresses your comments.
(In reply to Geoff Lankow (:darktrojan) from comment #11)
More general comments about testing:
It's harder to read a test if you have to keep in mind the current state of
the UI (ie. knowing what each key press does). If you want to change a
textbox or click on a button, go directly to it and do what you want. Sure,
test that pressing keys does the right thing (especially in weird UI like
this) but actually test it if you do (ie. input 2 has focus, press tab, test
that input 3 has focus).
Makes sense. Earlier I wasn't having much luck with the clicking approach because I hadn't figured out to say do more than one key at a time, like for ctrl+A, (not exactly well documented...). So I was relying on keyboard navigation to tab to inputs to get the text selected. But that's all in the past now.
Also, don't be afraid to write a completely separate test if there's
something else that needs testing. Tests are cheap. You don't need to do
everything in one go.
Okay, I've broken this up a bit.
Comment 13•6 years ago
|
||
| Assignee | ||
Comment 14•6 years ago
•
|
||
Thanks again for the review. This addresses your comments and makes a couple other improvements like using a global object and refactoring the dirTreeClick function.
| Assignee | ||
Comment 15•6 years ago
|
||
Comment 16•6 years ago
|
||
Updated•6 years ago
|
| Assignee | ||
Comment 17•6 years ago
|
||
Thanks, only when we're talking about at least incremental improvements. :) All for landing this and moving on.
...and jorgk beat me to adding the checkin flag.
Comment 18•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/54d186205801
Add a mochitest for mailing lists. r=darktrojan
Updated•6 years ago
|
Description
•