Skip to content

Commit

Permalink
MDL-75019 behat: Folder behat generators use UI
Browse files Browse the repository at this point in the history
Replace steps that manually add Folder instances via the UI and
use Behat generators. This improves the speed of the Behat test
runs.
  • Loading branch information
andelacruz committed Aug 5, 2022
1 parent 35b993b commit d31dfdc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
11 changes: 4 additions & 7 deletions course/tests/behat/view_subfolders_inline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ Feature: View subfolders in a course in-line
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Folder" to section "2" and I fill the form with:
| Name | Test folder |
| Display folder contents | On a separate page |
| Show subfolders expanded | |
And I am on the "Test folder" "folder activity" page
And the following "activities" exist:
| activity | course | name | display | showexpanded |
| folder | C1 | Test folder | 0 | 0 |
And I am on the "Test folder" "folder activity" page logged in as "teacher1"
And I press "Edit"
And I press "Create folder"
And I set the field "New folder name" to "Test subfolder 1"
Expand Down
12 changes: 6 additions & 6 deletions repository/recent/tests/behat/add_recent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ Feature: Recent files repository lists the recently used files
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And the following "activities" exist:
| activity | course | name | intro |
| folder | C1 | Folder name | Folder description |
And I log in as "admin"
And I follow "Manage private files"
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager
And I press "Save changes"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I am on the "Folder name" "folder activity" page
And I press "Edit"
And I add "empty.txt" file from "Recent files" to "Files" filemanager
And I add "empty.txt" file from "Recent files" to "Files" filemanager as:
| Save as | empty_copy.txt |
And I press "Save and display"
And I press "Save changes"
Then I should see "empty.txt"
And I should see "empty_copy.txt"
And I should see "Folder description"
12 changes: 6 additions & 6 deletions repository/tests/behat/cancel_add_file.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ Feature: A selected file can be cancelled
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And the following "activities" exist:
| activity | course | name | intro |
| folder | C1 | Folder name | Folder description |
And I log in as "admin"
And I follow "Manage private files"
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I press "Save changes"
And I am on "Course 1" course homepage with editing mode on
When I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Folder name |
| Description | Folder description |
And I am on the "Folder name" "folder activity" page
And I press "Edit"
And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager
And I click on "Add..." "button" in the "Files" "form_row"
And I click on "Recent files" "link" in the ".fp-repo-area" "css_element"
And I click on "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-file ')][normalize-space(.)='empty.txt']" "xpath_element"
And I click on ".moodle-dialogue-focused .fp-select .fp-select-cancel" "css_element"
And I click on "Close" "button" in the "File picker" "dialogue"
And I press "Save and display"
And I press "Save changes"
Then I should see "upload_users.csv"
And I should not see "empty.txt"
And I should see "Folder description"
35 changes: 10 additions & 25 deletions repository/tests/behat/select_file.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ Feature: Select file feature
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| private_files | System | 1 | my-index | side-post |
And I log in as "admin"
And the following "activities" exist:
| activity | course | name |
| folder | C1 | Test folder |
And I am on the "Test folder" "folder activity" page logged in as admin
And I press "Edit"
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I press "Save changes"

@javascript
Scenario: Select a file from the "Recent files" repository using "icons" view
Given I am on "Course 1" course homepage with editing mode on
And I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Test folder |
| Description | Test folder description |
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I click on "Save and display" "button"
And I follow "Dashboard"
Given I follow "Dashboard"
And I follow "Manage private files"
And I click on "Add..." "button" in the "Files" "form_row"
And I click on "Recent files" "link" in the ".fp-repo-area" "css_element"
Expand All @@ -35,14 +34,7 @@ Feature: Select file feature

@javascript
Scenario: Select a file from the "Recent files" repository using "list" view
Given I am on "Course 1" course homepage with editing mode on
And I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Test folder |
| Description | Test folder description |
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I click on "Save and display" "button"
And I follow "Dashboard"
Given I follow "Dashboard"
And I follow "Manage private files"
And I click on "Add..." "button" in the "Files" "form_row"
And I click on "Recent files" "link" in the ".fp-repo-area" "css_element"
Expand All @@ -55,14 +47,7 @@ Feature: Select file feature

@javascript
Scenario: Select a file from the "Recent files" repository using "tree" view
Given I am on "Course 1" course homepage with editing mode on
And I add a "Folder" to section "1"
And I set the following fields to these values:
| Name | Test folder |
| Description | Test folder description |
And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager
And I click on "Save and display" "button"
And I follow "Dashboard"
Given I follow "Dashboard"
And I follow "Manage private files"
And I click on "Add..." "button" in the "Files" "form_row"
And I click on "Recent files" "link" in the ".fp-repo-area" "css_element"
Expand Down

0 comments on commit d31dfdc

Please sign in to comment.