Calendar:QA/Automation Phase 2/Event Invitations Testing

From MozillaWiki
Jump to: navigation, search

For now attendees can't be added with Mozmill bug 505336

Setting up fakeservers

To create fake IMAP server for Thunderbird to interact with:

let imapDaemon = new imapDaemon();
let imapHandler = new IMAP_RFC3501_handler(imapDaemon);
let imapServer = new nsMailServer(imapHandler);
imapServer.start(PORT1);

Two accounts are needed, one for the sender and the other for the invited attendee. Fakeserver only supports one login but two IMAP servers can be setup. mail.server.serverX.max_cached_connections needs to be set to 1.

To create fake SMTP server that Thunderbird can use to send invitation:

let smtpDaemon = new smtpDaemon();
// use default authentication details for IMAP fakeserver
let smtpHandler = new SMTP_RFC2822_handler(smtpDaemon, "PLAIN", "user", "password");
let smtpServer = new nsMailServer(smtpHandler);
smtpServer.start(PORT2);

Account setup

  • New account wizard or
  • Setting needed prefs directly or
  • Using nsIMsgAccountManager

Transferring email

SMTP fakeserver doesn't provide a way to access last sent message but it should be possible to retrieve it from Sent folder. Copying mails to sent folder on send with above setup doesn't work for me every time, seems to work better if Sent is created server-side with
imapDaemon.createMailbox("Sent", {subscribed : true});
but even then not always. Not sure what causes it to fail.

To add email to inbox:

let inbox = imapDaemon.getMailbox("INBOX");
let message = do_get_file("test_mail");
let ioService = Cc["@mozilla.org/network/io-service;1"]
                  .getService(Ci.nsIIOService);
let URI = ioService.newFileURI(message).QueryInterface(Ci.nsIFileURL);
inbox.addMessage(new imapMessage(URI.spec, inbox.uidnext++, []));

All above code is in the form that goes into body of run_test() that mailnews xpcshell tests use. As mail needs to be added to inbox at the same time Mozmill test is running it might make sense to use xpcshell to send commands instead of running it as xpcshell test which does a do_timeout to keep running as long as is needed. With xpcshell it would be:

  • setup servers (xpcshell)
  • start Thunderbird
  • send invitation (UI)
  • retrieve sent mail (xpcshell/UI)
  • add it to inbox (xpcshell)
  • add to calendar (UI)