/
story-list.js
146 lines (124 loc) · 4.87 KB
/
story-list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
'use strict';
var _ = require('underscore');
var assert = require('selenium-webdriver/testing/assert');
var firefox = require('selenium-webdriver/firefox');
var phantomjs = require('selenium-webdriver/phantomjs');
var test = require('selenium-webdriver/testing');
var until = require('selenium-webdriver').until;
var helpers = require('./helpers');
test.describe('StoryListView', function() {
var dr;
this.timeout(10000);
test.beforeEach(function() {
dr = new firefox.Driver();
dr.get(helpers.testUrl + '#stories');
});
test.afterEach(function() {
dr.quit();
});
test.it('Is on the #stories route', function() {
assert(dr.isElementPresent({ css: '#regions #storyListView' })).isTrue();
});
test.it('Shows initial message when no stories are saved', function() {
dr.wait(until.elementLocated({ css: '.noStories' }))
.then(function() {
var noStories = dr.findElement({ css: '.noStories' });
dr.wait(until.elementIsVisible(noStories));
});
});
test.it('Can cancel out of adding a new story', function() {
var addButton = dr.findElement({ css: '.addStory' });
var bubble = addButton
.findElement({ xpath: '../..' })
.findElement({ css: '.bubble '});
addButton.click();
dr.wait(until.elementIsVisible(bubble));
dr.findElement({ css: '.cancelAdd' }).click();
dr.wait(until.elementIsNotVisible(bubble));
});
test.it('Does not allow blank story names', function() {
var addButton = dr.findElement({ css: '.addStory' });
var bubble = addButton
.findElement({ xpath: '../..' })
.findElement({ css: '.bubble '});
addButton.click();
dr.wait(until.elementIsVisible(bubble));
dr.findElement({ css: '.add' }).click();
assert(bubble.isDisplayed()).isTrue();
});
test.it('Can add a new story', function() {
helpers.createStory(dr, true);
dr.wait(until.elementLocated({ css: '.storyName' }));
assert(
dr.findElement({ css: '.storyName' }).getText()
).equalTo(helpers.shortUni);
});
test.it('Can play a story', function() {
helpers.createStory(dr);
dr.findElement({ css: '.story button[data-bubble="toggle"]' }).click();
dr.findElement({ css: '.story .menu .play' }).click();
dr.getAllWindowHandles(function(windows) {
assert(_.contains(windows, helpers.shortUni)).isTrue();
});
});
test.it('Can test a story', function() {
helpers.createStory(dr);
dr.findElement({ css: '.story button[data-bubble="toggle"]' }).click();
dr.findElement({ css: '.story .menu .test' }).click();
dr.getAllWindowHandles(function(windows) {
assert(_.contains(windows, helpers.shortUni)).isTrue();
});
});
test.it('Can rename a story', function() {
helpers.createStory(dr);
dr.findElement({ css: '.story button[data-bubble="toggle"]' }).click();
dr.findElement({ css: '.story .menu .rename' }).click();
dr.wait(until.elementLocated({ css: '.prompt input[type="text"]' }));
var promptEl = dr.findElement({ css: '.prompt' });
dr
.findElement({ css: '.prompt input[type="text"]' })
.sendKeys('123 ' + helpers.shortUni);
dr
.findElement({ css: '.prompt button[data-action="yes"]' })
.click();
dr.wait(until.elementIsNotVisible(promptEl));
assert(
dr.findElement({ css: '.story h2' }).getText()
).equalTo('123 ' + helpers.shortUni);
});
test.it('Can cancel out of deleting a story', function() {
helpers.createStory(dr);
dr.findElement({ css: '.story button[data-bubble="toggle"]' }).click();
dr.findElement({ css: '.story .menu .confirmDelete' }).click();
dr.wait(until.elementLocated({ css: '.modal.confirm.appear' }));
var cancelButton = dr.findElement({
css: '.modal.confirm.appear button.cancel',
});
dr.wait(until.elementIsVisible(cancelButton)).then(function() {
var confirmEl = dr.findElement({ css: '.modal.confirm.appear' });
cancelButton.click();
dr.wait(until.elementIsNotVisible(confirmEl));
assert(dr.isElementPresent({ css: '.story h2' })).isTrue();
});
});
test.it('Can delete a story', function() {
helpers.createStory(dr);
dr.findElement({ css: '.story button[data-bubble="toggle"]' }).click();
dr.findElement({ css: '.story .menu .confirmDelete' }).click();
dr.wait(until.elementLocated({ css: '.modal.confirm.appear' }));
var deleteButton = dr.findElement({
css: '.modal.confirm.appear button[data-action="yes"]',
});
dr.wait(until.elementIsVisible(deleteButton)).then(function() {
var confirmEl = dr.findElement({ css: '.modal.confirm.appear' });
deleteButton.click();
dr.wait(until.elementIsNotVisible(confirmEl));
var noStories = dr.findElement({ css: '.noStories' });
dr.wait(until.elementIsVisible(noStories));
});
});
test.it('Can generate an archive', function() {
helpers.createStory(dr);
dr.findElement({ css: '.saveArchive' }).click();
});
});