From cae9bd51ec1a37be50f83a3572101f865161381c Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 12 Nov 2021 12:38:44 +1300 Subject: [PATCH] MNT Update behat tests --- behat.yml | 5 +- tests/behat/features/operate-subsites.feature | 82 ++++++++++++++++++ .../behat/features/preview-navigation.feature | 19 ++-- tests/behat/features/select-a-subsite.feature | 21 ----- tests/behat/files/file1.jpg | Bin 0 -> 2292 bytes tests/behat/files/file2.jpg | Bin 0 -> 3886 bytes 6 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 tests/behat/features/operate-subsites.feature delete mode 100644 tests/behat/features/select-a-subsite.feature create mode 100644 tests/behat/files/file1.jpg create mode 100644 tests/behat/files/file2.jpg diff --git a/behat.yml b/behat.yml index 0cc5f06..f772c87 100644 --- a/behat.yml +++ b/behat.yml @@ -11,9 +11,10 @@ default: - SilverStripe\BehatExtension\Context\EmailContext - SilverStripe\CMS\Tests\Behaviour\LoginContext - SilverStripe\CMS\Tests\Behaviour\ThemeContext - - SilverStripe\CMS\Tests\Behaviour\FixtureContext: + # Using asset-admin for fixture context to get iAttachTheFileToDropzone() + - SilverStripe\AssetAdmin\Tests\Behat\Context\FixtureContext: # Note: double indent for args is intentional - - '%paths.modules.subsites%/tests/behat/features/files/' + - '%paths.modules.subsites%/tests/behat/files/' extensions: SilverStripe\BehatExtension\MinkExtension: diff --git a/tests/behat/features/operate-subsites.feature b/tests/behat/features/operate-subsites.feature new file mode 100644 index 0000000..dd2eaf5 --- /dev/null +++ b/tests/behat/features/operate-subsites.feature @@ -0,0 +1,82 @@ +@javascript +Feature: Create and select a subsite + As a CMS user + I want to be able to select a subsite + So that I can edit content for a specific subsite + + Background: + # There's a bug where you need CMS_ACCESS_CMSMain rather than CMS_ACCESS_LeftAndMain permissions to + # use subsites as expected + # Given the "group" "EDITOR group" has permissions "CMS_ACCESS_LeftAndMain" and "FILE_EDIT_ALL" + Given the "group" "EDITOR group" has permissions "CMS_ACCESS_CMSMain" and "CMS_ACCESS_AssetAdmin" and "FILE_EDIT_ALL" + And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content" + And an "image" "file1.jpg" + And an "image" "file2.jpg" + + Scenario: I can operate subsites + + # Create subsite as Admin + Given I am logged in with "ADMIN" permissions + Then I go to "admin/subsites" + + # Add subsites button is not a regular button, so click using css selector + And I click on the ".btn-toolbar .btn__title" element + And I fill in "Subsite Name" with "My subsite" + And I press "Create" + + # Add a file to the main site + When I go to "admin/assets" + And I press the "Add folder" button + And I select "Main site" from "SubsitesSelect" + # Using a short folder name so that it doesn't get truncated on the frontend + And I fill in "Folder name" with "mfol" + And I press the "Create" button + When I go to "admin/assets" + + And I click on the file named "mfol" in the gallery + And I attach the file "file1.jpg" to dropzone "gallery-container" + + # Change to Editor user + When I go to "/Security/login" + And I press the "Log in as someone else" button + When I am logged in with "EDITOR" permissions + And I go to "admin/pages" + + # Can see main site page on main site + When I go to "admin/pages" + Then I should see "My page" in the tree + + # Cannot see main site page on subsite + When I select "My subsite" from "SubsitesSelect" + And I go to "admin/pages" + Then I should not see "My page" in the tree + + # Create a page on the subsite + When I press the "Add new" button + And I select the "Page" radio button + And I press the "Create" button + When I fill in "Page name" with "My subsite page" + And I press the "Publish" button + Then I should see "My subsite page" + + # Can see main site folders/files from subsite + When I go to "admin/assets" + Then I should see "mfol" + When I click on the file named "mfol" in the gallery + Then I should see "file1" + + # Add a file to the subsite + When I go to "admin/assets" + And I select "My subsite" from "SubsitesSelect" + And I press the "Add folder" button + And I fill in "Folder name" with "sfol" + And I press the "Create" button + When I go to "admin/assets" + And I click on the file named "sfol" in the gallery + And I attach the file "file2.jpg" to dropzone "gallery-container" + + # Change back to main subsite - cannot see subsite folders/files + When I go to "admin/assets" + And I select "Main site" from "SubsitesSelect" + Then I should see "mfol" + Then I should not see "My subsite page" diff --git a/tests/behat/features/preview-navigation.feature b/tests/behat/features/preview-navigation.feature index 81492ac..fa2c2a8 100644 --- a/tests/behat/features/preview-navigation.feature +++ b/tests/behat/features/preview-navigation.feature @@ -4,18 +4,19 @@ Feature: Preview navigation In order to preview my content Background: - Given a "subsite" "My subsite" - And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content anameahref" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite" - And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content Goto my page>" and "Subsite"="=>SilverStripe\Subsites\Model\Subsite.My subsite" - Given a "member" "Joe" belonging to "Admin Group" with "Email"="joe@test.com" and "Password"="Password1" - And the "group" "Admin Group" has permissions "Full administrative rights" - And I log in with "joe@test.com" and "Password1" + Given a "subsite" "MySubsite" + And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content aname ahref" and "SubsiteID"="1" + And a "page" "Other page" with "URLSegment"="other-page", "Content"="Other page content Goto my page" and "SubsiteID"="1" @javascript Scenario: I can navigate the subsite preview - When I go to "admin" - And I select "My subsite" from "SubsitesSelect" - And I go to "admin/pages" + Given I am logged in with "ADMIN" permissions + When I go to "/admin/pages" + And I select "MySubsite" from "SubsitesSelect" + And I click on "My page" in the tree + And I press the "Publish" button + And I click on "Other page" in the tree + And I press the "Publish" button And I click on "My page" in the tree And I set the CMS mode to "Preview mode" And I follow "ahref" in preview diff --git a/tests/behat/features/select-a-subsite.feature b/tests/behat/features/select-a-subsite.feature deleted file mode 100644 index 1b183d1..0000000 --- a/tests/behat/features/select-a-subsite.feature +++ /dev/null @@ -1,21 +0,0 @@ -@javascript -Feature: Select a subsite - As a CMS user - I want to be able to select a subsite - So that I can edit content for a specific subsite - - Background: - Given a "subsite" "Subsite B" - And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content" - And I am logged in with "ADMIN" permissions - Then I go to "admin/pages" - - Scenario: Default site contains default pages - When I select "Main site" from "SubsitesSelect" - And I go to "admin/pages" - Then I should see "My page" in the tree - - Scenario: I can switch to another subsite - When I select "Subsite B" from "SubsitesSelect" - And I go to "admin/pages" - Then I should not see "My page" in the tree diff --git a/tests/behat/files/file1.jpg b/tests/behat/files/file1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..beb5a91b0aba93d3b54dadc12cff0104307d718e GIT binary patch literal 2292 zcmbV~c|6qJ9>;%UHjExS$z>*csbTDTlq4fO5~U_1OJm>1u4{=xiK_^q9w8LDu4RZU z8557($~v-CGowgKGnQ!>GxN;U>viux_m6w;=e)k(*IB;jygu)9j^K@e2FN&K9k2ih z1OOmm0|b2FS6eqbn=>wMhfslj2ScL#15xo9v>{3_E+#l45ar-#k8(U^XOD_EGun3m zMU3+e3yw`f9Y$H2N($xxTR;pXk|>Lb1ObaO6aoQ5U{DzBN5Cb-VQ>jJ3?_~cmyi@m z*pos?N{I%dLw;@*gMz_ONjMDtqvU@|f@grNIA8=Afk7I8m@Eh^3ldNOq!1GN!=8}z zr$Az02owev+CT^kNHRkEV6f0MROnb(og!QZAhJ-oy%-yqysIxV&@@|zq+B&*=`}UidnweWz9W@cqyyPi`}c)O^$RrQ0K+Pa62>RVddNbMa@I=jdNl;?v( ze+<7EpO~DYPQRI%r85>jd|X`mwEUU1w!X2+{?6Ij7IA?9@J}pZ{*PR;LM}1U8^A?e zAh85tfMp@jy%?CBjVs)jD6e6ZF0OFwR%LU)gr>0@Q}JT-n52@H30<2dLi<7X-+^WP zUu6FR`#0AtAO!{q9}g@GSOYtk7S!~}8_$uB+tPfA6|UScm#}l9_X_1u&tL^TQrcdj z>+Q>0tL3s|#Fe0ldmx9gHPI4kJ)~!b1g|z(yjN8XLXuJS` zbkD^*z5G3tsmzY%^l%+H!&dUleDZ1USK^@~9a{$<->ldybWF6F1{a6<+N$d#8AAgp zF*E@{=}DkRUa!e;;(^bU4KCsXbS(Fn>-RVSUwuF-0BsG#=yT*B;m`NAB6s9h`d>5U z*+I!zwFZ}WM9j}@ilS9JY$m9{% zsipE$tY6wzt5%oilB;$vxZ$B)^iwIL(cE|@3X!9 zbDTr53I6Tz7Vf2L?$z^&yIy=qePSj`q;Sh*>J)8~lG@3xHx8B!&?D3*4f z(16K+;)d7>XX`?zlMS|;WkY<4M_lzC8P1ia)Nya69S5E28twV6Tr)4-C%HIWYv;`p zTFU*5sQNAVW%oH)uPc)2`u@gP@{ucS0`FF`%&cKK#iMe(X=8+7xbU!S*y$YfG} zd!*;~%s9DPl~}k|wAj%YqC~`n?CF_g;&br>rUQqLThBn~X_7ouUO~4nSB>9a(PEyR zYQ=fM82>hyYA~Vx>0tfi*&?c+Ki5RkW%Z(S<%R3+=sK-?4c_)yg9C<->6uQuAmw+P z;wM73KYb_lJxGnY^I^(JN-JdXWKvPmD@={^;Mhq_QF-2Mi*u)0MeW*Q7fLY8e88IN z^iAG|>;KtsJ~5jw^VZJ5gK<0w(h{lU`qbdX1UyJtlhZtGsk?^cL-gmUr7TrLk#9c^FourW>LL;vTauCJy%?{X4MKQ47hT0+*~|arf=qg$=ZZpIf=5s9ayg_A#PN4J0T-0M|ZS11V(s}GqPVIYIU|8(Oode6acclYO}%9{6kE$M-OZo=C-yyXY&dv9s5YCdN`?_7VMjq_Tz_D9N2jX zzNGAes%lE4CzY=jq&&-;{#(iOONt{y(Z$;lRgq|eJwDf?YF;?+-#s=ml&N7?n6uuL zpVn4EF_<;__FFG&W&dz3x&Q30liRolrQ=!!#9c2b&2z2S2nX6%6as@lfIEU1*V(9j zzpO4?`p6JhBgZU%O|S6;>{IIPs}&x4_u)R5T+^5B6oBju%(2V%8aaBvvke7TJ0MLk F^Cu<`6}$id literal 0 HcmV?d00001 diff --git a/tests/behat/files/file2.jpg b/tests/behat/files/file2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fc834a452aa216fd7c7816e71877b9d10da6f7c4 GIT binary patch literal 3886 zcmbVO3p`Y58-LH7Gc!cvk|Nz^UCN5SaY<^e%P@wL%eaJ1#h78%7@QfD*h-~R3A=5( zDlO@r?WRrbCSkE{rCf5!+Cn6$2}z>)-ZM1l*YDf!``-D@d;ar0|L1xC&-0%1o{=@k z9s%{`&aTb?K@i{qKS0(>Ep&BsT?Vrs4=$A?;Ps{}XQG)iUP%$?W z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