decide.nolog.cz/tests/integration/legacy-support-test.js

155 lines
3.8 KiB
JavaScript
Raw Normal View History

2015-10-17 15:44:27 +02:00
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'croodle/tests/helpers/start-app';
import pagePollParticipation from 'croodle/tests/pages/poll/participation';
2015-10-17 15:44:27 +02:00
/* global moment */
2016-01-20 03:19:10 +01:00
let application;
2015-10-17 15:44:27 +02:00
module('Integration | legacy support', {
beforeEach() {
2015-10-17 15:44:27 +02:00
application = startApp();
},
afterEach() {
2015-10-17 15:44:27 +02:00
Ember.run(application, 'destroy');
}
});
test('show a default poll created with v0.3.0', function(assert) {
const id = 'JlHpRs0Pzi';
const encryptionKey = '5MKFuNTKILUXw6RuqkAw6ooZw4k3mWWx98ZQw8vH';
const timezone = 'Europe/Berlin';
2016-01-20 03:19:10 +01:00
visit(`/poll/${id}?encryptionKey=${encryptionKey}`);
2015-10-17 15:44:27 +02:00
andThen(function() {
assert.equal(
pagePollParticipation.title,
'default poll created with v0.3.0'
);
assert.equal(
pagePollParticipation.description,
'used for integration tests'
);
assert.deepEqual(
pagePollParticipation.options().labels,
[
moment.tz('2015-12-24T17:00:00.000Z', timezone).format('LLLL'),
moment.tz('2015-12-24T19:00:00.000Z', timezone).format('LT'),
moment.tz('2015-12-31T22:59:00.000Z', timezone).format('LLLL')
]
);
assert.deepEqual(
pagePollParticipation.options().answers,
[
t('answerTypes.yes.label').toString(),
t('answerTypes.maybe.label').toString(),
t('answerTypes.no.label').toString()
]
);
2015-10-17 15:44:27 +02:00
switchTab('evaluation');
andThen(function() {
assert.equal(currentPath(), 'poll.evaluation');
pollHasUser(assert,
'Fritz Bauer',
[
2015-11-20 02:18:19 +01:00
t('answerTypes.yes.label'),
t('answerTypes.no.label'),
t('answerTypes.no.label')
]
);
pollHasUser(assert,
'Lothar Hermann',
[
2015-11-20 02:18:19 +01:00
t('answerTypes.maybe.label'),
t('answerTypes.yes.label'),
t('answerTypes.no.label')
]
);
switchTab('participation');
andThen(function() {
assert.equal(currentPath(), 'poll.participation');
pollParticipate('Hermann Langbein', ['yes', 'maybe', 'yes']);
andThen(function() {
assert.equal(currentPath(), 'poll.evaluation');
pollHasUser(assert,
'Hermann Langbein',
[
2015-11-20 02:18:19 +01:00
t('answerTypes.yes.label'),
t('answerTypes.maybe.label'),
t('answerTypes.yes.label')
]
);
});
});
});
2015-10-17 15:44:27 +02:00
});
});
2015-10-19 11:19:01 +02:00
test('find a poll using free text created with v0.3.0', function(assert) {
const id = 'PjW3XwbuRc';
const encryptionKey = 'Rre6dAGOYLW9gYKOP4LhX7Qwfhe5Th3je0uKDtyy';
2016-01-20 03:19:10 +01:00
visit(`/poll/${id}?encryptionKey=${encryptionKey}`);
2015-10-19 11:19:01 +02:00
andThen(function() {
assert.equal(
pagePollParticipation.title,
'Which cake for birthday?'
);
assert.equal(
pagePollParticipation.description,
''
);
assert.deepEqual(
pagePollParticipation.options().labels,
[
'apple pie',
'pecan pie',
'plum pie'
]
);
2015-10-19 11:19:01 +02:00
switchTab('evaluation');
2015-10-19 11:19:01 +02:00
andThen(function() {
assert.equal(currentPath(), 'poll.evaluation');
2015-10-19 11:19:01 +02:00
pollHasUser(assert,
'Paul Levi',
2015-10-19 11:19:01 +02:00
[
'would be great!',
'no way',
'if I had to'
2015-10-19 11:19:01 +02:00
]
);
switchTab('participation');
andThen(function() {
assert.equal(currentPath(), 'poll.participation');
pollParticipate('Hermann Langbein', ["I don't care", 'would be awesome', "can't imagine anything better"]);
andThen(function() {
assert.equal(currentPath(), 'poll.evaluation');
pollHasUser(assert,
'Hermann Langbein',
[
"I don't care",
'would be awesome',
"can't imagine anything better"
]
);
});
});
2015-10-19 11:19:01 +02:00
});
});
});