|
| 1 | +@retry @job2 |
| 2 | +Feature: Files can be saved in and removed from elemental blocks |
| 3 | + As a CMS user |
| 4 | + I want to attach and remove files from elemental blocks |
| 5 | + |
| 6 | + Background: |
| 7 | + Given I add an extension "DNADesign\Elemental\Extensions\ElementalPageExtension" to the "Page" class |
| 8 | + And I add an extension "SilverStripe\FrameworkTest\Elemental\Extension\FileElementalExtension" to the "DNADesign\Elemental\Models\ElementContent" class |
| 9 | + And I go to "/dev/build?flush" |
| 10 | + And a "image" "file1.jpg" |
| 11 | + And a "page" "Blocks Page" with a "My title" content element with "My content" content |
| 12 | + And the "group" "EDITOR" has permissions "Access to 'Pages' section" |
| 13 | + And I am logged in as a member of "EDITOR" group |
| 14 | + And I go to "/admin/pages" |
| 15 | + And I follow "Blocks Page" |
| 16 | + |
| 17 | + Scenario: Add a file and save the block, then remove the file and save the block |
| 18 | + # Add a file to the block |
| 19 | + Given I click on the caret button for block 1 |
| 20 | + Then I should not see "file1" |
| 21 | + Given I take a screenshot after every step |
| 22 | + When I click "Choose existing" in the "#Form_ElementForm_1 .uploadfield" element |
| 23 | + And I press the "Back" HTML field button |
| 24 | + And I click on the file named "file1" in the gallery |
| 25 | + And I press the "Insert" button |
| 26 | + And I press the "View actions" button |
| 27 | + And I click on the ".element-editor__actions-save" element |
| 28 | + Then I should see a "Saved 'My title' successfully" success toast |
| 29 | + # Check we see the file both in the current page load (react state is correct) and after reloading the form |
| 30 | + Then I should see "file1" |
| 31 | + When I go to "/admin/pages" |
| 32 | + And I follow "Blocks Page" |
| 33 | + And I click on the caret button for block 1 |
| 34 | + Then I should see "file1" |
| 35 | + # Then remove the file from the block |
| 36 | + And I click on the "#Form_ElementForm_1 .uploadfield-item__remove-btn" element |
| 37 | + And I press the "View actions" button |
| 38 | + And I click on the ".element-editor__actions-save" element |
| 39 | + Then I should see a "Saved 'My title' successfully" success toast |
| 40 | + # Check we don't see the file anymore |
| 41 | + Then I should not see "file1" |
| 42 | + When I go to "/admin/pages" |
| 43 | + And I follow "Blocks Page" |
| 44 | + And I click on the caret button for block 1 |
| 45 | + Then I should not see "file1" |
0 commit comments