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/file-upload.feature
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,54 @@ Feature: Files can be saved in and removed from elemental blocks
8
8
And I add an extension "SilverStripe\FrameworkTest\Elemental\Extension\FileElementalExtension" to the "DNADesign\Elemental\Models\ElementContent" class
9
9
And I go to "/dev/build?flush"
10
10
And a "image""file1.jpg"
11
+
And a "image""file2.jpg"
11
12
And a "page""Blocks Page" with a "My title" content element with "My content" content
12
13
And the "group""EDITOR" has permissions "Access to 'Pages' section"
13
14
And I am logged in as a member of "EDITOR" group
14
15
And I go to "/admin/pages"
15
16
And I follow "Blocks Page"
16
17
18
+
Scenario: Add a file and save the block, then remove it and add a different one
19
+
# Add a file to the block
20
+
Given I click on the caret button for block 1
21
+
Then I should not see "file1"
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
+
Then I should not see "file1"
38
+
# Try adding the same file back
39
+
When I click "Choose existing" in the "#Form_ElementForm_1 .uploadfield" element
40
+
And I press the "Back" HTML field button
41
+
And I click on the file named "file1" in the gallery
42
+
And I press the "Insert" button
43
+
And I press the "View actions" button
44
+
# same file, so we shouldn't see the button
45
+
Then I should not see the save button for block 1
46
+
# Add a different file
47
+
And I click on the "#Form_ElementForm_1 .uploadfield-item__remove-btn" element
48
+
When I click "Choose existing" in the "#Form_ElementForm_1 .uploadfield" element
49
+
# Note we don't have to press "Back" here because react knows what folder we were just in before
50
+
And I click on the file named "file2" in the gallery
51
+
And I press the "Insert" button
52
+
And I press the "View actions" button
53
+
Then I should see the save button for block 1
54
+
And I click on the ".element-editor__actions-save" element
55
+
Then I should see a "Saved 'My title' successfully" success toast
56
+
And I should see "file2"
57
+
And I should not see "file1"
58
+
17
59
Scenario: Add a file and save the block, then remove the file and save the block
18
60
# Add a file to the block
19
61
Given I click on the caret button for block 1
@@ -33,6 +75,7 @@ Feature: Files can be saved in and removed from elemental blocks
33
75
Then I should see "file1"
34
76
# Then remove the file from the block
35
77
And I click on the "#Form_ElementForm_1 .uploadfield-item__remove-btn" element
78
+
Then I should not see "file1"
36
79
And I press the "View actions" button
37
80
And I click on the ".element-editor__actions-save" element
38
81
Then I should see a "Saved 'My title' successfully" success toast
0 commit comments