From 5d15e96a984ec479ac94c0f3282039e2e90f75f7 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Fri, 24 Jun 2022 13:06:08 +0800 Subject: [PATCH] MDL-75019 behat: Folder behat generators use UI Replace steps that manually add Folder instances via the UI and use Behat generators. This improves the speed of the Behat test runs. --- .../behat/view_subfolders_inline.feature | 11 ++---- .../recent/tests/behat/add_recent.feature | 12 +++--- .../tests/behat/cancel_add_file.feature | 12 +++--- repository/tests/behat/select_file.feature | 37 +++++-------------- 4 files changed, 26 insertions(+), 46 deletions(-) diff --git a/course/tests/behat/view_subfolders_inline.feature b/course/tests/behat/view_subfolders_inline.feature index edd547cdb59..c259d342ae3 100644 --- a/course/tests/behat/view_subfolders_inline.feature +++ b/course/tests/behat/view_subfolders_inline.feature @@ -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 "3" 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" diff --git a/repository/recent/tests/behat/add_recent.feature b/repository/recent/tests/behat/add_recent.feature index e3416e5e304..aa6f2ff3b85 100644 --- a/repository/recent/tests/behat/add_recent.feature +++ b/repository/recent/tests/behat/add_recent.feature @@ -9,20 +9,20 @@ Feature: Recent files repository lists the recently used files Given the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | + 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" diff --git a/repository/tests/behat/cancel_add_file.feature b/repository/tests/behat/cancel_add_file.feature index 76c43595259..9ca4c28126b 100644 --- a/repository/tests/behat/cancel_add_file.feature +++ b/repository/tests/behat/cancel_add_file.feature @@ -9,22 +9,22 @@ Feature: A selected file can be cancelled Given the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | + 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" diff --git a/repository/tests/behat/select_file.feature b/repository/tests/behat/select_file.feature index 43bce52fcf9..3469adf4963 100644 --- a/repository/tests/behat/select_file.feature +++ b/repository/tests/behat/select_file.feature @@ -8,18 +8,17 @@ Feature: Select file feature Given the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | + 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 log in as "admin" - And 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" in the user menu + Given I follow "Dashboard" in the user menu 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" @@ -32,15 +31,7 @@ Feature: Select file feature @javascript Scenario: Select a file from the "Recent files" repository using "list" view - Given I log in as "admin" - And 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" in the user menu + Given I follow "Dashboard" in the user menu 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" @@ -53,15 +44,7 @@ Feature: Select file feature @javascript Scenario: Select a file from the "Recent files" repository using "tree" view - Given I log in as "admin" - And 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" in the user menu + Given I follow "Dashboard" in the user menu 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"