|
46 | 46 | it "keeps showing only activated custom fields (tricky regression)" do |
47 | 47 | custom_field = string_project_custom_field |
48 | 48 | custom_field.update!(is_required: true) |
49 | | - field = FormFields::Primerized::InputField.new(custom_field) |
| 49 | + form_field = FormFields::Primerized::InputField.new(custom_field) |
50 | 50 |
|
51 | | - dialog = overview_page.open_modal_for_custom_field(custom_field) |
| 51 | + field = overview_page.open_inplace_edit_field_for_custom_field(custom_field) |
52 | 52 |
|
53 | | - dialog.within_async_content do |
| 53 | + field.within_field do |
54 | 54 | expect(page).to have_text("String field") |
55 | 55 | expect(page).to have_no_text(boolean_project_custom_field_activated_in_other_project.name) |
56 | 56 | end |
57 | 57 |
|
58 | | - field.fill_in(with: "") # this will trigger the validation |
| 58 | + form_field.fill_in(with: "") # this will trigger the validation |
59 | 59 |
|
60 | | - dialog.submit |
| 60 | + field.submit |
61 | 61 |
|
62 | | - field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
| 62 | + form_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
63 | 63 |
|
64 | | - dialog.within_async_content do |
| 64 | + field.within_field do |
65 | 65 | expect(page).to have_text("String field") |
66 | 66 | expect(page).to have_no_text(boolean_project_custom_field_activated_in_other_project.name) |
67 | 67 | end |
|
71 | 71 | shared_examples "keeps the unpersisted values" do |
72 | 72 | it "keeps the value" do |
73 | 73 | invalid_custom_field.update!(is_required: true) |
74 | | - dialog = overview_page.open_modal_for_custom_field(invalid_custom_field) |
| 74 | + field = overview_page.open_inplace_edit_field_for_custom_field(invalid_custom_field) |
75 | 75 | invalid_field.clear |
76 | | - dialog.submit |
| 76 | + field.submit |
77 | 77 |
|
78 | 78 | invalid_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
79 | 79 | invalid_field.expect_blank |
|
147 | 147 | end |
148 | 148 |
|
149 | 149 | describe "editing multiple fields" do |
150 | | - let(:input_fields_dialog) do |
151 | | - Components::Projects::ProjectCustomFields::Dialog.new(project, section_for_input_fields) |
152 | | - end |
153 | | - let(:select_fields_dialog) do |
154 | | - Components::Projects::ProjectCustomFields::Dialog.new(project, section_for_select_fields) |
155 | | - end |
156 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(list_project_custom_field) } |
| 150 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(list_project_custom_field) } |
157 | 151 |
|
158 | 152 | it "displays validation errors, when the previous modal was canceled (Regression)" do |
159 | 153 | list_project_custom_field.update!(is_required: true) |
160 | 154 | list_project_custom_field.custom_values.destroy_all |
161 | 155 |
|
162 | | - dialog = overview_page.open_modal_for_custom_field(string_project_custom_field) |
163 | | - dialog.close |
| 156 | + field = overview_page.open_inplace_edit_field_for_custom_field(string_project_custom_field) |
| 157 | + field.close |
164 | 158 |
|
165 | | - dialog = overview_page.open_modal_for_custom_field(list_project_custom_field) |
166 | | - dialog.submit |
| 159 | + field = overview_page.open_inplace_edit_field_for_custom_field(list_project_custom_field) |
| 160 | + field.submit |
167 | 161 |
|
168 | | - field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
| 162 | + form_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
169 | 163 | end |
170 | 164 |
|
171 | 165 | context "with required custom fields in different sections" do |
|
185 | 179 |
|
186 | 180 | it "validates required fields only within their respective sections" do |
187 | 181 | # Test 1: Multi-select field can be saved even when other required fields are invalid |
188 | | - multi_list_field_dialog = |
189 | | - overview_page.open_modal_for_custom_field(multi_list_project_custom_field) |
| 182 | + multi_list_inplace_field = |
| 183 | + overview_page.open_inplace_edit_field_for_custom_field(multi_list_project_custom_field) |
190 | 184 |
|
191 | | - multi_list_field_dialog.submit |
192 | | - multi_list_field_dialog.expect_closed |
| 185 | + multi_list_inplace_field.submit |
| 186 | + multi_list_inplace_field.expect_closed |
193 | 187 |
|
194 | 188 | # Test 2: Edit the required string field |
195 | | - string_field_dialog = |
196 | | - overview_page.open_modal_for_custom_field(string_project_custom_field) |
| 189 | + string_field_inplace_field = |
| 190 | + overview_page.open_inplace_edit_field_for_custom_field(string_project_custom_field) |
197 | 191 |
|
198 | 192 | # Submit without filling - should show error |
199 | | - string_field_dialog.submit |
| 193 | + string_field_inplace_field.submit |
200 | 194 | string_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
201 | | - string_field_dialog.close |
| 195 | + string_field_inplace_field.close |
202 | 196 |
|
203 | 197 | # Test 3: Edit the required list field |
204 | | - list_field_dialog = |
205 | | - overview_page.open_modal_for_custom_field(list_project_custom_field) |
| 198 | + list_field_inplace_field = |
| 199 | + overview_page.open_inplace_edit_field_for_custom_field(list_project_custom_field) |
206 | 200 |
|
207 | 201 | # Submit without filling - should show error |
208 | | - list_field_dialog.submit |
| 202 | + list_field_inplace_field.submit |
209 | 203 | list_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
210 | 204 |
|
211 | 205 | # Test 4: Fill required field and submit successfully |
212 | 206 | list_field.select_option("Option 1") |
213 | | - list_field_dialog.submit |
214 | | - list_field_dialog.expect_closed |
| 207 | + list_field_inplace_field.submit |
| 208 | + list_field_inplace_field.expect_closed |
215 | 209 |
|
216 | 210 | # Test 5: The required string field dialog still fails validation when empty |
217 | | - string_field_dialog = |
218 | | - overview_page.open_modal_for_custom_field(string_project_custom_field) |
219 | | - string_field_dialog.submit |
| 211 | + string_field_inplace_field = |
| 212 | + overview_page.open_inplace_edit_field_for_custom_field(string_project_custom_field) |
| 213 | + string_field_inplace_field.submit |
220 | 214 | string_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
221 | 215 |
|
222 | 216 | # Test 6: Complete the required string field and expect to pass validation |
223 | 217 | string_field.fill_in(with: "Test value") |
224 | | - string_field_dialog.submit |
225 | | - string_field_dialog.expect_closed |
| 218 | + string_field_inplace_field.submit |
| 219 | + string_field_inplace_field.expect_closed |
226 | 220 | end |
227 | 221 | end |
228 | 222 | end |
|
233 | 227 | custom_field.update!(is_required: true) |
234 | 228 | custom_field.custom_values.destroy_all |
235 | 229 |
|
236 | | - dialog = overview_page.open_modal_for_custom_field(custom_field) |
| 230 | + field = overview_page.open_inplace_edit_field_for_custom_field(custom_field) |
237 | 231 |
|
238 | | - dialog.submit |
| 232 | + field.submit |
239 | 233 |
|
240 | | - field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
| 234 | + form_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
241 | 235 | end |
242 | 236 | end |
243 | 237 |
|
244 | 238 | # boolean CFs can not be validated |
245 | 239 |
|
246 | 240 | describe "with string CF" do |
247 | 241 | let(:custom_field) { string_project_custom_field } |
248 | | - let(:field) { FormFields::Primerized::InputField.new(custom_field) } |
| 242 | + let(:form_field) { FormFields::Primerized::InputField.new(custom_field) } |
249 | 243 |
|
250 | 244 | it_behaves_like "a custom field input" |
251 | 245 | end |
252 | 246 |
|
253 | 247 | describe "with integer CF" do |
254 | 248 | let(:custom_field) { integer_project_custom_field } |
255 | | - let(:field) { FormFields::Primerized::InputField.new(custom_field) } |
| 249 | + let(:form_field) { FormFields::Primerized::InputField.new(custom_field) } |
256 | 250 |
|
257 | 251 | it_behaves_like "a custom field input" |
258 | 252 | end |
259 | 253 |
|
260 | 254 | describe "with float CF" do |
261 | 255 | let(:custom_field) { float_project_custom_field } |
262 | | - let(:field) { FormFields::Primerized::InputField.new(custom_field) } |
| 256 | + let(:form_field) { FormFields::Primerized::InputField.new(custom_field) } |
263 | 257 |
|
264 | 258 | it_behaves_like "a custom field input" |
265 | 259 | end |
266 | 260 |
|
267 | 261 | describe "with date CF" do |
268 | 262 | let(:custom_field) { date_project_custom_field } |
269 | | - let(:field) { FormFields::Primerized::InputField.new(custom_field) } |
| 263 | + let(:form_field) { FormFields::Primerized::InputField.new(custom_field) } |
270 | 264 |
|
271 | 265 | it_behaves_like "a custom field input" |
272 | 266 | end |
273 | 267 |
|
274 | 268 | describe "with text CF" do |
275 | 269 | let(:custom_field) { text_project_custom_field } |
276 | | - let(:field) { FormFields::Primerized::EditorFormField.new(custom_field) } |
| 270 | + let(:form_field) { FormFields::Primerized::EditorFormField.new(custom_field) } |
277 | 271 |
|
278 | 272 | it_behaves_like "a custom field input" |
279 | 273 | end |
|
283 | 277 | it "allows saving the dialog even if the calculated custom field is invalid" do |
284 | 278 | custom_field.custom_values.destroy_all |
285 | 279 |
|
286 | | - dialog = overview_page.open_modal_for_custom_field(custom_field) |
| 280 | + field = overview_page.open_inplace_edit_field_for_custom_field(custom_field) |
287 | 281 |
|
288 | | - dialog.submit |
| 282 | + field.submit |
289 | 283 |
|
290 | | - dialog.expect_closed |
| 284 | + field.expect_closed |
291 | 285 | end |
292 | 286 |
|
293 | 287 | it "displays the custom field label without the required asterisk" do |
|
331 | 325 | custom_field.update!(is_required: true) |
332 | 326 | custom_field.custom_values.destroy_all |
333 | 327 |
|
334 | | - dialog = overview_page.open_modal_for_custom_field(custom_field) |
| 328 | + dialog = overview_page.open_inplace_edit_field_for_custom_field(custom_field) |
335 | 329 |
|
336 | 330 | dialog.submit |
337 | 331 |
|
338 | | - field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
| 332 | + form_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
339 | 333 | end |
340 | 334 | end |
341 | 335 |
|
342 | 336 | describe "with list CF" do |
343 | 337 | let(:custom_field) { list_project_custom_field } |
344 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 338 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
345 | 339 |
|
346 | 340 | it_behaves_like "a custom field select" |
347 | 341 | end |
348 | 342 |
|
349 | 343 | describe "with version CF" do |
350 | 344 | let(:custom_field) { version_project_custom_field } |
351 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 345 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
352 | 346 |
|
353 | 347 | it_behaves_like "a custom field select" |
354 | 348 | end |
355 | 349 |
|
356 | 350 | describe "with user CF" do |
357 | 351 | let(:custom_field) { user_project_custom_field } |
358 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 352 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
359 | 353 |
|
360 | 354 | it_behaves_like "a custom field select" |
361 | 355 | end |
|
367 | 361 | custom_field.update!(is_required: true) |
368 | 362 | custom_field.custom_values.destroy_all |
369 | 363 |
|
370 | | - dialog = overview_page.open_modal_for_custom_field(custom_field) |
| 364 | + field = overview_page.open_inplace_edit_field_for_custom_field(custom_field) |
371 | 365 |
|
372 | | - dialog.submit |
| 366 | + field.submit |
373 | 367 |
|
374 | | - field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
| 368 | + form_field.expect_error(I18n.t("activerecord.errors.messages.blank")) |
375 | 369 | end |
376 | 370 | end |
377 | 371 |
|
378 | 372 | describe "with multi list CF" do |
379 | 373 | let(:custom_field) { multi_list_project_custom_field } |
380 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 374 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
381 | 375 |
|
382 | 376 | it_behaves_like "a custom field multi select" |
383 | 377 | end |
384 | 378 |
|
385 | 379 | describe "with multi version CF" do |
386 | 380 | let(:custom_field) { multi_version_project_custom_field } |
387 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 381 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
388 | 382 |
|
389 | 383 | it_behaves_like "a custom field multi select" |
390 | 384 | end |
391 | 385 |
|
392 | 386 | describe "with multi user CF" do |
393 | 387 | let(:custom_field) { multi_user_project_custom_field } |
394 | | - let(:field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
| 388 | + let(:form_field) { FormFields::Primerized::AutocompleteField.new(custom_field) } |
395 | 389 |
|
396 | 390 | it_behaves_like "a custom field multi select" |
397 | 391 | end |
|
0 commit comments