diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 47ff474bd..c5b4ccfa6 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -599,7 +599,10 @@ class behat_app extends behat_app_helper { */ public function the_app_has_the_following_config(TableNode $data) { foreach ($data->getRows() as $configrow) { - $this->appconfig[$configrow[0]] = json_decode($configrow[1]); + $name = $configrow[0]; + $value = $this->replace_wwwroot($configrow[1]); + + $this->appconfig[$name] = json_decode($value); } } diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index 7270abc27..50a905623 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -242,7 +242,7 @@ class behat_app_helper extends behat_base { // Assert initial page. $this->spin(function($context) { $page = $context->getSession()->getPage(); - $element = $page->find('xpath', '//page-core-login-site//input[@name="url"]'); + $element = $page->find('xpath', '//page-core-login-site'); if ($element) { // Login screen found. diff --git a/src/core/features/courses/tests/behat/basic-usage-402.feature b/src/core/features/courses/tests/behat/basic-usage-402.feature new file mode 100644 index 000000000..935d791bd --- /dev/null +++ b/src/core/features/courses/tests/behat/basic-usage-402.feature @@ -0,0 +1,70 @@ +@core_courses @app @javascript @lms_upto4.2 +Feature: Test basic usage of courses in app + In order to participate in the courses while using the mobile app + As a student + I need basic courses functionality to work + + Background: + Given the Moodle site is compatible with this feature + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | teacher | teacher1@example.com | + | student1 | Student | student | student1@example.com | + And the following "courses" exist: + | fullname | shortname | category | visible | + | Course 1 | C1 | 0 | 1 | + | Course 2 | C2 | 0 | 1 | + | Course 3 | C3 | 0 | 1 | + | Course 4 | C4 | 0 | 1 | + | Hidden course | CH | 0 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + | teacher1 | C3 | editingteacher | + | teacher1 | C4 | editingteacher | + | teacher1 | CH | editingteacher | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + | student1 | CH | student | + And the following "activities" exist: + | activity | name | intro | course | idnumber | option | + | choice | Choice course 1 | Test choice description | C1 | choice1 | Option 1, Option 2, Option 3 | + | choice | Choice course 2 | Test choice description | C2 | choice1 | Option 1, Option 2, Option 3 | + | choice | Choice course 3 | Test choice description | C3 | choice1 | Option 1, Option 2, Option 3 | + | choice | Choice course 4 | Test choice description | C4 | choice1 | Option 1, Option 2, Option 3 | + And the following "activities" exist: + | activity | course | idnumber | name | intro | assignsubmission_onlinetext_enabled | duedate | gradingduedate | + | assign | C1 | assign1 | assignment | Test assignment description | 1 | ##tomorrow## | ##tomorrow## | + + @lms_from4.0 + Scenario: See my courses + Given I entered the app as "student1" + When the header should be "Acceptance test site" in the app + And I press "My courses" in the app + And I should find "Course 1" in the app + And I should find "Course 2" in the app + And I should find "Course 3" in the app + + When I press "Course 1" in the app + Then I should find "Choice course 1" in the app + And the header should be "Course 1" in the app + + When I press "Choice course 1" in the app + Then I should find "Test choice description" in the app + And the header should be "Choice course 1" in the app + + When I press the back button in the app + And I press the back button in the app + And I press "Course 2" in the app + Then I should find "Choice course 2" in the app + And the header should be "Course 2" in the app + + When I press the back button in the app + And I press "Course 3" in the app + Then I should find "Choice course 3" in the app + And the header should be "Course 3" in the app + And the following events should have been logged for "student1" in the app: + | name | + | \core\event\mycourses_viewed | diff --git a/src/core/features/courses/tests/behat/basic_usage.feature b/src/core/features/courses/tests/behat/basic_usage.feature index 039cc2081..0cc50f205 100755 --- a/src/core/features/courses/tests/behat/basic_usage.feature +++ b/src/core/features/courses/tests/behat/basic_usage.feature @@ -66,7 +66,7 @@ Feature: Test basic usage of courses in app Then I should not find "Hidden course" in the app And I should not find "Hidden from students" in the app - @lms_from4.0 + @lms_from4.3 Scenario: See my courses Given I entered the app as "student1" When the header should be "Acceptance test site" in the app diff --git a/src/core/features/login/lang.json b/src/core/features/login/lang.json index a3b4e91e8..2f14dfa99 100644 --- a/src/core/features/login/lang.json +++ b/src/core/features/login/lang.json @@ -120,7 +120,7 @@ "supplyinfo": "More details", "toggleremove": "Edit accounts list", "unsupportedsite": "Site not accessible through the app", - "unsupportedsitemessage": "{{site}} can't be accessed through this app.\nYou can still access it using a web browser", + "unsupportedsitemessage": "{{site}} can't be accessed through this app.

You can still access it using a web browser.", "username": "Username", "usernamelowercase": "Only lowercase letters allowed", "usernameoremail": "Enter either username or email address", diff --git a/src/core/features/login/pages/site/site.html b/src/core/features/login/pages/site/site.html index b6833401a..186bbc4ce 100644 --- a/src/core/features/login/pages/site/site.html +++ b/src/core/features/login/pages/site/site.html @@ -120,7 +120,7 @@

{{site.title}}

-

{{site.noProtocolUrl}}

+

{{site.noProtocolUrl}}

{{site.location}}

diff --git a/src/core/features/login/tests/behat/basic_usage.feature b/src/core/features/login/tests/behat/basic_usage.feature index b0eb396ad..b1f4c57d6 100755 --- a/src/core/features/login/tests/behat/basic_usage.feature +++ b/src/core/features/login/tests/behat/basic_usage.feature @@ -37,9 +37,8 @@ Feature: Test basic usage of login in app | Username | student1 | | Password | student1 | And I press "Log in" near "Lost password?" in the app - Then I should find "Acceptance test site" in the app + Then the header should be "Acceptance test site" in the app And the UI should match the snapshot - But I should not find "Log in" in the app Scenario: Add a non existing account When I launch the app @@ -160,3 +159,21 @@ Feature: Test basic usage of login in app When I press "OK" in the app And I press "Lost password?" in the app Then I should find "Contact support" in the app + + Scenario: Shows sites list + Given the app has the following config: + | sites | [{"name":"Xavier's School for Gifted Youngsters","alias":"XSGY","imageurl":"https://x-school.campus.edu/logo.png","city":"North Salem","countrycode":"US","url":"https://x-school.campus.edu"},{"name":"Hogwarts", "url":"https://hogwarts.campus.edu"},{"name":"Acceptance test site","url":"$WWWROOT"}] | + When I launch the app + Then I should find "Xavier's School for Gifted Youngsters (XSGY)" in the app + + When I replace "/.*/" within "ion-list ion-item:last-of-type ion-label p:last-of-type" with "campus.example.edu" + Then the UI should match the snapshot + + When I press "Acceptance test site" in the app + Then I should find "Log in" in the app + + When I set the following fields to these values in the app: + | Username | student1 | + | Password | student1 | + And I press "Log in" near "Lost password?" in the app + Then the header should be "Acceptance test site" in the app diff --git a/src/core/features/login/tests/behat/snapshots/test-basic-usage-of-login-in-app-shows-sites-list_8.png b/src/core/features/login/tests/behat/snapshots/test-basic-usage-of-login-in-app-shows-sites-list_8.png new file mode 100644 index 000000000..497c8c333 Binary files /dev/null and b/src/core/features/login/tests/behat/snapshots/test-basic-usage-of-login-in-app-shows-sites-list_8.png differ