2013-10-08 00:23:44 +02:00
|
|
|
@assets
|
|
|
|
Feature: Insert links into a page
|
|
|
|
As a cms author
|
|
|
|
I want to insert a link into my content
|
|
|
|
So that I can link to a external website or a page on my site
|
|
|
|
|
|
|
|
Background:
|
|
|
|
Given a "page" "Home"
|
|
|
|
And a "page" "About Us" has the "Content" "My awesome content"
|
2014-08-01 02:03:07 +02:00
|
|
|
And a "page" "Details" has the "Content" "My sub-par content<a name="youranchor"></a>"
|
2014-01-06 02:38:02 +01:00
|
|
|
And a "file" "assets/file1.jpg"
|
2013-10-08 00:23:44 +02:00
|
|
|
And I am logged in with "ADMIN" permissions
|
|
|
|
And I go to "/admin/pages"
|
|
|
|
And I click on "About Us" in the tree
|
|
|
|
|
|
|
|
Scenario: I can link to an internal page
|
|
|
|
Given I select "awesome" in the "Content" HTML field
|
|
|
|
And I press the "Insert Link" button
|
2014-05-05 02:46:57 +02:00
|
|
|
When I select the "Page on the site" radio button
|
2015-06-26 02:48:29 +02:00
|
|
|
And I fill in the "internal" dropdown with "Home"
|
2013-10-08 00:23:44 +02:00
|
|
|
And I fill in "my desc" for "Link description"
|
|
|
|
And I press the "Insert" button
|
|
|
|
# TODO Dynamic DB identifiers
|
|
|
|
Then the "Content" HTML field should contain "<a title="my desc" href="[sitetree_link,id=1]">awesome</a>"
|
2014-01-06 02:38:02 +01:00
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2013-10-08 00:23:44 +02:00
|
|
|
Then I press the "Save draft" button
|
|
|
|
|
2014-08-01 02:03:07 +02:00
|
|
|
Scenario: I can link to an anchor in an internal page
|
|
|
|
Given I select "awesome" in the "Content" HTML field
|
|
|
|
And I press the "Insert Link" button
|
|
|
|
And I select the "Page on the site" radio button
|
2015-06-26 02:48:29 +02:00
|
|
|
And I fill in the "internal" dropdown with "Details"
|
2014-08-01 02:03:07 +02:00
|
|
|
And I wait for 1 second
|
|
|
|
And I select "youranchor" from "Form_EditorToolbarLinkForm_AnchorSelector"
|
2015-10-15 00:08:52 +02:00
|
|
|
And I press the "Insert" button
|
2014-08-01 02:03:07 +02:00
|
|
|
Then the "Content" HTML field should contain "<a href="[sitetree_link,id=3]#youranchor">awesome</a>"
|
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
|
|
|
Then I press the "Save draft" button
|
|
|
|
|
2013-10-08 00:23:44 +02:00
|
|
|
Scenario: I can link to an external URL
|
|
|
|
Given I select "awesome" in the "Content" HTML field
|
|
|
|
And I press the "Insert Link" button
|
2014-05-05 02:46:57 +02:00
|
|
|
When I select the "Another website" radio button
|
2013-10-08 00:23:44 +02:00
|
|
|
And I fill in "http://silverstripe.org" for "URL"
|
|
|
|
And I check "Open link in a new window"
|
|
|
|
And I press the "Insert" button
|
|
|
|
Then the "Content" HTML field should contain "<a href="http://silverstripe.org" target="_blank">awesome</a>"
|
2014-01-06 02:38:02 +01:00
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2013-10-08 00:23:44 +02:00
|
|
|
Then I press the "Save draft" button
|
|
|
|
|
|
|
|
Scenario: I can link to a file
|
|
|
|
Given I select "awesome" in the "Content" HTML field
|
|
|
|
When I press the "Insert Link" button
|
2014-05-05 02:46:57 +02:00
|
|
|
When I select the "Download a file" radio button
|
2015-06-26 02:48:29 +02:00
|
|
|
And I attach the file "testfile.jpg" to "file[Uploads][]" with HTML5
|
2015-10-15 00:08:52 +02:00
|
|
|
And I press the "Insert" button
|
|
|
|
Then the "Content" HTML field should contain "<a href="[file_link,id=4]" target="_blank">awesome</a>"
|
2014-01-06 02:38:02 +01:00
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2013-10-08 00:23:44 +02:00
|
|
|
Then I press the "Save draft" button
|
2016-01-11 18:08:23 +01:00
|
|
|
# Check that the field is reset when adding another new link
|
|
|
|
Given I select "content" in the "Content" HTML field
|
|
|
|
When I press the "Insert Link" button
|
|
|
|
Then I should not see a ".ss-uploadfield-files .ss-uploadfield-item" element
|
2013-10-08 00:23:44 +02:00
|
|
|
|
|
|
|
Scenario: I can link to an anchor
|
2014-08-01 02:03:07 +02:00
|
|
|
Given I fill in the "Content" HTML field with "<p>My awesome content<a name='myanchor'></a></p>"
|
2013-10-08 00:23:44 +02:00
|
|
|
And I select "awesome" in the "Content" HTML field
|
|
|
|
When I press the "Insert Link" button
|
2014-05-05 02:46:57 +02:00
|
|
|
When I select the "Anchor on this page" radio button
|
2014-08-01 02:03:07 +02:00
|
|
|
And I select "myanchor" from "Form_EditorToolbarLinkForm_AnchorSelector"
|
2015-10-15 00:08:52 +02:00
|
|
|
And I press the "Insert" button
|
2013-10-08 00:23:44 +02:00
|
|
|
Then the "Content" HTML field should contain "<a href="#myanchor">awesome</a>"
|
2014-01-06 02:38:02 +01:00
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2013-10-08 00:23:44 +02:00
|
|
|
Then I press the "Save draft" button
|
|
|
|
|
|
|
|
Scenario: I can edit a link
|
2014-08-01 02:03:07 +02:00
|
|
|
Given I fill in the "Content" HTML field with "<p>My <a href='http://silverstripe.org'>awesome</a> content"
|
2014-01-06 02:38:02 +01:00
|
|
|
And I select "awesome" in the "Content" HTML field
|
2013-10-08 00:23:44 +02:00
|
|
|
When I press the "Insert Link" button
|
2014-01-06 02:38:02 +01:00
|
|
|
# We need to hard-code the <input> id attribute, if you say 'Then the URL field', it picks up URLSegment instead.
|
|
|
|
Then the "Form_EditorToolbarLinkForm_external" field should contain "http://silverstripe.org"
|
|
|
|
# This doesn't seem to suffer from that issue
|
|
|
|
When I fill in "http://google.com" for "URL"
|
2015-10-15 00:08:52 +02:00
|
|
|
And I press the "Insert" button
|
2014-01-06 02:38:02 +01:00
|
|
|
Then the "Content" HTML field should contain "<a href="http://google.com">awesome</a>"
|
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2013-10-08 00:23:44 +02:00
|
|
|
Then I press the "Save draft" button
|
|
|
|
|
2014-01-06 02:38:02 +01:00
|
|
|
Scenario: I can remove a link
|
2014-08-01 02:03:07 +02:00
|
|
|
Given I fill in the "Content" HTML field with "My <a href='http://silverstripe.org'>awesome</a> content"
|
2014-01-06 02:38:02 +01:00
|
|
|
And I select "awesome" in the "Content" HTML field
|
|
|
|
When I press the "Unlink" button
|
|
|
|
Then the "Content" HTML field should contain "My awesome content"
|
|
|
|
And the "Content" HTML field should not contain "http://silverstripe.org"
|
|
|
|
# Required to avoid "unsaved changes" browser dialog
|
2014-08-01 02:03:07 +02:00
|
|
|
Then I press the "Save draft" button
|