From a18d8c59f4391c99b96dd7ecc82ce19b0ff5c53e Mon Sep 17 00:00:00 2001 From: Angelia Dela Cruz Date: Mon, 7 Mar 2022 14:36:06 +0800 Subject: [PATCH] MDL-74057 behat: SCORM behat generators use UI Replace steps that manually add SCORM instances via the UI and use Behat generators. This improves the speed of Behat test runs. --- .../tests/behat/multisco_review_mode.feature | 98 ++++--------------- .../behat/save_progress_on_unload.feature | 15 +-- .../scorm_no_calendar_capabilities.feature | 28 ++---- 3 files changed, 32 insertions(+), 109 deletions(-) diff --git a/mod/scorm/tests/behat/multisco_review_mode.feature b/mod/scorm/tests/behat/multisco_review_mode.feature index 9ac8ca9b880..02324685054 100644 --- a/mod/scorm/tests/behat/multisco_review_mode.feature +++ b/mod/scorm/tests/behat/multisco_review_mode.feature @@ -16,22 +16,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test review mode with a single sco completion. - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Basic Multi-sco SCORM package | - | Description | Description | - | Force new attempt | No | - And I set the field "Completed" to "1" - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Basic Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | + | scorm | C1 | Basic Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12.zip | 0 | And I am on the "Basic Multi-sco SCORM package" "scorm activity" page logged in as student1 And I should see "Enter" And I press "Enter" @@ -48,24 +35,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test review mode with all scos completed. - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I navigate to "Settings" in current page administration - And I set the following fields to these values: - | Enable completion tracking | Yes | - And I press "Save and display" - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | ADV Multi-sco SCORM package | - | Description | Description | - | Completion tracking | Show activity as complete when conditions are met | - | Require all scos to return completion status | 1 | - | Force new attempt | No | - And I set the field "Completed" to "1" - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "ADV Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | + | scorm | C1 | ADV Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12.zip | 0 | And I am on the "ADV Multi-sco SCORM package" "scorm activity" page logged in as student1 And I should see "Enter" And I press "Enter" @@ -167,17 +139,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test force completed set to Always. - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Basic Multi-sco SCORM package | - | Description | Description | - | Force new attempt | Always | - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Basic Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | + | scorm | C1 | Basic Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip | 2 | And I am on the "Basic Multi-sco SCORM package" "scorm activity" page logged in as student1 And I should see "Enter" And I press "Enter" @@ -197,17 +161,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test force completed set to when previous complete/passed/failed. - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Basic Multi-sco SCORM package | - | Description | Description | - | Force new attempt | When previous attempt completed, passed or failed | - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Basic Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | + | scorm | C1 | Basic Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip | 1 | And I am on the "Basic Multi-sco SCORM package" "scorm activity" page logged in as student1 And I should see "Enter" And I press "Enter" @@ -272,18 +228,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test force completed set to Always and student skipview - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Basic Multi-sco SCORM package | - | Description | Description | - | Force new attempt | Always | - | Student skip content structure page | Always | - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Basic Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | skipview | + | scorm | C1 | Basic Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip | 2 | 2 | And I am on the "Basic Multi-sco SCORM package" "scorm activity" page logged in as student1 And I switch to "scorm_object" iframe And I should see "Play of the game" @@ -298,18 +245,9 @@ Feature: Scorm multi-sco review mode. @javascript Scenario: Test force completed set to when previous complete/passed/failed. - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Basic Multi-sco SCORM package | - | Description | Description | - | Force new attempt | When previous attempt completed, passed or failed | - | Student skip content structure page | Always | - And I upload "mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Basic Multi-sco SCORM package" - And I log out + When the following "activities" exist: + | activity | course | name | packagefilepath | forcenewattempt | skipview | + | scorm | C1 | Basic Multi-sco SCORM package | mod/scorm/tests/packages/RuntimeMinimumCalls_SCORM12-mini.zip | 1 | 2 | And I am on the "Basic Multi-sco SCORM package" "scorm activity" page logged in as student1 And I switch to "scorm_object" iframe And I should see "Play of the game" diff --git a/mod/scorm/tests/behat/save_progress_on_unload.feature b/mod/scorm/tests/behat/save_progress_on_unload.feature index 48b7b2acb52..f63c7741d4a 100644 --- a/mod/scorm/tests/behat/save_progress_on_unload.feature +++ b/mod/scorm/tests/behat/save_progress_on_unload.feature @@ -19,16 +19,11 @@ Feature: Confirm progress gets saved on unload events @javascript Scenario: Test progress gets saved correctly when the user navigates away from the scorm activity - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Runtime Basic Calls SCORM 2004 3rd Edition package | - | Description | Description | - And I upload "mod/scorm/tests/packages/RuntimeBasicCalls_SCORM20043rdEdition.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I should see "Runtime Basic Calls SCORM 2004 3rd Edition package" - And I log out + Given the following "activity" exists: + | activity | scorm | + | course | C1 | + | name | Runtime Basic Calls SCORM 2004 3rd Edition package | + | packagefilepath | mod/scorm/tests/packages/RuntimeBasicCalls_SCORM20043rdEdition.zip | When I log in as "student1" And I am on "Course 1" course homepage And I am on the "Runtime Basic Calls SCORM 2004 3rd Edition package" "scorm activity" page diff --git a/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature b/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature index 7e194d56c4c..e41fc435031 100644 --- a/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature +++ b/mod/scorm/tests/behat/scorm_no_calendar_capabilities.feature @@ -14,6 +14,13 @@ Feature: Scorm with no calendar capabilites And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "activity" exists: + | activity | scorm | + | course | C1 | + | name | Test scorm name | + | timeopen | ##first day of January 2017## | + | timeclose | ##first day of February 2017## | + | packagefilepath | mod/scorm/tests/packages/singlesco_scorm12.zip | And I log in as "admin" And I am on the "Course 1" "permissions" page And I override the system permissions of "Teacher" role with: @@ -23,25 +30,8 @@ Feature: Scorm with no calendar capabilites @javascript @_file_upload @_switch_iframe Scenario: Editing a scorm activity without calendar permission - Given I log in as "admin" - And I am on "Course 1" course homepage with editing mode on - When I add a "SCORM package" to section "1" - And I set the following fields to these values: - | Name | Test scorm name | - | Description | Test scorm description | - | id_timeopen_enabled | 1 | - | id_timeopen_day | 1 | - | id_timeopen_month | 1 | - | id_timeopen_year | 2017 | - | id_timeclose_enabled | 1 | - | id_timeclose_day | 1 | - | id_timeclose_month | 2 | - | id_timeclose_year | 2017 | - And I upload "mod/scorm/tests/packages/singlesco_scorm12.zip" file to "Package file" filemanager - And I click on "Save and display" "button" - And I log out - When I am on the "Test scorm name" "scorm activity editing" page logged in as teacher1 - And I set the following fields to these values: + Given I am on the "Test scorm name" "scorm activity editing" page logged in as teacher1 + When I set the following fields to these values: | id_timeopen_year | 2018 | | id_timeclose_year | 2018 | And I press "Save and return to course"