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

Commit

Permalink
Merge pull request #11998 from lightsofapollo/email-card-stability
Browse files Browse the repository at this point in the history
Bug 913625 - Resolve flakey test issues with email reply tests r=lightso...
  • Loading branch information
lightsofapollo committed Sep 6, 2013
2 parents f0514bb + b8d2fb8 commit 72af505
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 71 deletions.
74 changes: 23 additions & 51 deletions apps/email/test/marionette/email.js
@@ -1,3 +1,4 @@
/*jshint node: true, browser: true */
function Email(client) {
this.client = client;
}
Expand Down Expand Up @@ -47,27 +48,12 @@ Email.prototype = {
return this.client.findElement(Selector.notificationBar);
},

setupImapEmail: function() {
const USER_NAME = 'GAIA';
const EMAIL_ADDRESS = 'marionette.js.client@gmail.com';
const PASSWORD = 'tpemozilla';
// wait for the setup page is loaded
this.client.helper.
waitForElement(Selector.manualConfigButton);
// setup a IMAP email account
this._setupTypeName(USER_NAME);
this._setupTypeEmail(EMAIL_ADDRESS);
this._setupTypePassword(PASSWORD);
this._setupTapNext();
this._waitForSetupCompleted();
this._tapContinue();
},

manualSetupImapEmail: function(server) {
// wait for the setup page is loaded
this.client.helper.
waitForElement(Selector.manualConfigButton).
tap();
this._waitForTransitionEnd('setup_manual_config');
// setup a IMAP email account
var email = server.imap.username + '@' + server.imap.hostname;
this._manualSetupTypeName(server.imap.username);
Expand All @@ -92,7 +78,7 @@ Email.prototype = {
tapCompose: function() {
this.client.findElement(Selector.composeButton).tap();
// wait for being in the compose page
this._waitForTransitionEnd();
this._waitForTransitionEnd('compose');
},

typeTo: function(email) {
Expand All @@ -118,10 +104,10 @@ Email.prototype = {
waitForElement(Selector.composeBodyInput).getAttribute('value');
},

abortCompose: function() {
abortCompose: function(cardId) {
this.client.helper.waitForElement(Selector.composeBackButton).tap();
this.client.helper.waitForElement(Selector.composeDraftDiscard).tap();
this._waitForTransitionEnd();
this._waitForTransitionEnd(cardId);
},

tapSend: function() {
Expand All @@ -141,16 +127,17 @@ Email.prototype = {
tap();
// wait for being in the email list page
client.helper.waitForElement(Selector.refreshButton);
this._waitForTransitionEnd();
this._waitForTransitionEnd('message_list');
},

waitForNewEmail: function() {
var client = this.client;
client.
tapRefreshButton: function() {
this.client.
findElement(Selector.refreshButton).
tap();
// show a new email notification
client.helper.waitForElement(Selector.notificationBar);
},

waitForNewEmail: function() {
this.client.helper.waitForElement(Selector.notificationBar);
},

launch: function() {
Expand All @@ -165,7 +152,7 @@ Email.prototype = {
var client = this.client;
var element = client.findElements(Selector.messageHeaderItem)[index];
element.tap();
this._waitForTransitionEnd();
this._waitForTransitionEnd('message_reader');
},

/**
Expand All @@ -191,27 +178,19 @@ Email.prototype = {
break;
}
client.findElement(whichButton).tap();
this._waitForTransitionEnd();
this._waitForTransitionEnd('compose');
},

_waitForTransitionEnd: function() {
_waitForTransitionEnd: function(cardId) {
var client = this.client;
client.waitFor(function() {
var condition = false;
client.executeScript(
function() {
return window.wrappedJSObject.
require('mail_common').
Cards.
_eatingEventsUntilNextCard;
},
function(error, result) {
if (result === false) {
condition = true;
}
}
);
return condition;
return client.executeScript(function(cardId) {
var Cards = window.wrappedJSObject.require('mail_common').Cards,
card = Cards._cardStack[Cards.activeCardIndex],
cardNode = card && card.domNode;
return cardNode && cardNode.dataset.type === cardId &&
!Cards._eatingEventsUntilNextCard;
}, [cardId]);
});
},

Expand All @@ -233,13 +212,6 @@ Email.prototype = {
sendKeys(password);
},

_setupTapNext: function() {
this._waitForTransitionEnd();
this.client.
findElement(Selector.nextButton).
tap();
},

_manualSetupTypeName: function(name) {
this.client.
findElement(Selector.manualSetupNameInput).
Expand Down Expand Up @@ -317,7 +289,7 @@ Email.prototype = {
},

_manualSetupTapNext: function() {
this._waitForTransitionEnd();
this._waitForTransitionEnd('setup_manual_config');
this.client.
findElement(Selector.manualNextButton).
tap();
Expand Down
10 changes: 6 additions & 4 deletions apps/email/test/marionette/reply_imap_email_test.js
Expand Up @@ -21,7 +21,7 @@ marionette('reply to an e-mail', function() {
var BODY_TEXT = 'I still have a dream.';

var app;
var server = serverHelper.use({}, this);
var server = serverHelper.use(null, this);
setup(function() {
app = new Email(client);
app.launch();
Expand All @@ -36,6 +36,7 @@ marionette('reply to an e-mail', function() {
app.typeBody(BODY_TEXT);
app.tapSend();

app.tapRefreshButton();
app.waitForNewEmail();
app.tapEmailAtIndex(0);
});
Expand All @@ -48,7 +49,7 @@ marionette('reply to an e-mail', function() {
assert(body.indexOf('wrote') != -1,
format('body should contain "wrote", was "%s"', body));

app.abortCompose();
app.abortCompose('message_reader');
});

test('should be able to "reply all" to an email', function() {
Expand All @@ -59,7 +60,7 @@ marionette('reply to an e-mail', function() {
assert(body.indexOf('wrote') != -1,
format('body should contain "wrote", was "%s"', body));

app.abortCompose();
app.abortCompose('message_reader');
});

test('should be able to forward an email', function() {
Expand All @@ -70,6 +71,7 @@ marionette('reply to an e-mail', function() {
assert(body.indexOf('Original message') != -1,
format('body should contain "Original message", was "%s"', body));

app.abortCompose();
app.abortCompose('message_reader');
});
});

32 changes: 16 additions & 16 deletions apps/email/test/marionette/send_imap_email_test.js
Expand Up @@ -3,20 +3,20 @@ var assert = require('assert');
var serverHelper = require('./lib/server_helper');

marionette('send email via IMAP', function() {
var client = marionette.client({
settings: {
// disable keyboard ftu because it blocks our display
'keyboard.ftu.enabled': false
}
});
var app,
client = marionette.client({
settings: {
// disable keyboard ftu because it blocks our display
'keyboard.ftu.enabled': false
}
});

var app;
setup(function() {
app = new Email(client);
app.launch();
});

var server = serverHelper.use({}, this);
var server = serverHelper.use(null, this);

test('should send a email', function() {
const ONE_NEW_EMAIL_NOTIFICATION = '1 New Email';
Expand All @@ -30,15 +30,15 @@ marionette('send email via IMAP', function() {
app.typeBody('I still have a dream.');
app.tapSend();

app.tapRefreshButton();
app.waitForNewEmail();
// get the text of the notification bar
app.notificationBar.
text(function(error, text) {
assert.equal(
text,
ONE_NEW_EMAIL_NOTIFICATION,
text + ' should equal ' + ONE_NEW_EMAIL_NOTIFICATION
);
});
var notificationText = app.notificationBar.text();
assert.equal(
notificationText,
ONE_NEW_EMAIL_NOTIFICATION,
notificationText + ' should equal ' + ONE_NEW_EMAIL_NOTIFICATION
);
});
});

0 comments on commit 72af505

Please sign in to comment.