forked from NUBIC/surveyor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurveyor_dependencies.feature
330 lines (291 loc) · 9.45 KB
/
surveyor_dependencies.feature
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
Feature: Survey dependencies
As a survey participant
I want to see dependent question if conditions are met
And I do now want to see dependent question if conditions are not met
@javascript
Scenario: "Simple question dependencies"
Given the survey
"""
survey "Anybody" do
section "First" do
q_1 "Anybody there?", :pick => :one
a_1 "Yes"
a_2 "No"
q_2 "Who are you??"
dependency :rule => "A"
condition_A :q_1, "==", :a_1
a :string
q_3 "Weird.. Must be talking to myself..", :pick => :one
dependency :rule => "A"
condition_A :q_1, "==", :a_2
a "Maybe"
a "Huh?"
end
section "Second" do
q "Anything else?"
a :string
end
end
"""
When I go to the surveys page
And I start the "Anybody" survey
Then I should see "Anybody there?"
And the element "#q_2" should be hidden
And the element "#q_3" should be hidden
When I choose "Yes"
Then the element "#q_2" should not be hidden
And the element "#q_3" should be hidden
When I choose "No"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
When I press "Second"
And I press "First"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
@javascript
Scenario: "Dependencies inside of the question group"
Given the survey
"""
survey "Anybody" do
section "First" do
group "" do
q_1 "Anybody there?", :pick => :one
a_1 "Yes"
a_2 "No"
q_2 "Who are you??"
dependency :rule => "A"
condition_A :q_1, "==", :a_1
a :string
q_3 "Weird.. Must be talking to myself..", :pick => :one
dependency :rule => "A"
condition_A :q_1, "==", :a_2
a "Maybe"
a "Huh?"
end
end
section "Second" do
q "Anything else?"
a :string
end
end
"""
When I go to the surveys page
And I start the "Anybody" survey
Then I should see "Anybody there?"
And the element "#q_2" should be hidden
And the element "#q_3" should be hidden
When I choose "Yes"
Then the element "#q_2" should not be hidden
And the element "#q_3" should be hidden
When I choose "No"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
When I press "Second"
And I press "First"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
@javascript
Scenario: "Dependencies inside of the 'inline' question group"
Given the survey
"""
survey "Anybody" do
section "First" do
group "", :display_type => :inline do
q_1 "Anybody there?", :pick => :one
a_1 "Yes"
a_2 "No"
q_2 "Who are you??"
dependency :rule => "A"
condition_A :q_1, "==", :a_1
a :string
q_3 "Weird.. Must be talking to myself..", :pick => :one
dependency :rule => "A"
condition_A :q_1, "==", :a_2
a "Maybe"
a "Huh?"
end
end
section "Second" do
q "Anything else?"
a :string
end
end
"""
When I go to the surveys page
And I start the "Anybody" survey
Then I should see "Anybody there?"
And the element "#q_2" should be hidden
And the element "#q_3" should be hidden
When I choose "Yes"
Then the element "#q_2" should not be hidden
And the element "#q_3" should be hidden
When I choose "No"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
When I press "Second"
And I press "First"
Then the element "#q_3" should not be hidden
And the element "#q_2" should be hidden
@javascript
Scenario: "Dependency on group"
Given the survey
"""
survey "Anybody" do
section "First" do
q_1 "Anybody there?", :pick => :one
a_1 "Yes"
a_2 "No"
group "Who are you?", :display_type => :inline do
dependency :rule => "A"
condition_A :q_1, "==", :a_1
q_2 "Name yourself"
a :string
q_3 "Why are you here?"
a :string
end
group "" do
dependency :rule => "A"
condition_A :q_1, "==", :a_2
q_4 "Who is talking?", :pick => :one
a "You are"
a "Are you nuts?"
end
end
section "Second" do
q "Anything else?"
a :string
end
end
"""
When I go to the surveys page
And I start the "Anybody" survey
Then I should see "Anybody there?"
And the element "#q_2" should be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should be hidden
When I choose "Yes"
Then the element "#q_2" should not be hidden
And the element "#q_3" should not be hidden
And the element "#q_4" should be hidden
When I choose "No"
Then the element "#q_2" should be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should not be hidden
When I press "Second"
And I press "First"
Then the element "#q_2" should be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should not be hidden
@javascript
Scenario: "Dependency on question in dependent group"
Given the survey
"""
survey "Anybody" do
section "First" do
q_1 "Anybody there?", :pick => :one
a_1 "Yes"
a_2 "No"
group "Who are you?" do
dependency :rule => "A"
condition_A :q_1, "==", :a_1
q_2 "Are you..", :pick => :one
a_1 "Human"
a_2 "Dancer"
a_3 "Owner Of The World"
q_3 "Why are you here?"
dependency :rule => "A"
condition_A :q_2, "==", :a_1
a :string
q_4 "Which one?"
dependency :rule => "A"
condition_A :q_2, "==", :a_3
a :string
end
group "" do
dependency :rule => "A"
condition_A :q_1, "==", :a_2
q_5 "Who is talking?", :pick => :one
a "You are"
a "Are you nuts?"
end
end
section "Second" do
q "Anything else?"
a :string
end
end
"""
When I go to the surveys page
And I start the "Anybody" survey
Then I should see "Anybody there?"
And the element "#q_2" should be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should be hidden
And the element "#q_5" should be hidden
When I choose "Yes"
Then the element "#q_2" should not be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should be hidden
And the element "#q_5" should be hidden
When I choose "Human"
Then the element "#q_3" should not be hidden
And the element "#q_4" should be hidden
And the element "#q_5" should be hidden
When I choose "Owner Of The World"
Then the element "#q_3" should be hidden
And the element "#q_4" should not be hidden
And the element "#q_5" should be hidden
When I choose "No"
Then the element "#q_2" should be hidden
And the element "#q_3" should be hidden
And the element "#q_4" should be hidden
And the element "#q_5" should not be hidden
#issue #337 answer != condition returns false if question was never activated
@javascript
Scenario: Depending with != on questions without responses
Given the survey
"""
survey "Cooling" do
section "Basics" do
q_cooling_1 "How do you cool your home?", :pick => :one
a_1 "Fans"
a_2 "Window AC"
a_3 "Central AC"
a_4 "Passive"
q_cooling_2 "How much does it cost to run your non-passive cooling solutions?"
dependency :rule => "A"
condition_A :q_cooling_1, "!=", :a_4
a_1 "$", :float
end
end
"""
When I go to the surveys page
And I start the "Cooling" survey
Then the question "How much does it cost to run your non-passive cooling solutions?" should be triggered
And I choose "Passive"
Then the question "How much does it cost to run your non-passive cooling solutions?" should be hidden
#issue #337 answer != condition returns false if question was never activated
@javascript
Scenario: Depending with != on questions without responses
Given the survey
"""
survey "Heating" do
section "Basics" do
q_heating_1 "How do you heat your home?", :pick => :one
a_1 "Force air"
a_2 "Radiators"
a_3 "Oven"
a_4 "Passive"
q_heating_2 "How much does it cost to run your non-passive heating solutions?"
dependency :rule => "A and B"
condition_A :q_heating_1, "!=", :a_4
condition_B :q_heating_1, "count>0"
a_1 "$", :float
end
end
"""
When I go to the surveys page
And I start the "Heating" survey
Then the question "How much does it cost to run your non-passive heating solutions?" should be hidden
And I choose "Oven"
Then the question "How much does it cost to run your non-passive heating solutions?" should be triggered