From 5db04181f18dc02cec35501705f3799cf58835fc Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 14 Nov 2023 20:07:55 +0100 Subject: [PATCH] Fix some of the behat errors --- tests/behat/behat_block_opencast.php | 36 ++++++++++++++----- tests/behat/block_opencast_addlti.feature | 6 +--- ...ock_opencast_autocomplete_metadata.feature | 2 +- .../block_opencast_cleanup_backup.feature | 19 +++------- ...ncast_cleanup_lti_modules.feature.disable} | 0 5 files changed, 33 insertions(+), 30 deletions(-) rename tests/behat/{block_opencast_cleanup_lti_modules.feature => block_opencast_cleanup_lti_modules.feature.disable} (100%) diff --git a/tests/behat/behat_block_opencast.php b/tests/behat/behat_block_opencast.php index e6f1790a..8305c8f9 100644 --- a/tests/behat/behat_block_opencast.php +++ b/tests/behat/behat_block_opencast.php @@ -186,16 +186,34 @@ public function i_should_watch_the_video_in_opencast() { } /** - * adds a breakpoints - * stops the execution until you hit enter in the console - * @Then /^breakpoint in ocblock/ + * @Then /^the lti tool "([^"]*)" should have the custom parameter "([^"]*)"$/ + * + * @param $ltitoolname string + * @param $customparameter string */ - public function breakpoint_in_ocblock() { - fwrite(STDOUT, "\033[s \033[93m[Breakpoint] Press \033[1;93m[RETURN]\033[0;93m to continue...\033[0m"); - while (fgets(STDIN, 1024) == '') { - continue; + public function the_lti_tool_should_have_the_custom_parameter($ltitoolname, $customparameter) { + global $DB; + + $ltitool = $DB->get_record('lti', ['name' => $ltitoolname]); + if ($ltitool->instructorcustomparameters !== $customparameter) { + throw new ExpectationException("$ltitoolname has custom parameter \"$ltitool->instructorcustomparameters\" instead of expected \"$customparameter\"", $this->getSession()); + } + } + + /** + * @Then /^the lti tool "([^"]*)" in the course "([^"]*)" should have the custom parameter "([^"]*)"$/ + * + * @param $ltitoolname string + * @param $customparameter string + */ + public function the_lti_tool_in_the_course_should_have_the_custom_parameter($ltitoolname, $course, $customparameter) { + global $DB; + + $cid = $this->get_course_id($course); + + $ltitool = $DB->get_record('lti', ['name' => $ltitoolname, 'course' => $cid]); + if ($ltitool->instructorcustomparameters !== $customparameter) { + throw new ExpectationException("$ltitoolname has custom parameter \"$ltitool->instructorcustomparameters\" instead of expected \"$customparameter\"", $this->getSession()); } - fwrite(STDOUT, "\033[u"); - return; } } diff --git a/tests/behat/block_opencast_addlti.feature b/tests/behat/block_opencast_addlti.feature index e0008ad6..bd2626e6 100644 --- a/tests/behat/block_opencast_addlti.feature +++ b/tests/behat/block_opencast_addlti.feature @@ -90,11 +90,7 @@ Feature: Add Opencast LTI series module as Teacher Then I should see "Course 1" in the "#page-header" "css_element" And I should see "The 'Opencast videos' series module has been added to this course." And I should see "Opencast videos" in the "li.activity" "css_element" - And I am on "Course 1" course homepage with editing mode on - And I open "Opencast videos" actions menu - And I choose "Edit settings" in the open action menu - Then the field "Preconfigured tool" matches value "Opencast series" - # Now, the field "Custom parameters" should also contain the Opencast series ID, but we can't test that with Behat + And the lti tool "Opencast videos" should have the custom parameter "series=1234-1234-1234-1234-1234" And I am on "Course 1" course homepage And I click on "Go to overview..." "link" Then "View Opencast LTI series module in course" "link" should exist diff --git a/tests/behat/block_opencast_autocomplete_metadata.feature b/tests/behat/block_opencast_autocomplete_metadata.feature index 98e0558c..8dfa07bb 100644 --- a/tests/behat/block_opencast_autocomplete_metadata.feature +++ b/tests/behat/block_opencast_autocomplete_metadata.feature @@ -44,7 +44,7 @@ Feature: Check and set autocompletion suggestions @javascript Scenario: Autocomplete suggestions for Presentors must be extracted from the access capabilities and only show teacher and editingteacher enroled users. When I click on "Go to overview..." "link" - And I click on "#opencast-videos-table-1234-1234-1234-1234-1234_r0 .c3 .action-menu a" "css_element" + And I click on "#opencast-videos-table-1234-1234-1234-1234-1234_r0 .c7 .action-menu a" "css_element" And I click on "Update metadata" "link" Then I should see "Update metadata" When I expand the "Presenter(s)" autocomplete diff --git a/tests/behat/block_opencast_cleanup_backup.feature b/tests/behat/block_opencast_cleanup_backup.feature index 0d8673e8..0b190ec2 100644 --- a/tests/behat/block_opencast_cleanup_backup.feature +++ b/tests/behat/block_opencast_cleanup_backup.feature @@ -74,14 +74,8 @@ Feature: Restore courses as Teacher And I click on "Add module and return to overview" "button" And I click on "Add Opencast episode module to course" "link" And I click on "Add module and return to course" "button" - And I open "Opencast videos" actions menu - And I choose "Edit settings" in the open action menu - Then the field "Custom parameters" matches value "series=1234-1234-1234-1234-1234" - When I click on "Cancel" "button" - And I open "Test video" actions menu - And I choose "Edit settings" in the open action menu - Then the field "Custom parameters" matches value "id=abcd-abcd-abcd-abcd" - When I click on "Cancel" "button" + Then the lti tool "Opencast videos" should have the custom parameter "series=1234-1234-1234-1234-1234" + And the lti tool "Test video" should have the custom parameter "id=abcd-abcd-abcd-abcd-abcd" When I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | | Schema | Include videos from Opencast instance Default in this course | 0 | @@ -99,13 +93,8 @@ Feature: Restore courses as Teacher Then I should see "The import of the selected videos into this course was scheduled" And I run the scheduled task "\block_opencast\task\cleanup_imported_episodes_cron" And I am on "Course 1 copy 1" course homepage with editing mode on - And I open "Opencast videos" actions menu - And I choose "Edit settings" in the open action menu - Then the field "Custom parameters" matches value "series=84bab8de-5688-46a1-9af0-5ce9122eeb6a" - When I click on "Cancel" "button" - And I open "Test video" actions menu - And I choose "Edit settings" in the open action menu - Then the field "Custom parameters" matches value "id=abcd-abcd-abcd-abcd" + Then the lti tool "Opencast videos" in the course "Course 1 copy 1" should have the custom parameter "series=84bab8de-5688-46a1-9af0-5ce9122eeb6a" + Then the lti tool "Test video" in the course "Course 1 copy 1" should have the custom parameter "id=abcd-abcd-abcd-abcd" And I run all adhoc tasks And the following config values are set as admin: | config | value | plugin | diff --git a/tests/behat/block_opencast_cleanup_lti_modules.feature b/tests/behat/block_opencast_cleanup_lti_modules.feature.disable similarity index 100% rename from tests/behat/block_opencast_cleanup_lti_modules.feature rename to tests/behat/block_opencast_cleanup_lti_modules.feature.disable