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

Commit

Permalink
fix(tests): Avatar functional test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikoff committed Aug 12, 2014
1 parent 08ac812 commit ceb5561
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 17 deletions.
22 changes: 18 additions & 4 deletions tests/functional/avatar.js
Expand Up @@ -58,6 +58,10 @@ define([

.findByCssSelector('button[type="submit"]')
.click()
.end()

// make sure we actually sign in
.findById('fxa-settings-header')
.end();
});
},
Expand Down Expand Up @@ -89,13 +93,14 @@ define([
.click()
.end()

.findByCssSelector('img[src*="https://www.gravatar.com"]')
.end()

.findById('submit-btn')
.click()
.end()

// redirected back to main avatar page after save
.findById('change-avatar')
.end()
.then(FunctionalHelpers.visibleByQSA('.success'))

.findByCssSelector('.success')
.getVisibleText()
Expand All @@ -104,6 +109,10 @@ define([
})
.end()

// redirected back to main avatar page after save
.findById('change-avatar')
.end()

// check for an image with the gravatar url
.findByCssSelector('img[src*="https://www.gravatar.com"]')
.end();
Expand All @@ -118,6 +127,9 @@ define([
.click()
.end()

.findByCssSelector('img[src*="https://www.gravatar.com"]')
.end()

.findByCssSelector('a.cancel')
.click()
.end()
Expand All @@ -126,6 +138,9 @@ define([
.findById('avatar-options')
.end()

// give time for error to show up, there should be no error though
.sleep(500)

.findByCssSelector('.error')
.getVisibleText()
.then(function (val) {
Expand All @@ -137,7 +152,6 @@ define([
.findByCssSelector('.default')
.end();
},

'visit gravatar with no gravatar set': function () {
return this.get('remote')
.get(require.toUrl(AVATAR_CHANGE_URL))
Expand Down
9 changes: 3 additions & 6 deletions tests/functional/confirm.js
Expand Up @@ -81,12 +81,9 @@ define([
.end()

// the test below depends on the speed of the email resent XHR
// we have to pollUntil the resent request completes
.then(pollUntil(function () {
/* global document */
var element = document.getElementsByClassName('success')[0];
return element && element.offsetWidth > 0 ? true : null;
}, [ ], 40000))
// we have to wait until the resent request completes and the success notification is visible
.then(FunctionalHelpers.visibleByQSA('.success'))

.then(function (result) {
assert.ok(result);
}, function (error) {
Expand Down
32 changes: 28 additions & 4 deletions tests/functional/lib/helpers.js
Expand Up @@ -4,8 +4,9 @@

define([
'intern',
'require'
], function (intern, require) {
'require',
'intern/dojo/node!leadfoot/helpers/pollUntil'
], function (intern, require, pollUntil) {
'use strict';

var config = intern.config;
Expand All @@ -20,8 +21,31 @@ define([
.end();
}

/**
* Use document.querySelectorAll to find visible elements
* used for error and success notification animations.
*
* Usage: ".then(FunctionalHelpers.visibleByQSA('.success'))"
*
* @param {String} selector
* QSA compatible selector string
*/
function visibleByQSA(selector) {
return pollUntil(function (selector) {
/* global document */
var match = document.querySelectorAll(selector);

if (match.length > 1) {
throw new Error('Multiple elements matched. Make a more precise selector');
}

return match[0] && match[0].offsetWidth > 0 ? true : null;
}, [ selector ], 10000);
}

return {
clearBrowserState: clearBrowserState
clearBrowserState: clearBrowserState,
visibleByQSA: visibleByQSA,
pollUntil: pollUntil
};
});

4 changes: 3 additions & 1 deletion tests/intern.js
Expand Up @@ -53,7 +53,9 @@ define(['intern/lib/args', 'intern/node_modules/dojo/has!host-node?intern/node_m
{ browserName: 'firefox' }
],

pageLoadTimeout: 30000,
// the default test timeout is 30 seconds
// make it 28 seconds to see the timeout error stack
pageLoadTimeout: 28000,

// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 3,
Expand Down
4 changes: 2 additions & 2 deletions tests/intern_sauce.js
Expand Up @@ -12,10 +12,10 @@ define([
intern.tunnelOptions = {
port: 4445,
directDomains: [
'lcip.org'
'latest.dev.lcip.org'
],
skipSslDomains: [
'lcip.org'
'latest.dev.lcip.org'
]
};
intern.functionalSuites = [ 'tests/functional', 'tests/functional_extra' ];
Expand Down

0 comments on commit ceb5561

Please sign in to comment.