2015-01-24 14:50:56 +01:00
|
|
|
import Ember from "ember";
|
2015-04-02 20:09:07 +02:00
|
|
|
import { module, test } from 'qunit';
|
2015-01-24 14:50:56 +01:00
|
|
|
import startApp from '../helpers/start-app';
|
|
|
|
var App;
|
|
|
|
|
2015-06-11 10:53:22 +02:00
|
|
|
module('Integration - participate in a poll', {
|
2015-04-02 20:09:07 +02:00
|
|
|
beforeEach: function() {
|
2015-01-24 14:50:56 +01:00
|
|
|
App = startApp();
|
|
|
|
},
|
2015-04-02 20:09:07 +02:00
|
|
|
afterEach: function() {
|
2015-01-24 14:50:56 +01:00
|
|
|
Ember.run(App, App.destroy);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-02 20:09:07 +02:00
|
|
|
test("add a user to a default poll", function(assert) {
|
|
|
|
assert.expect(2);
|
2015-01-24 17:14:57 +01:00
|
|
|
|
2015-01-24 14:50:56 +01:00
|
|
|
visit('/poll/defaultpoll?encryptionKey=0123456789abcdefghijklmnopqrstuvwxyzABC').then(function() {
|
|
|
|
fillIn('.newUserName input', 'Max Meier');
|
|
|
|
|
|
|
|
Ember.$('.newUser td').each(function(i, e) {
|
2015-01-24 18:31:21 +01:00
|
|
|
$('.newUserSelection').each(function(i, e){
|
|
|
|
if(i % 2 === 0) {
|
|
|
|
click( $('input[type=radio]', e)[0] );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
click( $('input[type=radio]', e)[1] );
|
|
|
|
}
|
|
|
|
});
|
2015-01-24 14:50:56 +01:00
|
|
|
});
|
2015-01-24 18:31:21 +01:00
|
|
|
|
|
|
|
var userSelecectionsTableLengthBefore = Ember.$('.user').length;
|
2015-01-24 14:50:56 +01:00
|
|
|
click('.newUser button');
|
2015-01-24 18:31:21 +01:00
|
|
|
|
2015-04-02 20:09:07 +02:00
|
|
|
assert.equal(Ember.$('.has-error').length, 0, "there is no validation error");
|
2015-01-24 18:31:21 +01:00
|
|
|
|
2015-01-24 14:50:56 +01:00
|
|
|
andThen(function(){
|
2015-04-02 20:09:07 +02:00
|
|
|
assert.equal( find('.user').length, userSelecectionsTableLengthBefore + 1, "user is added to user selections table");
|
2015-01-24 14:50:56 +01:00
|
|
|
});
|
|
|
|
});
|
2015-01-24 17:14:57 +01:00
|
|
|
});
|
2015-06-20 18:33:51 +02:00
|
|
|
|
|
|
|
test("participate in a poll using freetext", function(assert) {
|
|
|
|
assert.expect(6);
|
|
|
|
|
|
|
|
visit('/poll/freetext?encryptionKey=JU8dqNCJivwqfRpP28M5gpcqK0BsfgjUkDoXvTTX').then(function() {
|
|
|
|
fillIn('.newUserName input', 'Karl Käfer');
|
|
|
|
|
|
|
|
fillIn('.newUserSelection input:eq(0)', 'answer 1');
|
|
|
|
fillIn('.newUserSelection input:eq(1)', 'answer 2');
|
|
|
|
fillIn('.newUserSelection input:eq(2)', 'answer 3');
|
|
|
|
|
|
|
|
var userSelecectionsTableLengthBefore = Ember.$('.user').length;
|
|
|
|
click('.newUser button');
|
|
|
|
|
|
|
|
assert.equal(Ember.$('.has-error').length, 0, "there is no validation error");
|
|
|
|
|
|
|
|
andThen(function(){
|
|
|
|
assert.equal( find('.user').length, userSelecectionsTableLengthBefore + 1, "user is added to user selections table");
|
2015-06-20 18:42:28 +02:00
|
|
|
assert.equal( find('.user:last td:nth-child(1)').text(), 'Karl Käfer', "user name is correct");
|
|
|
|
assert.equal( find('.user:last td:nth-child(2)').text().trim(), 'answer 1', "answer 1 is correct");
|
|
|
|
assert.equal( find('.user:last td:nth-child(3)').text().trim(), 'answer 2', "answer 2 is correct");
|
|
|
|
assert.equal( find('.user:last td:nth-child(4)').text().trim(), 'answer 3', "answer 3 is correct");
|
2015-06-20 18:33:51 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|