From 5c737525d8a17602f84b82fdb25ed05fb2e87771 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Thu, 10 Aug 2023 09:29:57 +0800 Subject: [PATCH] MDL-78597 mod_lti: Add test for manually configured instance editing This adds a single scenario covering all the expected behavior for those existing, manually configured tools. It also removes any tests dealing with creation of manually configured instances, which is not supported any more. --- mod/lti/tests/behat/addtool.feature | 82 +++++++++++++++++++++++++ mod/lti/tests/behat/addtype.feature | 35 ----------- mod/lti/tests/behat/contentitem.feature | 40 ------------ mod/lti/tests/generator/lib.php | 2 +- 4 files changed, 83 insertions(+), 76 deletions(-) delete mode 100644 mod/lti/tests/behat/addtype.feature diff --git a/mod/lti/tests/behat/addtool.feature b/mod/lti/tests/behat/addtool.feature index 32233c6a800..f30782ef81b 100644 --- a/mod/lti/tests/behat/addtool.feature +++ b/mod/lti/tests/behat/addtool.feature @@ -58,3 +58,85 @@ Feature: Add tools And the "Tool URL" "field" should be disabled And I click on "Preconfigured tool" "select" And I should not see "Automatic, based on tool URL" + + @javascript + Scenario: Editing a (deprecated) manually configured activity instance, confirming that config changes aren't possible + Given the following "activities" exist: + | activity | name | course | toolurl | + | lti | A manual tool | C1 | /mod/lti/tests/fixtures/ims_cartridge_basic_lti_link.xml | + # Add a course tool with the same URL as that of the manually configured instance (the tool URL found in the above cartridge). + # This would normally be domain-matched during edit, resulting in the assignment of a preconfigured tool to the instance. + # In this case, because config changes and domain matching are disabled, the test confirms this doesn't take place. + And the following "mod_lti > course tools" exist: + | name | baseurl | course | lti_sendname | lti_sendemailaddr | lti_acceptgrades | + | Course tool 2 | http://www.example.com/lti/provider.php | C1 | 0 | 1 | 2 | + When I am on the "A manual tool" "lti activity editing" page logged in as teacher1 + Then I should see "Manually configured External tool activities are no longer supported" + And I follow "Show more..." + And I expand all fieldsets + # The privacy values below represent the existing values of the privacy settings, before saving and inheriting from the + # domain-matched tool values. + And the following fields match these values: + | Activity name | A manual tool | + | id_showdescription | 0 | + | Consumer key | 12345 | + | Icon URL | http://download.moodle.org/unittest/test.jpg | + | Secure icon URL | https://download.moodle.org/unittest/test.jpg | + | Tool URL | http://www.example.com/lti/provider.php | + | id_instructorchoicesendname | 1 | + | id_instructorchoicesendemailaddr | 1 | + | id_instructorchoiceacceptgrades | 1 | + And the "Activity name" "field" should be enabled + And the "Activity description" "field" should be enabled + And the "id_showdescription" "checkbox" should be enabled + And the "id_showtitlelaunch" "checkbox" should be enabled + And the "id_showdescriptionlaunch" "checkbox" should be enabled + And the "Secure tool URL" "field" should be disabled + And the "Consumer key" "field" should be disabled + And I click on "Reveal" "icon" + And I should see "secret" + And the "Custom parameters" "field" should be disabled + And the "Icon URL" "field" should be disabled + And the "Secure icon URL" "field" should be disabled + And I should see "Automatic, based on tool URL" + And the "Select content" "button" should be disabled + And the "Tool URL" "field" should be disabled + And the "id_instructorchoicesendname" "checkbox" should be disabled + And the "id_instructorchoicesendemailaddr" "checkbox" should be disabled + And the "id_instructorchoiceacceptgrades" "checkbox" should be disabled + And I set the following fields to these values: + | Activity name | A manual tool name edited | + | id_showdescription | 1 | + And I press "Save and return to course" + And I am on the "A manual tool" "lti activity editing" page logged in as teacher1 + And I follow "Show more..." + # This confirms that the instance config, while locked to user edits, still inherits privacy settings from the tool which + # it was domain-matched to. + And the following fields match these values: + | Activity name | A manual tool name edited | + | id_showdescription | 1 | + | Consumer key | 12345 | + | Icon URL | http://download.moodle.org/unittest/test.jpg | + | Secure icon URL | https://download.moodle.org/unittest/test.jpg | + | Tool URL | http://www.example.com/lti/provider.php | + | id_instructorchoicesendname | 0 | + | id_instructorchoicesendemailaddr | 1 | + | id_instructorchoiceacceptgrades | 2 | + And the "Activity name" "field" should be enabled + And the "Activity description" "field" should be enabled + And the "id_showdescription" "checkbox" should be enabled + And the "id_showtitlelaunch" "checkbox" should be enabled + And the "id_showdescriptionlaunch" "checkbox" should be enabled + And the "Secure tool URL" "field" should be disabled + And the "Consumer key" "field" should be disabled + And I click on "Reveal" "icon" + And I should see "secret" + And the "Custom parameters" "field" should be disabled + And the "Icon URL" "field" should be disabled + And the "Secure icon URL" "field" should be disabled + And I should see "Automatic, based on tool URL" + And the "Select content" "button" should be disabled + And the "Tool URL" "field" should be disabled + And the "id_instructorchoicesendname" "checkbox" should be disabled + And the "id_instructorchoicesendemailaddr" "checkbox" should be disabled + And the "id_instructorchoiceacceptgrades" "checkbox" should be disabled diff --git a/mod/lti/tests/behat/addtype.feature b/mod/lti/tests/behat/addtype.feature deleted file mode 100644 index 3e87dd1f74b..00000000000 --- a/mod/lti/tests/behat/addtype.feature +++ /dev/null @@ -1,35 +0,0 @@ -@mod @mod_lti -Feature: Add preconfigured tools via teacher interface - In order to provide reusable activities for teachers - As a teacher - I need to be able to add preconfigured tools - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Terry1 | Teacher1 | teacher1@example.com | - And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And the following "activities" exist: - | activity | course | name | typeid | toolurl | - | lti | C1 | Test tool | 0 | /mod/lti/tests/fixtures/ims_cartridge_basic_lti_link.xml | - - Scenario: Add a tool activity instance from a cartridge - Given I am on the "Test tool" "lti activity editing" page logged in as teacher1 - And I expand all fieldsets - Then the field "Tool URL" matches value "http://www.example.com/lti/provider.php" - And the field "Secure tool URL" matches value "https://www.example.com/lti/provider.php" - And the field "Icon URL" matches value "http://download.moodle.org/unittest/test.jpg" - And the field "Secure icon URL" matches value "https://download.moodle.org/unittest/test.jpg" - - @javascript @_switch_window - Scenario: Add and use a preconfigured tool - Given I am on the "Test tool" "lti activity editing" page logged in as teacher1 - And I set the field "Tool URL" to local url "/mod/lti/tests/fixtures/tool_provider.php" - And I press "Save and display" - When I switch to "contentframe" iframe - Then I should see "This represents a tool provider" diff --git a/mod/lti/tests/behat/contentitem.feature b/mod/lti/tests/behat/contentitem.feature index 51efb901b77..3158f086793 100644 --- a/mod/lti/tests/behat/contentitem.feature +++ b/mod/lti/tests/behat/contentitem.feature @@ -39,43 +39,3 @@ Feature: Content-Item support And I choose "Edit settings" in the open action menu Then the field "Preconfigured tool" matches value "Teaching Tool 1" And the "Select content" "button" should be enabled - - @javascript - Scenario: Changing preconfigured tool selection - Given the following "mod_lti > tool types" exist: - | name | description | baseurl | coursevisible | state | - | Teaching Tool 2 | Another description | /mod/lti/tests/fixtures/tool_provider.php | 2 | 1 | - # Create a manually configured instance using the generator (this isn't possible via the UI any more). - And the following "activities" exist: - | activity | course | name | typeid | toolurl | - | lti | C1 | Test tool activity 1 | 0 | /mod/lti/tests/fixtures/tool_provider.php | - When I am on the "Test tool activity 1" "lti activity editing" page logged in as teacher1 - # On load with no preconfigured tool selected: Select content button - disabled, Tool URL - enabled. - And the field "Preconfigured tool" matches value "Automatic, based on tool URL" - And I set the field "Activity name" to "Test tool activity 1" - And the "Select content" "button" should be disabled - And the "Tool URL" "field" should be enabled - # Selecting a tool that supports deep linking: Select content button - enabled, Tool URL - enabled. - And I set the field "Preconfigured tool" to "Teaching Tool 1" - And I set the field "Activity name" to "Test tool activity 1" - Then the "Select content" "button" should be enabled - And the "Tool URL" "field" should be enabled - # Selecting a tool that does not support deep linking: Select content button - disabled, Tool URL - disabled. - And I set the field "Preconfigured tool" to "Teaching Tool 2" - And I set the field "Activity name" to "Test tool activity 1" - And the "Select content" "button" should be disabled - And the "Tool URL" "field" should be disabled - # Not selecting any tool: Select content button - disabled, Tool URL - enabled. - And I set the field "Preconfigured tool" to "Automatic, based on tool URL" - And I set the field "Activity name" to "Test tool activity 1" - And the "Select content" "button" should be disabled - And the "Tool URL" "field" should be enabled - - @javascript - Scenario: Editing a manually configured external tool - Given the following "activities" exist: - | activity | course | name | typeid | toolurl | - | lti | C1 | Test tool | 0 | /mod/lti/tests/fixtures/tool_provider.php | - And I am on the "Test tool" "lti activity editing" page logged in as teacher1 - Then the field "Preconfigured tool" matches value "Automatic, based on tool URL" - And the "Select content" "button" should be disabled diff --git a/mod/lti/tests/generator/lib.php b/mod/lti/tests/generator/lib.php index 6e7bb954af3..d6837c0c30a 100644 --- a/mod/lti/tests/generator/lib.php +++ b/mod/lti/tests/generator/lib.php @@ -68,7 +68,7 @@ class mod_lti_generator extends testing_module_generator { $record->instructorchoiceacceptgrades = 1; } if (!isset($record->typeid)) { - $record->typeid = null; + $record->typeid = 0; } return parent::create_instance($record, (array)$options); }