Skip to content

Commit 8a32f1f

Browse files
committed
Closes #87.
1 parent 6fe75cf commit 8a32f1f

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"ember-cli-app-version": "^1.0.0",
3232
"ember-cli-babel": "^5.1.5",
3333
"ember-cli-bootstrap-datepicker": "0.5.3",
34+
"ember-cli-browser-navigation-button-test-helper": "0.0.1",
3435
"ember-cli-build-info": "0.2.0",
3536
"ember-cli-chart": "jelhan/ember-cli-chart#87cc4f125ce69e22197c992206cca700edc70267",
3637
"ember-cli-content-security-policy": "0.4.0",

tests/.jshintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
"pollHasUsersCount",
3131
"pollParticipate",
3232
"switchTab",
33-
"t"
33+
"t",
34+
"backButton",
35+
"forwardButton",
36+
"setupBrowserNavigationButtons"
3437
],
3538
"node": false,
3639
"browser": false,

tests/acceptance/create-a-poll-test.js

+104
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,107 @@ test('create a poll with only one day and multiple times', function(assert) {
425425
});
426426
});
427427
});
428+
429+
test('create a poll and using back button (find a date)', function(assert) {
430+
let days = [
431+
moment().add(1, 'day'),
432+
moment().add(1, 'week')
433+
];
434+
const dayFormat = moment.localeData().longDateFormat('LLLL')
435+
.replace(
436+
moment.localeData().longDateFormat('LT'), '')
437+
.trim();
438+
439+
setupBrowserNavigationButtons();
440+
441+
pageCreateIndex
442+
.visit();
443+
444+
andThen(function() {
445+
pageCreateIndex
446+
.next();
447+
448+
andThen(function() {
449+
assert.equal(currentPath(), 'create.meta');
450+
451+
pageCreateMeta
452+
.title('default poll')
453+
.description('a sample description')
454+
.next();
455+
456+
andThen(function() {
457+
assert.equal(currentPath(), 'create.options');
458+
459+
pageCreateOptions
460+
.dateOptions(days);
461+
pageCreateOptions
462+
.next();
463+
464+
andThen(function() {
465+
assert.equal(currentPath(), 'create.options-datetime');
466+
467+
assert.deepEqual(
468+
pageCreateOptionsDatetime.days().labels,
469+
days.map((day) => day.format(dayFormat)),
470+
'time inputs having days as label'
471+
);
472+
pageCreateOptionsDatetime.days(1).times(0).time('10:00');
473+
474+
backButton();
475+
476+
andThen(() => {
477+
assert.equal(currentPath(), 'create.options');
478+
assert.deepEqual(
479+
pageCreateOptions.dateOptions().map((date) => date.toISOString()),
480+
days.map((day) => day.toISOString()),
481+
'days are still present after back button is used'
482+
);
483+
484+
pageCreateOptions
485+
.next();
486+
487+
andThen(() => {
488+
assert.equal(currentPath(), 'create.options-datetime');
489+
490+
pageCreateOptionsDatetime
491+
.next();
492+
493+
andThen(function() {
494+
assert.equal(currentPath(), 'create.settings');
495+
496+
pageCreateSettings
497+
.next();
498+
499+
andThen(function() {
500+
assert.equal(currentPath(), 'poll.participation');
501+
assert.ok(
502+
pagePollParticipation.urlIsValid() === true,
503+
'poll url is valid'
504+
);
505+
assert.equal(
506+
pagePollParticipation.title,
507+
'default poll',
508+
'poll title is correct'
509+
);
510+
assert.equal(
511+
pagePollParticipation.description,
512+
'a sample description',
513+
'poll description is correct'
514+
);
515+
assert.deepEqual(
516+
pagePollParticipation.options().labels,
517+
[
518+
days[0].format(dayFormat),
519+
days[1].hour(10).minute(0).format('LLLL')
520+
],
521+
'options are correctly labeled'
522+
);
523+
});
524+
});
525+
});
526+
});
527+
});
528+
});
529+
});
530+
});
531+
});

tests/helpers/start-app.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import './poll-has-users';
66
import './poll-participate';
77
import './switch-tab';
88
import './t';
9+
import './browser-navigation-buttons';
910

1011
registerAcceptanceTestHelpers();
1112

0 commit comments

Comments
 (0)