From 4ecea7c09f37e7d3e2b453eff4e977effbcf2766 Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Mon, 9 Oct 2023 12:19:19 +1100 Subject: [PATCH] MDL-79460 communication_matrix: Re-enabled tests that use new sync route --- .../tests/behat/matrix_form_fields.feature | 37 +++++++++---------- .../tests/behat/matrix_room_banner.feature | 21 +++++------ .../tests/communication_feature_test.php | 16 ++++---- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/communication/provider/matrix/tests/behat/matrix_form_fields.feature b/communication/provider/matrix/tests/behat/matrix_form_fields.feature index 0bb719db23e..78ea9fdbedc 100644 --- a/communication/provider/matrix/tests/behat/matrix_form_fields.feature +++ b/communication/provider/matrix/tests/behat/matrix_form_fields.feature @@ -28,22 +28,21 @@ Feature: Communication matrix form field And I navigate to "Communication" in current page administration Then the field "id_communicationroomname" matches value "Sampleroomname" -# Skipping while we update the Mock Server with the new route. -# Scenario: I can add room topic for matrix room -# Given a Matrix mock server is configured -# And I log in as "teacher1" -# And I am on "Test course" course homepage -# When I navigate to "Communication" in current page administration -# And I set the field "id_selectedcommunication" to "Matrix" -# And I wait to be redirected -# And I should see "Room name" -# And I should see "Room topic" -# And I set the field "id_communicationroomname" to "Sampleroomname" -# And I set the field "id_matrixroomtopic" to "Sampleroomtopic" -# And I press "Save changes" -# And I navigate to "Communication" in current page administration -# Then the field "id_communicationroomname" matches value "Sampleroomname" -# And I press "Cancel" -# And I run all adhoc tasks -# And I navigate to "Communication" in current page administration -# And the field "id_matrixroomtopic" matches value "Sampleroomtopic" + Scenario: I can add room topic for matrix room + Given a Matrix mock server is configured + And I log in as "teacher1" + And I am on "Test course" course homepage + When I navigate to "Communication" in current page administration + And I set the field "id_selectedcommunication" to "Matrix" + And I wait to be redirected + And I should see "Room name" + And I should see "Room topic" + And I set the field "id_communicationroomname" to "Sampleroomname" + And I set the field "id_matrixroomtopic" to "Sampleroomtopic" + And I press "Save changes" + And I navigate to "Communication" in current page administration + Then the field "id_communicationroomname" matches value "Sampleroomname" + And I press "Cancel" + And I run all adhoc tasks + And I navigate to "Communication" in current page administration + And the field "id_matrixroomtopic" matches value "Sampleroomtopic" diff --git a/communication/provider/matrix/tests/behat/matrix_room_banner.feature b/communication/provider/matrix/tests/behat/matrix_room_banner.feature index e8a94764340..a264e2e2e98 100644 --- a/communication/provider/matrix/tests/behat/matrix_room_banner.feature +++ b/communication/provider/matrix/tests/behat/matrix_room_banner.feature @@ -24,17 +24,16 @@ Feature: Display communication room status banner # Not for students to see. Then I should not see "Your Matrix room will be ready soon." in the "page-content" "region" -# Skipping while we update the Mock Server with the new route. -# Scenario: I can see the room has been created and ready to access -# When I run all adhoc tasks -# And I am on the "Test course" "Course" page logged in as "teacher1" -# Then I should see "Your Matrix room is ready!" in the "page-content" "region" -# # This is a one time message per user. -# When I reload the page -# Then I should not see "Your Matrix room is ready." in the "page-content" "region" -# # Not for students to see. -# When I am on the "Test course" "Course" page logged in as "student1" -# Then I should not see "Your Matrix room is ready." in the "page-content" "region" + Scenario: I can see the room has been created and ready to access + When I run all adhoc tasks + And I am on the "Test course" "Course" page logged in as "teacher1" + Then I should see "Your Matrix room is ready." in the "page-content" "region" + # This is a one time message per user. + When I reload the page + Then I should not see "Your Matrix room is ready." in the "page-content" "region" + # Not for students to see. + When I am on the "Test course" "Course" page logged in as "student1" + Then I should not see "Your Matrix room is ready." in the "page-content" "region" Scenario: Enabling or disabling the matrix plugin hides the banner accordingly Given I am on the "Test course" "Course" page logged in as "teacher1" diff --git a/communication/provider/matrix/tests/communication_feature_test.php b/communication/provider/matrix/tests/communication_feature_test.php index 1d6e431ea61..e6d38b7c1da 100644 --- a/communication/provider/matrix/tests/communication_feature_test.php +++ b/communication/provider/matrix/tests/communication_feature_test.php @@ -368,8 +368,6 @@ class communication_feature_test extends \advanced_testcase { * @covers ::set_matrix_power_levels */ public function test_add_and_remove_members_from_room(): void { - $this->markTestSkipped('Skipping while we update the Mock Server with the new route'); - $user = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user(); @@ -413,28 +411,32 @@ class communication_feature_test extends \advanced_testcase { * @covers ::get_user_allowed_power_level */ public function test_update_room_membership(): void { - $this->markTestSkipped('Skipping while we update the Mock Server with the new route'); - $this->resetAfterTest(); global $DB; // Create a new room. $course = $this->get_course('Sampleroom', 'none'); + $coursecontext = \context_course::instance($course->id); $user = $this->get_user(); $communication = $this->create_room( component: 'core_course', itemtype: 'coursecommunication', - itemid: $course->id + itemid: $course->id, + roomname: 'sampleroom', + roomtopic: 'sampltopic', + roomavatar: null, + members: [$user->id], + context: $coursecontext, ); + $provider = $communication->get_room_user_provider(); // Add the members to the room. $provider->add_members_to_room([$user->id]); // Assign teacher role to the user. - $coursecontext = \context_course::instance($course->id); $teacherrole = $DB->get_record('role', ['shortname' => 'teacher']); $this->getDataGenerator()->enrol_user($user->id, $course->id); role_assign($teacherrole->id, $user->id, $coursecontext->id); @@ -443,7 +445,7 @@ class communication_feature_test extends \advanced_testcase { $provider->update_room_membership([$user->id]); $processor = \core_communication\processor::load_by_instance( - context: \core\context\course::instance($course->id), + context: $coursecontext, component: 'core_course', instancetype: 'coursecommunication', instanceid: $course->id,