From 7cea344dab45b4752ebd417a1c600d0542ac7c89 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Thu, 18 Dec 2014 21:41:51 -0500 Subject: [PATCH] chore(tests): fix up functional tests --- app/templates/application.hbs | 2 +- app/templates/client/form.hbs | 2 +- app/templates/client/register.hbs | 10 ++--- app/templates/clients.hbs | 4 +- bower.json | 3 +- package.json | 5 ++- scripts/run_functional.sh | 8 ++++ tests/functional/all.js | 4 +- tests/functional/all/clients.js | 64 +++++++++++++++++++++++++++---- tests/functional/intern.js | 7 +++- 10 files changed, 86 insertions(+), 23 deletions(-) create mode 100755 scripts/run_functional.sh diff --git a/app/templates/application.hbs b/app/templates/application.hbs index e4967f8..ca66ef2 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -12,7 +12,7 @@
diff --git a/app/templates/client/form.hbs b/app/templates/client/form.hbs index 634c248..fe08a67 100644 --- a/app/templates/client/form.hbs +++ b/app/templates/client/form.hbs @@ -22,7 +22,7 @@ {{#if model.secret}} -
{{model.secret}}
+
{{model.secret}}

Save this secret above, you will never see it again.

Sample Configuration

diff --git a/app/templates/client/register.hbs b/app/templates/client/register.hbs
index c0a4f41..1d51893 100644
--- a/app/templates/client/register.hbs
+++ b/app/templates/client/register.hbs
@@ -1,7 +1,7 @@
 
- {{#if name}} - Client: {{name}} + {{#if model.name}} + Client: {{model.name}} {{else}} New Client {{/if}} @@ -9,9 +9,9 @@ {{partial 'client/form'}}
-{{#unless secret}} +{{#unless model.secret}}
- - + +
{{/unless}} diff --git a/app/templates/clients.hbs b/app/templates/clients.hbs index 1bf17fe..d342341 100644 --- a/app/templates/clients.hbs +++ b/app/templates/clients.hbs @@ -1,13 +1,13 @@ diff --git a/bower.json b/bower.json index 7d35605..eabc898 100644 --- a/bower.json +++ b/bower.json @@ -21,6 +21,7 @@ "jquery": ">= 1.7.0 < 2.2.0" }, "devDependencies": { - "blanket": "~1.1.5" + "blanket": "~1.1.5", + "fxa-js-client": "~0.1.27" } } diff --git a/package.json b/package.json index a213f18..0840c61 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "./scripts/run_dev.js", "production": "NODE_ENV=production ember build --environment=production && node bin/server.js", "test": "ember test && grunt lint", + "test-functional": "./scripts/run_functional.sh", "postinstall": "node_modules/.bin/bower install --config.interactive=false -s", "outdated": "npm outdated --depth 0", "contributors": "git shortlog -s | cut -c8- | sort -f > CONTRIBUTORS" @@ -52,7 +53,9 @@ "intern": "^2.2.2", "load-grunt-tasks": "^1.0.0", "nodemon": "^1.2.1", - "opn": "^1.0.0" + "opn": "^1.0.0", + "selenium-standalone": "^2.44.0-1", + "xmlhttprequest": "git://github.com/zaach/node-XMLHttpRequest.git#onerror" }, "engines": { "node": "0.10.0", diff --git a/scripts/run_functional.sh b/scripts/run_functional.sh new file mode 100755 index 0000000..9cde4b1 --- /dev/null +++ b/scripts/run_functional.sh @@ -0,0 +1,8 @@ +node_modules/.bin/start-selenium > /dev/null 2>&1 & +SEL=$! + +sleep 3 +node_modules/.bin/intern-runner config=tests/functional/intern + +kill $SEL +wait diff --git a/tests/functional/all.js b/tests/functional/all.js index b328826..5ba24f1 100644 --- a/tests/functional/all.js +++ b/tests/functional/all.js @@ -1,5 +1,5 @@ define([ - './functional/all/clients' + './all/clients' ], function () { 'use strict'; -}); \ No newline at end of file +}); diff --git a/tests/functional/all/clients.js b/tests/functional/all/clients.js index c9564ba..790138d 100644 --- a/tests/functional/all/clients.js +++ b/tests/functional/all/clients.js @@ -6,36 +6,84 @@ define([ 'intern', 'intern!object', 'intern/chai!assert', - 'require' -], function (intern, registerSuite, assert, require) { + 'require', + 'bower_components/fxa-js-client/fxa-client', + 'intern/node_modules/dojo/node!xmlhttprequest' +], function (intern, registerSuite, assert, require, FxaClient, nodeXMLHttpRequest) { var config = intern.config; + var AUTH_SERVER_ROOT = 'http://127.0.0.1:9000/v1'; var APP_URL = 'http://127.0.0.1:10137'; + var client = new FxaClient(AUTH_SERVER_ROOT, { + xhr: nodeXMLHttpRequest.XMLHttpRequest + }); + var email = 'user' + Date.now() + '@mozilla.com'; + var PASSWORD = 'password'; registerSuite({ name: 'clients', 'login, add a client, update that client, delete it, logout': function () { + this.timeout = 60 * 1000 * 60 * 2; + return this.remote .get(require.toUrl(APP_URL)) + .setFindTimeout(config.pageLoadTimeout) + .then(function () { + return client.signUp(email, PASSWORD, { preVerified: true }); + }) .findByCssSelector('#login') .click() .end() - .findByCssSelector('.sign-up') - .click() - .end() - - .findByCssSelector('#fxa-signup-header') + .findByCssSelector('#fxa-signin-header') .end() .findByCssSelector('input.email') - .type('') + .type(email) + .end() + + .findByCssSelector('#password') + .type(PASSWORD) .end() .findByCssSelector('#submit-btn') .click() + .end() + + .findByCssSelector('#logout') + .end() + + .findByCssSelector('.new-client') + .click() + .end() + + .findByCssSelector('#inputTitle') + .type('sample') + .end() + + .findByCssSelector('#inputRedirect') + .type('sample') + .end() + + .findByCssSelector('#inputImage') + .type('sample') + .end() + + .findByCssSelector('#inputImage') + .type('sample') + .end() + + .findByCssSelector('.register-create') + .click() + .end() + + .findByCssSelector('#secret') + .getVisibleText() + .then(function (val) { + assert.isTrue(val.length > 0); + }) .end(); } diff --git a/tests/functional/intern.js b/tests/functional/intern.js index 6fa5709..3a916ab 100644 --- a/tests/functional/intern.js +++ b/tests/functional/intern.js @@ -1,5 +1,8 @@ define({ functionalSuites: [ 'tests/functional/all' ], - + environments: [ + { browserName: 'firefox' } + ], + pageLoadTimeout: 10000, excludeInstrumentation: /./ -}); \ No newline at end of file +});