01f9b6e61f
started replacing ember-easy-form-extensions by ember-form-master-2000 and ember-validations by ember-cp-validations using ember-form-master-2000 in old 0.2 release cause newer releases does not work with ember 0.12 should move to ember 2.x as soon as possible therefore ember-easy-form-extensions has to be dropped and ember-i18n been updated part of #76
229 lines
5.8 KiB
JavaScript
229 lines
5.8 KiB
JavaScript
import Ember from 'ember';
|
|
import { module, test } from 'qunit';
|
|
import startApp from 'croodle/tests/helpers/start-app';
|
|
import Pretender from 'pretender';
|
|
import serverGetPolls from '../helpers/server-get-polls';
|
|
/* jshint proto: true */
|
|
/* global jstz, moment, start, stop */
|
|
|
|
var application, server;
|
|
|
|
module('Acceptance | view poll', {
|
|
beforeEach: function() {
|
|
application = startApp();
|
|
application.__container__.lookup('adapter:application').__proto__.namespace = '';
|
|
|
|
server = new Pretender();
|
|
},
|
|
afterEach: function() {
|
|
server.shutdown();
|
|
|
|
Ember.run(application, 'destroy');
|
|
}
|
|
});
|
|
|
|
test('view poll url', function(assert) {
|
|
var id = 'test',
|
|
encryptionKey = 'abcdefghijklmnopqrstuvwxyz012345789';
|
|
|
|
server.get('/polls/' + id, function() {
|
|
return serverGetPolls({ id: id }, encryptionKey);
|
|
});
|
|
|
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey);
|
|
andThen(function() {
|
|
assert.equal(
|
|
find('.share-link .link a').text(),
|
|
window.location.href,
|
|
'share link is shown'
|
|
);
|
|
});
|
|
});
|
|
|
|
test('view a poll with dates', function(assert) {
|
|
var id = 'test',
|
|
encryptionKey = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
|
|
server.get('/polls/' + id, function() {
|
|
return serverGetPolls(
|
|
{
|
|
id: id,
|
|
options: [
|
|
{title: '2015-12-12'},
|
|
{title: '2016-01-01'}
|
|
]
|
|
}, encryptionKey
|
|
);
|
|
});
|
|
|
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey).then(function() {
|
|
pollHasOptions(assert, [
|
|
moment('2015-12-12').format(
|
|
moment.localeData().longDateFormat('LLLL')
|
|
.replace(
|
|
moment.localeData().longDateFormat('LT'), '')
|
|
.trim()
|
|
),
|
|
moment('2016-01-01').format(
|
|
moment.localeData().longDateFormat('LLLL')
|
|
.replace(
|
|
moment.localeData().longDateFormat('LT'), '')
|
|
.trim()
|
|
)
|
|
]);
|
|
});
|
|
});
|
|
|
|
test('view a poll with dates and times', function(assert) {
|
|
var id = 'test',
|
|
encryptionKey = 'abcdefghijklmnopqrstuvwxyz0123456789',
|
|
timezone = jstz.determine().name();
|
|
|
|
server.get('/polls/' + id, function() {
|
|
return serverGetPolls(
|
|
{
|
|
id: id,
|
|
isDateTime: true,
|
|
options: [
|
|
{title: '2015-12-12T11:11:00.000Z'},
|
|
{title: '2015-12-12T13:13:00.000Z'},
|
|
{title: '2016-01-01T11:11:00.000Z'}
|
|
],
|
|
timezone: timezone
|
|
}, encryptionKey
|
|
);
|
|
});
|
|
|
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey).then(function() {
|
|
pollHasOptions(assert, [
|
|
// full date
|
|
moment.tz('2015-12-12T11:11:00.000Z', timezone).format('LLLL'),
|
|
// only time cause day is repeated
|
|
moment.tz('2015-12-12T13:13:00.000Z', timezone).format('LT'),
|
|
// full date cause day changed
|
|
moment.tz('2016-01-01T11:11:00.000Z', timezone).format('LLLL')
|
|
]);
|
|
});
|
|
});
|
|
|
|
test('view a poll while timezone differs from the one poll got created in and choose local timezone', function(assert) {
|
|
var id = 'test',
|
|
encryptionKey = 'abcdefghijklmnopqrstuvwxyz0123456789',
|
|
timezoneLocal = jstz.determine().name(),
|
|
timezonePoll;
|
|
|
|
if(timezoneLocal !== 'America/Caracas') {
|
|
timezonePoll = 'America/Caracas';
|
|
}
|
|
else {
|
|
timezonePoll = 'Europe/Moscow';
|
|
}
|
|
|
|
server.get('/polls/' + id, function() {
|
|
return serverGetPolls(
|
|
{
|
|
id: id,
|
|
isDateTime: true,
|
|
options: [
|
|
{title: '2015-12-12T11:11:00.000Z'},
|
|
{title: '2016-01-01T11:11:00.000Z'}
|
|
],
|
|
timezone: timezonePoll
|
|
}, encryptionKey
|
|
);
|
|
});
|
|
|
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey).then(function() {
|
|
stop();
|
|
Ember.run.later(function(){
|
|
start();
|
|
|
|
assert.equal(
|
|
find('.modal').css('display'),
|
|
'block',
|
|
'user gets asked which timezone should be used'
|
|
);
|
|
|
|
click('.modal button.use-local-timezone');
|
|
|
|
andThen(function() {
|
|
pollHasOptions(assert, [
|
|
moment.tz('2015-12-12T11:11:00.000Z', timezoneLocal).format('LLLL'),
|
|
moment.tz('2016-01-01T11:11:00.000Z', timezoneLocal).format('LLLL')
|
|
]);
|
|
|
|
stop();
|
|
Ember.run.later(function(){
|
|
start();
|
|
|
|
assert.equal(
|
|
find('.modal').css('display'),
|
|
'none',
|
|
'modal is closed'
|
|
);
|
|
}, 1000);
|
|
});
|
|
}, 1000);
|
|
});
|
|
});
|
|
|
|
test('view a poll while timezone differs from the one poll got created in and choose poll timezone', function(assert) {
|
|
var id = 'test',
|
|
encryptionKey = 'abcdefghijklmnopqrstuvwxyz0123456789',
|
|
timezoneLocal = jstz.determine().name(),
|
|
timezonePoll;
|
|
|
|
if(timezoneLocal !== 'America/Caracas') {
|
|
timezonePoll = 'America/Caracas';
|
|
}
|
|
else {
|
|
timezonePoll = 'Europe/Moscow';
|
|
}
|
|
|
|
server.get('/polls/' + id, function() {
|
|
return serverGetPolls(
|
|
{
|
|
id: id,
|
|
isDateTime: true,
|
|
options: [
|
|
{title: '2015-12-12T11:11:00.000Z'},
|
|
{title: '2016-01-01T11:11:00.000Z'}
|
|
],
|
|
timezone: timezonePoll
|
|
}, encryptionKey
|
|
);
|
|
});
|
|
|
|
visit('/poll/' + id + '?encryptionKey=' + encryptionKey).then(function() {
|
|
stop();
|
|
Ember.run.later(function(){
|
|
start();
|
|
|
|
assert.equal(
|
|
find('.modal').css('display'),
|
|
'block',
|
|
'user gets asked which timezone should be used'
|
|
);
|
|
|
|
click('.modal button.use-poll-timezone');
|
|
|
|
andThen(function() {
|
|
pollHasOptions(assert, [
|
|
moment.tz('2015-12-12T11:11:00.000Z', timezonePoll).format('LLLL'),
|
|
moment.tz('2016-01-01T11:11:00.000Z', timezonePoll).format('LLLL')
|
|
]);
|
|
|
|
stop();
|
|
Ember.run.later(function(){
|
|
start();
|
|
|
|
assert.equal(
|
|
find('.modal').css('display'),
|
|
'none',
|
|
'modal is closed'
|
|
);
|
|
}, 1000);
|
|
});
|
|
}, 1000);
|
|
});
|
|
});
|