-
Notifications
You must be signed in to change notification settings - Fork 503
/
api.attributes.feature
231 lines (217 loc) · 7.95 KB
/
api.attributes.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
@oauth2Skip @forms @form_attributes
Feature: Testing the Form Attributes API
Scenario: Creating a new Attribute
Given that I want to make a new "Attribute"
And that the request "data" is:
"""
{
"form_stage":1,
"key":"new",
"label":"Full Name",
"type":"varchar",
"input":"text",
"required":true,
"priority":1,
"default":"",
"options":{}
}
"""
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "id" property
And the type of the "id" property is "numeric"
Then the guzzle status code should be 200
Scenario: Creating a new Attribute on a non-existent Stage
Given that I want to make a new "Attribute"
And that the request "data" is:
"""
{
"form_stage":35,
"key":"new",
"label":"Full Name",
"type":"varchar",
"input":"text",
"required":true,
"priority":1
}
"""
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "errors" property
Then the guzzle status code should be 404
Scenario: Creating a new Attribute with a duplicate key
Given that I want to make a new "Attribute"
And that the request "data" is:
"""
{
"form_stage":1,
"key":"test_varchar",
"label":"Hey a Thing",
"type":"varchar",
"input":"text",
"required":true,
"priority":1
}
"""
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "errors" property
Then the guzzle status code should be 422
Scenario: Creating a new Attribute on a Stage with the wrong Form ID
Given that I want to make a new "Attribute"
And that the request "data" is:
"""
{
"form_stage":1,
"key":"some_key",
"label":"Hey a Thing",
"type":"varchar",
"input":"text",
"required":true,
"priority":1
}
"""
When I request "/forms/2/attributes"
Then the response is JSON
And the response has a "errors" property
Then the guzzle status code should be 400
Scenario: Check all attribute values were saved
Given that I want to make a new "Attribute"
And that the request "data" is:
"""
{
"form_stage":1,
"key":"value_test",
"label":"Value test",
"instructions":"Much longer boring instructions",
"type":"varchar",
"input":"text",
"required":true,
"priority":11,
"default":"default val",
"options":[
"option1",
"option2",
"option3",
"option4",
"option5",
"option6",
"option7",
"option8",
"option9",
"option10",
"option11",
"option12",
"option13"
],
"config":{
"magic-input":true
}
}
"""
When I request "/forms/1/attributes"
Then the response is JSON
And the "label" property equals "Value test"
And the "instructions" property equals "Much longer boring instructions"
And the "type" property equals "varchar"
And the "input" property equals "text"
And the "required" property equals "true"
And the "priority" property equals "11"
And the "default" property equals "default val"
And the "options.12" property equals "option13"
And the "config.magic-input" property equals "true"
Then the guzzle status code should be 200
Scenario: Updating a Attribute
Given that I want to update a "Attribute"
And that the request "data" is:
"""
{
"key":"updated",
"label":"Full Name Updated",
"type":"varchar",
"input":"text",
"required":true,
"priority":1
}
"""
And that its "id" is "1"
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "id" property
And the type of the "id" property is "numeric"
And the "id" property equals "1"
And the response has a "label" property
And the "label" property equals "Full Name Updated"
Then the guzzle status code should be 200
Scenario: Updating a non-existent Attribute
Given that I want to update a "Attribute"
And that the request "data" is:
"""
{
"key":"updated",
"label":"Full Name Updated",
"type":"varchar",
"input":"text",
"required":true,
"priority":1
}
"""
And that its "id" is "40"
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "errors" property
Then the guzzle status code should be 404
Scenario: Listing All Attributes for a form
Given that I want to get all "Attributes"
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "count" property
And the type of the "count" property is "numeric"
And the "count" property equals "17"
Then the guzzle status code should be 200
Scenario: Listing All Attributes
Given that I want to get all "Attributes"
When I request "/forms/attributes"
Then the response is JSON
And the response has a "count" property
And the type of the "count" property is "numeric"
And the "count" property equals "17"
Then the guzzle status code should be 200
Scenario: Search for point attributes
Given that I want to get all "Attributes"
And that the request "query string" is:
"""
type=point
"""
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "count" property
And the type of the "count" property is "numeric"
And the "count" property equals "3"
Then the guzzle status code should be 200
Scenario: Finding a Attribute
Given that I want to find a "Attribute"
And that its "id" is "1"
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "id" property
And the type of the "id" property is "numeric"
Then the guzzle status code should be 200
Scenario: Finding a non-existent Attribute
Given that I want to find a "Attribute"
And that its "id" is "35"
When I request "/forms/1/attributes"
Then the response is JSON
And the response has a "errors" property
Then the guzzle status code should be 404
Scenario: Deleting a Attribute
Given that I want to delete a "Attribute"
And that its "id" is "1"
When I request "/forms/1/attributes"
Then the guzzle status code should be 200
Scenario: Deleting a non-existent Attribute
Given that I want to delete a "Attribute"
And that its "id" is "35"
When I request "/forms/1/attributes"
And the response has a "errors" property
Then the guzzle status code should be 404