From 8af5a9df093f49209ae422399e4a6beaa45924c1 Mon Sep 17 00:00:00 2001 From: jelhan Date: Wed, 26 Nov 2014 13:15:05 +0100 Subject: [PATCH] Integration Test for creation of a default poll --- app/adapters/application.js | 2 + app/templates/create/index.hbs | 2 +- app/templates/create/meta.hbs | 2 +- app/templates/create/options-datetime.hbs | 6 +-- app/templates/create/options.hbs | 6 +-- app/templates/create/settings.hbs | 2 +- tests/integrations/create-poll-test.js | 63 +++++++++++++++++++++++ 7 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 tests/integrations/create-poll-test.js diff --git a/app/adapters/application.js b/app/adapters/application.js index acc934e..4b3288e 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -6,6 +6,8 @@ export default DS.RESTAdapter.extend({ window.location.pathname // remove index.html if it's there .replace(/index.html$/, '') + // remove tests prefix which are added if tests are running + .replace(/tests/, '') // remove leading and trailing slash .replace(/\/$/, '') // add api.php diff --git a/app/templates/create/index.hbs b/app/templates/create/index.hbs index 3e0f97d..37c0de2 100644 --- a/app/templates/create/index.hbs +++ b/app/templates/create/index.hbs @@ -9,5 +9,5 @@ }} {{/form-for}} - + \ No newline at end of file diff --git a/app/templates/create/meta.hbs b/app/templates/create/meta.hbs index 702cea4..01c65a8 100644 --- a/app/templates/create/meta.hbs +++ b/app/templates/create/meta.hbs @@ -11,6 +11,6 @@ }} {{/form-for}} - + \ No newline at end of file diff --git a/app/templates/create/options-datetime.hbs b/app/templates/create/options-datetime.hbs index 8b8b365..eac44f5 100644 --- a/app/templates/create/options-datetime.hbs +++ b/app/templates/create/options-datetime.hbs @@ -32,9 +32,9 @@ {{/input}} {{/form-for}} - + - + - + \ No newline at end of file diff --git a/app/templates/create/options.hbs b/app/templates/create/options.hbs index af3dd65..f56fe56 100644 --- a/app/templates/create/options.hbs +++ b/app/templates/create/options.hbs @@ -18,9 +18,9 @@ {{/input}} {{/form-for}} - + - + {{/if}} @@ -42,7 +42,7 @@ }} {{/form-for}} - + {{/if}} \ No newline at end of file diff --git a/app/templates/create/settings.hbs b/app/templates/create/settings.hbs index 6d8f2c3..9627cb4 100644 --- a/app/templates/create/settings.hbs +++ b/app/templates/create/settings.hbs @@ -15,5 +15,5 @@ }} {{/form-for}} - + \ No newline at end of file diff --git a/tests/integrations/create-poll-test.js b/tests/integrations/create-poll-test.js new file mode 100644 index 0000000..2887c18 --- /dev/null +++ b/tests/integrations/create-poll-test.js @@ -0,0 +1,63 @@ +import Ember from "ember"; +import { test } from 'ember-qunit'; +import startApp from '../helpers/start-app'; +/* global moment */ +var App; + +module('Integration - create poll', { + setup: function() { + App = startApp(); + }, + teardown: function() { + Ember.run(App, App.destroy); + } +}); + +test("default poll", function() { + expect(8); + + visit('/create').then(function() { + click('.button-next'); + + andThen(function(){ + equal(currentPath(), 'create.meta'); + + fillIn('input[name="title"]', 'default poll'); + click('.button-next'); + + andThen(function(){ + equal(currentPath(), 'create.options'); + + // select days in calendar + // today and last day on current calendar page + click('.datepicker tbody td.today'); + click('.datepicker tbody tr:last-child td:last-child'); + + click('.button-next'); + + andThen(function(){ + equal(currentPath(), 'create.settings'); + + click('.button-next'); + + andThen(function(){ + equal(currentPath(), 'poll'); + + equal(find('.meta-data .title').text(), 'default poll'); + equal(find('.meta-data .description').text(), ''); + + // check that there are two options + // head of user selections table is options + leading column (user names) + last column (buttons) + equal(find('.user-selections-table thead tr th').length, 4); + + // check that current day is first option + equal(find( + Ember.$('.user-selections-table thead tr th')[1]).text().trim(), + moment().format(moment.localeData().longDateFormat( 'LLLL' ).replace('LT' , '')).trim() + ); + }); + }); + }); + }); + }); +}); \ No newline at end of file