2016-01-28 12:34:56 +01:00
|
|
|
import Ember from 'ember';
|
2015-08-19 11:29:30 +02:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import startApp from '../helpers/start-app';
|
2015-11-24 01:37:37 +01:00
|
|
|
import moment from 'moment';
|
2016-04-08 21:48:22 +02:00
|
|
|
import pageCreateIndex from 'croodle/tests/pages/create/index';
|
|
|
|
import pageCreateMeta from 'croodle/tests/pages/create/meta';
|
|
|
|
import pageCreateOptions from 'croodle/tests/pages/create/options';
|
|
|
|
import pageCreateOptionsDatetime from 'croodle/tests/pages/create/options-datetime';
|
|
|
|
import pageCreateSettings from 'croodle/tests/pages/create/settings';
|
|
|
|
import pagePollParticipation from 'croodle/tests/pages/poll/participation';
|
2015-08-19 11:29:30 +02:00
|
|
|
/* jshint proto: true */
|
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
let application;
|
2015-08-19 11:29:30 +02:00
|
|
|
|
|
|
|
module('Integration', {
|
2016-01-28 12:34:56 +01:00
|
|
|
beforeEach() {
|
2015-08-19 11:29:30 +02:00
|
|
|
application = startApp();
|
2015-11-24 01:37:37 +01:00
|
|
|
moment.locale(
|
|
|
|
application.__container__.lookup('service:i18n').get('locale')
|
|
|
|
);
|
2015-08-19 11:29:30 +02:00
|
|
|
},
|
2016-01-28 12:34:56 +01:00
|
|
|
afterEach() {
|
2015-08-19 11:29:30 +02:00
|
|
|
Ember.run(application, 'destroy');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
test('create a default poll and participate', function(assert) {
|
|
|
|
const dates =
|
2015-11-12 15:52:14 +01:00
|
|
|
[
|
|
|
|
moment().add(1, 'day'),
|
|
|
|
moment().add(1, 'week'),
|
|
|
|
moment().add(1, 'month')
|
|
|
|
];
|
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
const formattedDates =
|
2015-11-12 15:52:14 +01:00
|
|
|
dates.map((date) => {
|
|
|
|
return date.format(
|
|
|
|
moment.localeData().longDateFormat('LLLL')
|
|
|
|
.replace(
|
|
|
|
moment.localeData().longDateFormat('LT'), '')
|
|
|
|
.trim()
|
|
|
|
);
|
|
|
|
});
|
2015-11-16 14:28:00 +01:00
|
|
|
|
2016-04-08 21:48:22 +02:00
|
|
|
pageCreateIndex
|
|
|
|
.visit();
|
|
|
|
|
|
|
|
andThen(function() {
|
|
|
|
pageCreateIndex
|
|
|
|
.next();
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
andThen(function() {
|
2015-08-19 11:29:30 +02:00
|
|
|
assert.equal(currentPath(), 'create.meta');
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-04-08 21:48:22 +02:00
|
|
|
pageCreateMeta
|
|
|
|
.title('default poll')
|
|
|
|
.next();
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
andThen(function() {
|
2015-08-19 11:29:30 +02:00
|
|
|
assert.equal(currentPath(), 'create.options');
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-05-21 17:17:08 +02:00
|
|
|
assert.notOk(
|
|
|
|
pageCreateOptions.dateHasError,
|
|
|
|
'no validation error shown before user interaction'
|
|
|
|
);
|
|
|
|
|
2016-04-08 21:48:22 +02:00
|
|
|
pageCreateOptions
|
|
|
|
.next();
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
andThen(function() {
|
2016-05-21 17:17:08 +02:00
|
|
|
assert.equal(
|
|
|
|
currentPath(),
|
|
|
|
'create.options',
|
|
|
|
'transition is aborted due to validation error (no day selected)'
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
pageCreateOptions.dateHasError,
|
|
|
|
'validation error is shown if no day is selected (after user interaction)'
|
|
|
|
);
|
|
|
|
|
|
|
|
pageCreateOptions
|
|
|
|
.dateOptions(dates);
|
|
|
|
pageCreateOptions
|
2016-04-08 21:48:22 +02:00
|
|
|
.next();
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
andThen(function() {
|
2016-05-21 17:17:08 +02:00
|
|
|
assert.equal(currentPath(), 'create.options-datetime');
|
2016-02-16 02:26:27 +01:00
|
|
|
|
2016-05-21 17:17:08 +02:00
|
|
|
pageCreateOptionsDatetime
|
2016-04-08 21:48:22 +02:00
|
|
|
.next();
|
2015-11-02 23:02:59 +01:00
|
|
|
|
2016-01-28 12:34:56 +01:00
|
|
|
andThen(function() {
|
2016-05-21 17:17:08 +02:00
|
|
|
assert.equal(currentPath(), 'create.settings');
|
|
|
|
|
|
|
|
pageCreateSettings
|
|
|
|
.next();
|
|
|
|
|
2016-02-16 02:26:27 +01:00
|
|
|
andThen(function() {
|
2016-05-21 17:17:08 +02:00
|
|
|
assert.equal(currentPath(), 'poll.participation');
|
|
|
|
assert.ok(
|
|
|
|
pagePollParticipation.urlIsValid() === true,
|
|
|
|
'poll url is valid'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
pagePollParticipation.title,
|
|
|
|
'default poll',
|
|
|
|
'title is correct'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
pagePollParticipation.description,
|
|
|
|
'',
|
|
|
|
'description is correct'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
pagePollParticipation.options().labels,
|
|
|
|
formattedDates,
|
|
|
|
'option labels are correct'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
pagePollParticipation.options().answers,
|
2016-02-16 02:26:27 +01:00
|
|
|
[
|
2016-05-21 17:17:08 +02:00
|
|
|
t('answerTypes.yes.label').toString(),
|
|
|
|
t('answerTypes.no.label').toString()
|
|
|
|
],
|
|
|
|
'option labels are correct'
|
2016-02-16 02:26:27 +01:00
|
|
|
);
|
2016-05-21 17:17:08 +02:00
|
|
|
|
|
|
|
pollParticipate('Max Hoelz', ['no', 'no', 'yes']);
|
|
|
|
andThen(function() {
|
|
|
|
assert.equal(currentPath(), 'poll.evaluation');
|
|
|
|
pollHasUsersCount(assert, 1);
|
|
|
|
pollHasUser(
|
|
|
|
assert,
|
|
|
|
'Max Hoelz',
|
|
|
|
[
|
|
|
|
t('answerTypes.no.label'),
|
|
|
|
t('answerTypes.no.label'),
|
|
|
|
t('answerTypes.yes.label')
|
|
|
|
]
|
|
|
|
);
|
|
|
|
});
|
2016-02-16 02:26:27 +01:00
|
|
|
});
|
2015-10-18 14:04:04 +02:00
|
|
|
});
|
2015-08-19 11:29:30 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|