You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/behat/features/create-edit-linkfield.feature
+58Lines changed: 58 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -211,3 +211,61 @@ I want to add links to pages, files, external URLs, email addresses and phone nu
211
211
And I should see "File1" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-first" element
212
212
And I should see "folder1/file1.jpg" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-first" element
213
213
And I should see "Draft" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-first" element
214
+
215
+
Scenario: Create links on an unsaved record
216
+
Given I add an extension "SilverStripe\LinkField\Tests\Behat\Context\Extension\LinkCompanyExtension" to the "SilverStripe\FrameworkTest\Model\Company" class
217
+
And the "group""EDITOR" has permissions "Access to 'Test ModelAdmin' section" and "TEST_DATAOBJECT_EDIT"
218
+
When I go to "/admin/test"
219
+
Then I press the "Add new Company" button
220
+
And I wait for 2 seconds
221
+
222
+
# Test that the single + multiple link fields are visible on unsaved records
223
+
Then I should see the "[data-field-id='Form_ItemEditForm_CompanyWebSiteLink'] button" element
224
+
And I should see the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] button" element
225
+
226
+
# Test saving - first add a link to the single link field
227
+
Then I click on the "[data-field-id='Form_ItemEditForm_CompanyWebSiteLink'] button" element
228
+
And I click on the "[data-field-id='Form_ItemEditForm_CompanyWebSiteLink'] .dropdown-item:nth-of-type(1)" element
229
+
Then I fill in "LinkText" with "External URL"
230
+
And I fill in "ExternalUrl" with "https://www.silverstripe.org"
231
+
And I press the "Create link" button
232
+
And I wait for 2 seconds
233
+
234
+
# Then add the first link (email link) to the multi link field
235
+
Then I click on the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] button" element
236
+
And I click on the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .dropdown-item:nth-of-type(4)" element
237
+
And I wait for 5 seconds
238
+
Then I fill in "LinkText" with "Email link"
239
+
And I fill in "Email" with "email@example.com"
240
+
And I press the "Create link" button
241
+
And I wait for 2 seconds
242
+
243
+
# Then add the second link (phone link) to the multi link field
244
+
Then I click on the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] button" element
245
+
And I click on the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .dropdown-item:nth-of-type(5)" element
246
+
And I wait for 5 seconds
247
+
Then I fill in "LinkText" with "Phone"
248
+
And I fill in "Phone" with "12345678"
249
+
And I press the "Create link" button
250
+
And I wait for 2 seconds
251
+
252
+
# Fill out required field on Company records
253
+
And I fill in "Name" with "A company with links"
254
+
And I press the "Create" button
255
+
And I wait for 2 seconds
256
+
Then I should see a "Saved company" message
257
+
258
+
# Reload the page to ensure links have saved, and haven't just been re-populated from POST data
259
+
Then I reload the page
260
+
261
+
# Check links are present - single link
262
+
And I should see "External URL" in the "[data-field-id='Form_ItemEditForm_CompanyWebSiteLink']" element
263
+
And I should see "https://www.silverstripe.org" in the "[data-field-id='Form_ItemEditForm_CompanyWebSiteLink'] .link-picker__link" element
264
+
265
+
# Check links are present - multi link 1
266
+
And I should see "Email link" in the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .link-picker__link:nth-of-type(1)" element
267
+
And I should see "email@example.com" in the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .link-picker__link:nth-of-type(1)" element
268
+
269
+
# Check links are present - multi link 2
270
+
And I should see "Phone number" in the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .link-picker__link:nth-of-type(2)" element
271
+
And I should see "12345678" in the "[data-field-id='Form_ItemEditForm_ManyCompanyWebSiteLink'] .link-picker__link:nth-of-type(2)" element
0 commit comments