From ba578cfc0673ee4a98dff6a01ac0ba045a862638 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 7 Sep 2023 10:24:09 +1200 Subject: [PATCH] FIX Allow wrapping an image in a link (#2883) Relies on logic added to silverstripe/admin, so we need to bump the constraint as well. Behat test requires new logic added to the behat-extension module. --- client/dist/js/TinyMCE_sslink-anchor.js | 2 +- client/dist/js/TinyMCE_sslink-internal.js | 2 +- client/src/legacy/TinyMCE_sslink-anchor.js | 5 +-- client/src/legacy/TinyMCE_sslink-internal.js | 14 -------- composer.json | 4 +-- tests/behat/features/insert-a-link.feature | 34 +++++++++++++++++-- .../behat/features/insert-anchor-link.feature | 18 ++++++++++ tests/behat/features/redirector-page.feature | 1 - 8 files changed, 54 insertions(+), 26 deletions(-) diff --git a/client/dist/js/TinyMCE_sslink-anchor.js b/client/dist/js/TinyMCE_sslink-anchor.js index c585833f4f..241682bbde 100644 --- a/client/dist/js/TinyMCE_sslink-anchor.js +++ b/client/dist/js/TinyMCE_sslink-anchor.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/legacy/TinyMCE_sslink-anchor.js")}({"./client/src/legacy/TinyMCE_sslink-anchor.js":function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(9),c=r(a),l=n(2),s=r(l),d=n(5),u=r(d),p=n(4),f=n(6),A=n(0),E=r(A),_=n(8),C=r(_),h=n(7),g=n(3),R=n("./client/src/state/anchorSelector/AnchorSelectorActions.js");c.default.addAction("sslink",{text:o.default._t("CMS.LINKLABEL_ANCHOR","Anchor on a page"),onclick:function(e){return e.execCommand("sslinkanchor")},priority:60},editorIdentifier).addCommandWithUrlTest("sslinkanchor",/^\[sitetree_link.+]#[^#\]]+$/);var O={init:function(e){e.addCommand("sslinkanchor",function(){var t=(0,E.default)("#"+e.id).entwine("ss"),n=Number((0,E.default)("#Form_EditForm_ID").val()||0),r=e.$("[id],[name]",e.getBody()).toArray().map(function(e){return e.id||e.name});ss.store.dispatch((0,R.updatedCurrentField)(n,r,e.id)),t.openLinkAnchorDialog()})}},m="insert-link__dialog-wrapper--anchor",T=(0,g.provideInjector)((0,h.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorAnchorLink"));E.default.entwine("ss",function(e){e("textarea.htmleditor").entwine({openLinkAnchorDialog:function(){var t=e("#"+m);t.length||(t=e('
'),e("body").append(t)),t.addClass("insert-link__dialog-wrapper"),t.setElement(this),t.open()}}),e("#"+m).entwine({renderModal:function(t){var n=this,r=ss.store,i=ss.apolloClient,a=function(){return n.close()},c=function(){return n.handleInsert.apply(n,arguments)},l=this.getOriginalAttributes(),d=tinymce.activeEditor.selection,A=d.getContent()||"",E=d.getNode().tagName,_="A"!==E&&""===A.trim(),C=Number(e("#Form_EditForm_ID").val()||0);u.default.render(s.default.createElement(p.ApolloProvider,{client:i},s.default.createElement(f.Provider,{store:r},s.default.createElement(T,{isOpen:t,onInsert:c,onClosed:a,title:o.default._t("CMS.LINK_ANCHOR","Link to an anchor on a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--anchor",fileAttributes:l,identifier:"Admin.InsertLinkAnchorModal",requireLinkText:_,currentPageID:C}))),this[0])},buildAttributes:function(e){return{href:C.default.serialise({name:"sitetree_link",properties:{id:e.PageID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getOriginalAttributes:function(){var t=this.getElement().getEditor(),n=e(t.getSelectedNode()),r=(n.attr("href")||"").split("#");if(!r[0])return{};var i=C.default.match("sitetree_link",!1,r[0]);return i?{PageID:i.properties.id?parseInt(i.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkanchor",function(e){return O.init(e)}),t.default=O},"./client/src/state/anchorSelector/AnchorSelectorActionTypes.js":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={ANCHORSELECTOR_CURRENT_FIELD:"ANCHORSELECTOR_CURRENT_FIELD",ANCHORSELECTOR_UPDATED:"ANCHORSELECTOR_UPDATED",ANCHORSELECTOR_UPDATING:"ANCHORSELECTOR_UPDATING",ANCHORSELECTOR_UPDATE_FAILED:"ANCHORSELECTOR_UPDATE_FAILED"}},"./client/src/state/anchorSelector/AnchorSelectorActions.js":function(e,t,n){"use strict";function r(e){return{type:l.default.ANCHORSELECTOR_UPDATING,payload:{pageId:e}}}function i(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:l.default.ANCHORSELECTOR_UPDATED,payload:{pageId:e,anchors:t,cacheResult:n}}}function o(e,t,n){return{type:l.default.ANCHORSELECTOR_CURRENT_FIELD,payload:{pageId:e,anchors:t,fieldID:n}}}function a(e){return{type:l.default.ANCHORSELECTOR_UPDATE_FAILED,payload:{pageId:e}}}Object.defineProperty(t,"__esModule",{value:!0}),t.beginUpdating=r,t.updated=i,t.updatedCurrentField=o,t.updateFailed=a;var c=n("./client/src/state/anchorSelector/AnchorSelectorActionTypes.js"),l=function(e){return e&&e.__esModule?e:{default:e}}(c)},0:function(e,t){e.exports=jQuery},1:function(e,t){e.exports=i18n},2:function(e,t){e.exports=React},3:function(e,t){e.exports=Injector},4:function(e,t){e.exports=ReactApollo},5:function(e,t){e.exports=ReactDom},6:function(e,t){e.exports=ReactRedux},7:function(e,t){e.exports=InsertLinkModal},8:function(e,t){e.exports=ShortcodeSerialiser},9:function(e,t){e.exports=TinyMCEActionRegistrar}}); \ No newline at end of file +!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/legacy/TinyMCE_sslink-anchor.js")}({"./client/src/legacy/TinyMCE_sslink-anchor.js":function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(9),l=r(a),c=n(2),s=r(c),u=n(5),d=r(u),p=n(4),f=n(6),A=n(0),E=r(A),_=n(8),h=r(_),C=n(7),g=n(3),R=n("./client/src/state/anchorSelector/AnchorSelectorActions.js");l.default.addAction("sslink",{text:o.default._t("CMS.LINKLABEL_ANCHOR","Anchor on a page"),onclick:function(e){return e.execCommand("sslinkanchor")},priority:60},editorIdentifier).addCommandWithUrlTest("sslinkanchor",/^\[sitetree_link.+]#[^#\]]+$/);var O={init:function(e){e.addCommand("sslinkanchor",function(){var t=(0,E.default)("#"+e.id).entwine("ss"),n=Number((0,E.default)("#Form_EditForm_ID").val()||0),r=e.$("[id],[name]",e.getBody()).toArray().map(function(e){return e.id||e.name});ss.store.dispatch((0,R.updatedCurrentField)(n,r,e.id)),t.openLinkAnchorDialog()})}},T="insert-link__dialog-wrapper--anchor",m=(0,g.provideInjector)((0,C.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorAnchorLink"));E.default.entwine("ss",function(e){e("textarea.htmleditor").entwine({openLinkAnchorDialog:function(){var t=e("#"+T);t.length||(t=e('
'),e("body").append(t)),t.addClass("insert-link__dialog-wrapper"),t.setElement(this),t.open()}}),e("#"+T).entwine({renderModal:function(t){var n=this,r=ss.store,i=ss.apolloClient,a=function(){return n.close()},l=function(){return n.handleInsert.apply(n,arguments)},c=this.getOriginalAttributes(),u=this.getRequireLinkText(),A=Number(e("#Form_EditForm_ID").val()||0);d.default.render(s.default.createElement(p.ApolloProvider,{client:i},s.default.createElement(f.Provider,{store:r},s.default.createElement(m,{isOpen:t,onInsert:l,onClosed:a,title:o.default._t("CMS.LINK_ANCHOR","Link to an anchor on a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--anchor",fileAttributes:c,identifier:"Admin.InsertLinkAnchorModal",requireLinkText:u,currentPageID:A}))),this[0])},buildAttributes:function(e){return{href:h.default.serialise({name:"sitetree_link",properties:{id:e.PageID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getOriginalAttributes:function(){var t=this.getElement().getEditor(),n=e(t.getSelectedNode()),r=(n.attr("href")||"").split("#");if(!r[0])return{};var i=h.default.match("sitetree_link",!1,r[0]);return i?{PageID:i.properties.id?parseInt(i.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkanchor",function(e){return O.init(e)}),t.default=O},"./client/src/state/anchorSelector/AnchorSelectorActionTypes.js":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={ANCHORSELECTOR_CURRENT_FIELD:"ANCHORSELECTOR_CURRENT_FIELD",ANCHORSELECTOR_UPDATED:"ANCHORSELECTOR_UPDATED",ANCHORSELECTOR_UPDATING:"ANCHORSELECTOR_UPDATING",ANCHORSELECTOR_UPDATE_FAILED:"ANCHORSELECTOR_UPDATE_FAILED"}},"./client/src/state/anchorSelector/AnchorSelectorActions.js":function(e,t,n){"use strict";function r(e){return{type:c.default.ANCHORSELECTOR_UPDATING,payload:{pageId:e}}}function i(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return{type:c.default.ANCHORSELECTOR_UPDATED,payload:{pageId:e,anchors:t,cacheResult:n}}}function o(e,t,n){return{type:c.default.ANCHORSELECTOR_CURRENT_FIELD,payload:{pageId:e,anchors:t,fieldID:n}}}function a(e){return{type:c.default.ANCHORSELECTOR_UPDATE_FAILED,payload:{pageId:e}}}Object.defineProperty(t,"__esModule",{value:!0}),t.beginUpdating=r,t.updated=i,t.updatedCurrentField=o,t.updateFailed=a;var l=n("./client/src/state/anchorSelector/AnchorSelectorActionTypes.js"),c=function(e){return e&&e.__esModule?e:{default:e}}(l)},0:function(e,t){e.exports=jQuery},1:function(e,t){e.exports=i18n},2:function(e,t){e.exports=React},3:function(e,t){e.exports=Injector},4:function(e,t){e.exports=ReactApollo},5:function(e,t){e.exports=ReactDom},6:function(e,t){e.exports=ReactRedux},7:function(e,t){e.exports=InsertLinkModal},8:function(e,t){e.exports=ShortcodeSerialiser},9:function(e,t){e.exports=TinyMCEActionRegistrar}}); \ No newline at end of file diff --git a/client/dist/js/TinyMCE_sslink-internal.js b/client/dist/js/TinyMCE_sslink-internal.js index 7ab403aa4f..fc1dae53db 100644 --- a/client/dist/js/TinyMCE_sslink-internal.js +++ b/client/dist/js/TinyMCE_sslink-internal.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/legacy/TinyMCE_sslink-internal.js")}({"./client/src/legacy/TinyMCE_sslink-internal.js":function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(9),l=r(a),s=n(2),u=r(s),c=n(5),d=r(c),f=n(4),p=n(6),g=n(0),k=r(g),m=n(8),_=r(m),h=n(7),x=n(3);l.default.addAction("sslink",{text:o.default._t("CMS.LINKLABEL_PAGE","Page on this site"),onclick:function(e){return e.execCommand("sslinkinternal")},priority:90},editorIdentifier).addCommandWithUrlTest("sslinkinternal",/^\[sitetree_link.+]$/);var I={init:function(e){e.addCommand("sslinkinternal",function(){(0,k.default)("#"+e.id).entwine("ss").openLinkInternalDialog()})}},A="insert-link__dialog-wrapper--internal",C=(0,x.provideInjector)((0,h.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorInternalLink"));k.default.entwine("ss",function(e){e("textarea.htmleditor").entwine({openLinkInternalDialog:function(){var t=e("#"+A);t.length||(t=e('
'),e("body").append(t)),t.addClass("insert-link__dialog-wrapper"),t.setElement(this),t.open()}}),e("#"+A).entwine({renderModal:function(e){var t=this,n=ss.store,r=ss.apolloClient,i=function(){return t.close()},a=function(){return t.handleInsert.apply(t,arguments)},l=this.getOriginalAttributes(),s=this.getRequireLinkText();d.default.render(u.default.createElement(f.ApolloProvider,{client:r},u.default.createElement(p.Provider,{store:n},u.default.createElement(C,{isOpen:e,onInsert:a,onClosed:i,title:o.default._t("CMS.LINK_PAGE","Link to a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:l,identifier:"Admin.InsertLinkInternalModal",requireLinkText:s}))),this[0])},getRequireLinkText:function(){var e=this.getElement().getEditor().getInstance().selection,t=e.getContent()||"";return"A"!==e.getNode().tagName&&""===t.trim()},buildAttributes:function(e){return{href:_.default.serialise({name:"sitetree_link",properties:{id:e.PageID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getOriginalAttributes:function(){var t=this.getElement().getEditor(),n=e(t.getSelectedNode()),r=(n.attr("href")||"").split("#");if(!r[0])return{};var i=_.default.match("sitetree_link",!1,r[0]);return i?{PageID:i.properties.id?parseInt(i.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkinternal",function(e){return I.init(e)}),t.default=I},0:function(e,t){e.exports=jQuery},1:function(e,t){e.exports=i18n},2:function(e,t){e.exports=React},3:function(e,t){e.exports=Injector},4:function(e,t){e.exports=ReactApollo},5:function(e,t){e.exports=ReactDom},6:function(e,t){e.exports=ReactRedux},7:function(e,t){e.exports=InsertLinkModal},8:function(e,t){e.exports=ShortcodeSerialiser},9:function(e,t){e.exports=TinyMCEActionRegistrar}}); \ No newline at end of file +!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./client/src/legacy/TinyMCE_sslink-internal.js")}({"./client/src/legacy/TinyMCE_sslink-internal.js":function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),o=r(i),a=n(9),l=r(a),s=n(2),u=r(s),c=n(5),d=r(c),f=n(4),p=n(6),g=n(0),k=r(g),_=n(8),m=r(_),h=n(7),x=n(3);l.default.addAction("sslink",{text:o.default._t("CMS.LINKLABEL_PAGE","Page on this site"),onclick:function(e){return e.execCommand("sslinkinternal")},priority:90},editorIdentifier).addCommandWithUrlTest("sslinkinternal",/^\[sitetree_link.+]$/);var I={init:function(e){e.addCommand("sslinkinternal",function(){(0,k.default)("#"+e.id).entwine("ss").openLinkInternalDialog()})}},A="insert-link__dialog-wrapper--internal",C=(0,x.provideInjector)((0,h.createInsertLinkModal)("SilverStripe\\CMS\\Controllers\\CMSPageEditController","editorInternalLink"));k.default.entwine("ss",function(e){e("textarea.htmleditor").entwine({openLinkInternalDialog:function(){var t=e("#"+A);t.length||(t=e('
'),e("body").append(t)),t.addClass("insert-link__dialog-wrapper"),t.setElement(this),t.open()}}),e("#"+A).entwine({renderModal:function(e){var t=this,n=ss.store,r=ss.apolloClient,i=function(){return t.close()},a=function(){return t.handleInsert.apply(t,arguments)},l=this.getOriginalAttributes(),s=this.getRequireLinkText();d.default.render(u.default.createElement(f.ApolloProvider,{client:r},u.default.createElement(p.Provider,{store:n},u.default.createElement(C,{isOpen:e,onInsert:a,onClosed:i,title:o.default._t("CMS.LINK_PAGE","Link to a page"),bodyClassName:"modal__dialog",className:"insert-link__dialog-wrapper--internal",fileAttributes:l,identifier:"Admin.InsertLinkInternalModal",requireLinkText:s}))),this[0])},buildAttributes:function(e){return{href:m.default.serialise({name:"sitetree_link",properties:{id:e.PageID}},!0)+(e.Anchor&&e.Anchor.length?"#"+e.Anchor:""),target:e.TargetBlank?"_blank":"",title:e.Description}},getOriginalAttributes:function(){var t=this.getElement().getEditor(),n=e(t.getSelectedNode()),r=(n.attr("href")||"").split("#");if(!r[0])return{};var i=m.default.match("sitetree_link",!1,r[0]);return i?{PageID:i.properties.id?parseInt(i.properties.id,10):0,Anchor:r[1]||"",Description:n.attr("title"),TargetBlank:!!n.attr("target")}:{}}})}),tinymce.PluginManager.add("sslinkinternal",function(e){return I.init(e)}),t.default=I},0:function(e,t){e.exports=jQuery},1:function(e,t){e.exports=i18n},2:function(e,t){e.exports=React},3:function(e,t){e.exports=Injector},4:function(e,t){e.exports=ReactApollo},5:function(e,t){e.exports=ReactDom},6:function(e,t){e.exports=ReactRedux},7:function(e,t){e.exports=InsertLinkModal},8:function(e,t){e.exports=ShortcodeSerialiser},9:function(e,t){e.exports=TinyMCEActionRegistrar}}); \ No newline at end of file diff --git a/client/src/legacy/TinyMCE_sslink-anchor.js b/client/src/legacy/TinyMCE_sslink-anchor.js index 042d3a66e8..667fd99bf9 100644 --- a/client/src/legacy/TinyMCE_sslink-anchor.js +++ b/client/src/legacy/TinyMCE_sslink-anchor.js @@ -74,10 +74,7 @@ jQuery.entwine('ss', ($) => { const handleHide = () => this.close(); const handleInsert = (...args) => this.handleInsert(...args); const attrs = this.getOriginalAttributes(); - const selection = tinymce.activeEditor.selection; - const selectionContent = selection.getContent() || ''; - const tagName = selection.getNode().tagName; - const requireLinkText = tagName !== 'A' && selectionContent.trim() === ''; + const requireLinkText = this.getRequireLinkText(); const currentPageID = Number($('#Form_EditForm_ID').val() || 0); // create/update the react component diff --git a/client/src/legacy/TinyMCE_sslink-internal.js b/client/src/legacy/TinyMCE_sslink-internal.js index 30290cd2ce..b73727a3ba 100644 --- a/client/src/legacy/TinyMCE_sslink-internal.js +++ b/client/src/legacy/TinyMCE_sslink-internal.js @@ -89,20 +89,6 @@ jQuery.entwine('ss', ($) => { ); }, - /** - * Determine whether to show the link text field - * - * @return {Boolean} - */ - getRequireLinkText() { - const selection = this.getElement().getEditor().getInstance().selection; - const selectionContent = selection.getContent() || ''; - const tagName = selection.getNode().tagName; - const requireLinkText = tagName !== 'A' && selectionContent.trim() === ''; - - return requireLinkText; - }, - /** * @param {Object} data - Posted data * @return {Object} diff --git a/composer.json b/composer.json index c18a7a9eef..fcc372e14a 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "silverstripe/admin": "^1.12@dev", + "silverstripe/admin": "^1.13@dev", "silverstripe/campaign-admin": "^1.7@dev", "silverstripe/framework": "^4.11", "silverstripe/reports": "^4.7@dev", @@ -55,4 +55,4 @@ }, "prefer-stable": true, "minimum-stability": "dev" -} \ No newline at end of file +} diff --git a/tests/behat/features/insert-a-link.feature b/tests/behat/features/insert-a-link.feature index 8d83dc97ad..05fd11a535 100644 --- a/tests/behat/features/insert-a-link.feature +++ b/tests/behat/features/insert-a-link.feature @@ -8,7 +8,8 @@ So that I can link to a external website or a page on my site Given a "page" "Home" And a "page" "About Us" has the "Content" "

My awesome content

" And a "file" "file1.jpg" - And the "group" "EDITOR" has permissions "Access to 'Pages' section" + # And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And the "group" "EDITOR" has permissions "Access to 'Files' section" and "Access to 'Pages' section" and "FILE_EDIT_ALL" And I am logged in as a member of "EDITOR" group And I go to "/admin/pages" And I click on "About Us" in the tree @@ -26,6 +27,20 @@ So that I can link to a external website or a page on my site # Required to avoid "unsaved changes" browser dialog Then I press the "Save" button + Scenario: I can wrap an image in a link to an internal page + Given I fill in the "Content" HTML field with "

" + When I select the image "file1.jpg" in the "Content" HTML field + And I press the "Insert link" HTML field button + And I click "Page on this site" in the ".mce-menu" element + Then I should see an "form#Form_editorInternalLink" element + And I should not see "Link text" + When I click "(Search or choose Page)" in the ".Select-multi-value-wrapper" element + And I click "About Us" in the ".treedropdownfield__menu" element + And I press the "Insert" button + Then the "Content" HTML field should contain "" + # Required to avoid "unsaved changed" browser dialog + And I press the "Save" button + Scenario: I can edit a link to an internal page Given I fill in the "Content" HTML field with "awesome" And I select "awesome" in the "Content" HTML field @@ -55,7 +70,20 @@ So that I can link to a external website or a page on my site # Required to avoid "unsaved changes" browser dialog Then I press the "Save" button - Scenario: I can edit a link + Scenario: I can wrap an image in a link to an external URL + Given I fill in the "Content" HTML field with "

" + When I select the image "file1.jpg" in the "Content" HTML field + And I press the "Insert link" HTML field button + When I click "Link to external URL" in the ".mce-menu" element + And I should see an "form#Form_ModalsEditorExternalLink" element + And I should not see "Link text" + When I fill in "http://silverstripe.org" for "URL" + And I press the "Insert" button + Then the "Content" HTML field should contain "" + # Required to avoid "unsaved changed" browser dialog + And I press the "Save" button + + Scenario: I can edit an external link Given I fill in the "Content" HTML field with "

My awesome content" And I select "awesome" in the "Content" HTML field When I press the "Insert link" HTML field button @@ -69,7 +97,7 @@ So that I can link to a external website or a page on my site # Required to avoid "unsaved changes" browser dialog Then I press the "Save" button - Scenario: I can remove a link + Scenario: I can remove an external link Given I fill in the "Content" HTML field with "My awesome content" And I select "awesome" in the "Content" HTML field When I press the "Remove link" button diff --git a/tests/behat/features/insert-anchor-link.feature b/tests/behat/features/insert-anchor-link.feature index a6f1ea1712..a202d039e4 100644 --- a/tests/behat/features/insert-anchor-link.feature +++ b/tests/behat/features/insert-anchor-link.feature @@ -31,6 +31,24 @@ So that I can link to a external website or a page on my site # Required to avoid "unsaved changes" browser dialog Then I press the "Save" button + Scenario: I can wrap an image in a link to an anchor in an internal page + Given I fill in the "Content" HTML field with "

" + When I select the image "file1.jpg" in the "Content" HTML field + And I press the "Insert link" HTML field button + And I click "Anchor on a page" in the ".mce-menu" element + Then I should see an "form#Form_editorAnchorLink" element + And I should not see "Link text" + And I should see "About Us" in the "#Form_editorAnchorLink_PageID_Holder .Select-multi-value-wrapper" element + When I click "About Us" in the "#Form_editorAnchorLink_PageID_Holder .Select-multi-value-wrapper" element + And I click "Details" in the "#Form_editorAnchorLink_PageID_Holder .Select-menu-outer" element + And I click "Select or enter anchor" in the "#Form_editorAnchorLink_Anchor_Holder .Select-multi-value-wrapper" element + And I click "youranchor" in the "#Form_editorAnchorLink_Anchor_Holder .Select-menu-outer" element + Then I should see "youranchor" in the "#Form_editorAnchorLink_Anchor_Holder .Select-value" element + And I press the "Insert" button + Then the "Content" HTML field should contain "" + # Required to avoid "unsaved changed" browser dialog + And I press the "Save" button + Scenario: I can link to an anchor from a dataobject on the current page When I select "awesome" in the "Content" HTML field And I press the "Insert link" HTML field button diff --git a/tests/behat/features/redirector-page.feature b/tests/behat/features/redirector-page.feature index 40eca4d675..de9ea79427 100644 --- a/tests/behat/features/redirector-page.feature +++ b/tests/behat/features/redirector-page.feature @@ -1,4 +1,3 @@ -@gsat Feature: Redirector Pages As an author I want to redirect to a different location