From 7c0a9829583001d19e16d30ac947532c31db9628 Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Mon, 17 Jan 2022 17:47:48 +0800 Subject: [PATCH] MDL-73788 behat: URL behat generators use UI Replace steps that manually add URL instances via the UI and use Behat generators. This improves the speed of Behat test runs. --- .../behat/restore_moodle2_courses.feature | 37 +++++-------------- .../tests/behat/add_url.feature | 16 ++++++-- .../videojs/tests/behat/modules.feature | 13 ++++--- 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/backup/util/ui/tests/behat/restore_moodle2_courses.feature b/backup/util/ui/tests/behat/restore_moodle2_courses.feature index d1bae452395..7cbdcb971e9 100644 --- a/backup/util/ui/tests/behat/restore_moodle2_courses.feature +++ b/backup/util/ui/tests/behat/restore_moodle2_courses.feature @@ -12,9 +12,10 @@ Feature: Restore Moodle 2 course backups | Course 3 | C3 | 0 | topics | 2 | 0 | | Course 4 | C4 | 0 | topics | 20 | 0 | And the following "activities" exist: - | activity | course | idnumber | name | intro | section | - | assign | C3 | assign1 | Test assign name | Assign description | 1 | - | data | C3 | data1 | Test database name | Database description | 2 | + | activity | course | idnumber | name | intro | section | externalurl | + | assign | C3 | assign1 | Test assign name | Assign description | 1 | | + | data | C3 | data1 | Test database name | Database description | 2 | | + | url | C1 | url1 | Test URL name | Test URL description | 3 | http://www.moodle.org | And I log in as "admin" And I am on "Course 1" course homepage with editing mode on And I add a "Forum" to section "1" and I fill the form with: @@ -108,11 +109,7 @@ Feature: Restore Moodle 2 course backups @javascript Scenario: Restore a backup in an existing course retaining the backup course settings - Given I add a "URL" to section "3" and I fill the form with: - | Name | Test URL name | - | Description | Test URL description | - | id_externalurl | http://www.moodle.org | - And I hide section "3" + Given I hide section "3" And I hide section "7" When I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | @@ -134,11 +131,7 @@ Feature: Restore Moodle 2 course backups @javascript Scenario: Restore a backup in an existing course keeping the target course settings - Given I add a "URL" to section "3" and I fill the form with: - | Name | Test URL name | - | Description | Test URL description | - | id_externalurl | http://www.moodle.org | - And I hide section "3" + Given I hide section "3" And I hide section "7" When I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | @@ -160,11 +153,7 @@ Feature: Restore Moodle 2 course backups @javascript Scenario: Restore a backup in an existing course deleting contents and retaining the backup course settings - Given I add a "URL" to section "3" and I fill the form with: - | Name | Test URL name | - | Description | Test URL description | - | id_externalurl | http://www.moodle.org | - And I hide section "3" + Given I hide section "3" And I hide section "7" When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | @@ -189,11 +178,7 @@ Feature: Restore Moodle 2 course backups @javascript Scenario: Restore a backup in an existing course deleting contents and keeping the current course settings - Given I add a "URL" to section "3" and I fill the form with: - | Name | Test URL name | - | Description | Test URL description | - | id_externalurl | http://www.moodle.org | - And I hide section "3" + Given I hide section "3" And I hide section "7" When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | @@ -218,11 +203,7 @@ Feature: Restore Moodle 2 course backups @javascript Scenario: Restore a backup in an existing course deleting contents decreasing the number of sections - Given I add a "URL" to section "3" and I fill the form with: - | Name | Test URL name | - | Description | Test URL description | - | id_externalurl | http://www.moodle.org | - And I hide section "3" + Given I hide section "3" And I hide section "7" When I backup "Course 1" course using this options: | Initial | Include enrolled users | 0 | diff --git a/blocks/site_main_menu/tests/behat/add_url.feature b/blocks/site_main_menu/tests/behat/add_url.feature index 1b2a7df7682..49185cc14b5 100644 --- a/blocks/site_main_menu/tests/behat/add_url.feature +++ b/blocks/site_main_menu/tests/behat/add_url.feature @@ -10,10 +10,18 @@ Feature: Add URL to main menu block And I am on site homepage And I navigate to "Turn editing on" in current page administration And I add the "Main menu" block - When I add a "URL" to section "0" and I fill the form with: - | Name | google | - | Description | gooooooooogle | - | External URL | http://www.google.com | + And the following "activity" exists: + | activity | url | + | course | Acceptance test site | + | name | google | + | intro | gooooooooogle | + | externalurl | http://www.google.com | + | section | 0 | + When I am on the "google" "url activity editing" page + And I expand all fieldsets + And I set the following fields to these values: | id_display | In pop-up | + And I press "Save and return to course" Then "google" "link" should exist in the "Main menu" "block" + And "Add an activity" "button" should exist in the "Main menu" "block" And "Add an activity or resource" "button" should exist in the "Main menu" "block" diff --git a/media/player/videojs/tests/behat/modules.feature b/media/player/videojs/tests/behat/modules.feature index a0175ddce9d..1412340860d 100644 --- a/media/player/videojs/tests/behat/modules.feature +++ b/media/player/videojs/tests/behat/modules.feature @@ -11,11 +11,14 @@ Feature: Embed videos without the media filter @javascript Scenario: Add a video in a URL resource. Make sure media filters work - When I add a "URL" to section "1" and I fill the form with: - | Name | Video URL | - | Description | Example of a video url | - | External URL | http://download.moodle.org/mediatest/quicktime_320_180.mov | - And I follow "Video URL" + Given the following "activity" exists: + | activity | url | + | course | Acceptance test site | + | name | Video URL | + | intro | Example of a video url | + | externalurl | http://download.moodle.org/mediatest/quicktime_320_180.mov | + | section | 1 | + When I am on the "Video URL" "url activity" page Then ".video-js" "css_element" should exist And I am on site homepage