From 41489ecc66cdbe504839ba6826af3b331dba581c Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 12 Jul 2022 10:25:13 +0200 Subject: [PATCH] MOBILE-4081 behat: Fix 3.9 tests --- .../tests/behat/basic_usage-310.feature | 93 +++++++++++++++++++ .../timeline/tests/behat/basic_usage.feature | 4 +- .../core-course-module-completion-legacy.html | 9 +- .../module-completion-legacy.ts | 5 +- src/tests/behat/open_files-39.feature | 44 +++++++++ src/tests/behat/open_files.feature | 17 ++-- src/tests/behat/runtime.feature | 3 +- 7 files changed, 157 insertions(+), 18 deletions(-) create mode 100644 src/addons/block/timeline/tests/behat/basic_usage-310.feature create mode 100644 src/tests/behat/open_files-39.feature diff --git a/src/addons/block/timeline/tests/behat/basic_usage-310.feature b/src/addons/block/timeline/tests/behat/basic_usage-310.feature new file mode 100644 index 000000000..58dda605c --- /dev/null +++ b/src/addons/block/timeline/tests/behat/basic_usage-310.feature @@ -0,0 +1,93 @@ +@block @block_timeline @app @javascript @lms_upto3.10 +Feature: Timeline block. + + Background: + Given the following "users" exist: + | username | + | student1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + | Course 2 | C2 | + | Course 3 | C3 | + | Course 4 | C4 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + | student1 | Acceptance test site | student | + And the following "activities" exist: + | activity | course | idnumber | name | duedate | + | assign | Acceptance test site | assign00 | Assignment 00 | ##tomorrow## | + | assign | C2 | assign01 | Assignment 01 | ##yesterday## | + | assign | C1 | assign02 | Assignment 02 | ##tomorrow## | + | assign | C1 | assign03 | Assignment 03 | ##tomorrow## | + | assign | C2 | assign04 | Assignment 04 | ##+2 days## | + | assign | C1 | assign05 | Assignment 05 | ##+5 days## | + | assign | C2 | assign06 | Assignment 06 | ##+1 month## | + | assign | C2 | assign07 | Assignment 07 | ##+1 month## | + | assign | C3 | assign08 | Assignment 08 | ##+1 month## | + | assign | C2 | assign09 | Assignment 09 | ##+1 month## | + | assign | C1 | assign10 | Assignment 10 | ##+1 month## | + | assign | C1 | assign11 | Assignment 11 | ##+6 months## | + | assign | C1 | assign12 | Assignment 12 | ##+6 months## | + | assign | C1 | assign13 | Assignment 13 | ##+6 months## | + | assign | C2 | assign14 | Assignment 14 | ##+6 months## | + | assign | C2 | assign15 | Assignment 15 | ##+6 months## | + | assign | C2 | assign16 | Assignment 16 | ##+6 months## | + | assign | C3 | assign17 | Assignment 17 | ##+6 months## | + | assign | C3 | assign18 | Assignment 18 | ##+6 months## | + | assign | C3 | assign19 | Assignment 19 | ##+6 months## | + | assign | C1 | assign20 | Assignment 20 | ##+1 year## | + | assign | C1 | assign21 | Assignment 21 | ##+1 year## | + | assign | C2 | assign22 | Assignment 22 | ##+1 year## | + | assign | C2 | assign23 | Assignment 23 | ##+1 year## | + | assign | C3 | assign24 | Assignment 24 | ##+1 year## | + | assign | C3 | assign25 | Assignment 25 | ##+1 year## | + + Scenario: See courses inside block + Given I entered the app as "student1" + And I press "Open block drawer" in the app + Then I should find "Assignment 00" within "Timeline" "ion-card" in the app + And I should find "Assignment 02" within "Timeline" "ion-card" in the app + And I should find "Assignment 05" within "Timeline" "ion-card" in the app + And I should find "Course 1" within "Timeline" "ion-card" in the app + And I should find "Course 2" within "Timeline" "ion-card" in the app + But I should not find "Assignment 01" within "Timeline" "ion-card" in the app + And I should not find "Course 3" within "Timeline" "ion-card" in the app + + When I press "Next 30 days" in the app + And I press "Overdue" in the app + Then I should find "Assignment 01" within "Timeline" "ion-card" in the app + And I should find "Course 2" within "Timeline" "ion-card" in the app + But I should not find "Assignment 00" within "Timeline" "ion-card" in the app + And I should not find "Assignment 02" within "Timeline" "ion-card" in the app + And I should not find "Course 1" within "Timeline" "ion-card" in the app + And I should not find "Course 3" within "Timeline" "ion-card" in the app + + When I press "Overdue" in the app + And I press "All" in the app + Then I should find "Assignment 19" within "Timeline" "ion-card" in the app + And I should find "Course 3" within "Timeline" "ion-card" in the app + But I should not find "Assignment 20" within "Timeline" "ion-card" in the app + + When I press "Load more" in the app + Then I should find "Assignment 21" within "Timeline" "ion-card" in the app + And I should find "Assignment 25" within "Timeline" "ion-card" in the app + + When I press "All" in the app + And I press "Next 7 days" in the app + And I press "Sort by" in the app + And I press "Sort by courses" in the app + Then I should find "Course 1" "h3" within "Timeline" "ion-card" in the app + And I should find "Course 2" "h3" within "Timeline" "ion-card" in the app + And I should find "Assignment 02" within "Timeline" "ion-card" in the app + And I should find "Assignment 04" within "Timeline" "ion-card" in the app + But I should not find "Course 3" within "Timeline" "ion-card" in the app + + When the following "activities" exist: + | activity | course | idnumber | name | duedate | + | assign | C1 | newassign | New Assignment | ##tomorrow## | + And I pull to refresh in the app + Then I should find "New Assignment" in the app diff --git a/src/addons/block/timeline/tests/behat/basic_usage.feature b/src/addons/block/timeline/tests/behat/basic_usage.feature index ebfd10e03..d91bff7f4 100644 --- a/src/addons/block/timeline/tests/behat/basic_usage.feature +++ b/src/addons/block/timeline/tests/behat/basic_usage.feature @@ -1,4 +1,4 @@ -@app @javascript +@block @block_timeline @app @javascript Feature: Timeline block. Background: @@ -46,8 +46,10 @@ Feature: Timeline block. | assign | C3 | assign24 | Assignment 24 | ##+1 year## | | assign | C3 | assign25 | Assignment 25 | ##+1 year## | + @lms_from3.11 Scenario: See courses inside block Given I entered the app as "student1" + And I press "Open block drawer" in the app Then I should find "Assignment 00" within "Timeline" "ion-card" in the app And I should find "Assignment 02" within "Timeline" "ion-card" in the app And I should find "Assignment 05" within "Timeline" "ion-card" in the app diff --git a/src/core/features/course/components/module-completion-legacy/core-course-module-completion-legacy.html b/src/core/features/course/components/module-completion-legacy/core-course-module-completion-legacy.html index 32a0dacae..3139c0d77 100644 --- a/src/core/features/course/components/module-completion-legacy/core-course-module-completion-legacy.html +++ b/src/core/features/course/components/module-completion-legacy/core-course-module-completion-legacy.html @@ -1,9 +1,6 @@ - + - + diff --git a/src/core/features/course/components/module-completion-legacy/module-completion-legacy.ts b/src/core/features/course/components/module-completion-legacy/module-completion-legacy.ts index f7c5b55e8..5ba425701 100644 --- a/src/core/features/course/components/module-completion-legacy/module-completion-legacy.ts +++ b/src/core/features/course/components/module-completion-legacy/module-completion-legacy.ts @@ -24,6 +24,7 @@ import { Translate } from '@singletons'; import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; +import { BehaviorSubject } from 'rxjs'; /** * Component to handle activity completion in sites previous to 3.11. @@ -43,7 +44,7 @@ export class CoreCourseModuleCompletionLegacyComponent extends CoreCourseModuleC implements OnInit, OnDestroy { completionImage?: string; - completionDescription?: string; + completionDescription$ = new BehaviorSubject(''); protected completionObserver?: CoreEventObserver; @@ -133,7 +134,7 @@ export class CoreCourseModuleCompletionLegacyComponent extends CoreCourseModuleC }; } - this.completionDescription = Translate.instant(langKey, translateParams); + this.completionDescription$.next(Translate.instant(langKey, translateParams)); } /** diff --git a/src/tests/behat/open_files-39.feature b/src/tests/behat/open_files-39.feature new file mode 100644 index 000000000..49e074f44 --- /dev/null +++ b/src/tests/behat/open_files-39.feature @@ -0,0 +1,44 @@ +@app @javascript @lms_upto3.9 +Feature: It opens files properly. + + Background: + Given the following "users" exist: + | username | + | student1 | + And the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following "activities" exist: + | activity | name | intro | display | course | defaultfilename | + | resource | Test TXT | Test TXT description | 5 | C1 | A txt.txt | + | resource | Test RTF | Test RTF description | 5 | C1 | A rtf.rtf | + | resource | Test DOC | Test DOC description | 5 | C1 | A doc.doc | + + Scenario: Open a file + Given I entered the resource activity "Test TXT" on course "Course 1" as "student1" in the app + When I press "Open" in the app + Then the app should have opened a browser tab with url "^blob:" + + When I switch to the browser tab opened by the app + Then I should see "Test resource A txt.txt file" + + When I close the browser tab opened by the app + And I press the back button in the app + And I press "Test RTF" in the app + And I press "Open" in the app + Then the app should have opened a browser tab with url "^blob:" + + When I switch to the browser tab opened by the app + Then I should see "Test resource A rtf.rtf file" + + When I close the browser tab opened by the app + And I press the back button in the app + And I press "Test DOC" in the app + And I press "Open" in the app + Then the app should have opened a browser tab with url "^blob:" + + When I switch to the browser tab opened by the app + Then I should see "Test resource A doc.doc file" diff --git a/src/tests/behat/open_files.feature b/src/tests/behat/open_files.feature index 0f12b02da..2eda134f1 100644 --- a/src/tests/behat/open_files.feature +++ b/src/tests/behat/open_files.feature @@ -19,10 +19,11 @@ Feature: It opens files properly. And the following config values are set as admin: | filetypeexclusionlist | rtf,doc | tool_mobile | + @lms_from3.10 Scenario: Open a file Given I entered the resource activity "Test TXT" on course "Course 1" as "student1" in the app - When I press "Open" near "Last modified" in the app - Then the app should have opened a browser tab with url "^blob:(first)?" + When I press "Open" in the app + Then the app should have opened a browser tab with url "^blob:" When I switch to the browser tab opened by the app Then I should see "Test resource A txt.txt file" @@ -30,26 +31,26 @@ Feature: It opens files properly. When I close the browser tab opened by the app And I press the back button in the app And I press "Test RTF" in the app - And I press "Open" near "Last modified" in the app + And I press "Open" in the app Then I should find "This file may not work as expected on this device" in the app When I press "Open file" in the app - Then the app should have opened a browser tab with url "^blob:(second)?" + Then the app should have opened a browser tab with url "^blob:" When I switch to the browser tab opened by the app Then I should see "Test resource A rtf.rtf file" When I close the browser tab opened by the app - And I press "Open" near "Last modified" in the app + And I press "Open" in the app Then I should find "This file may not work as expected on this device" in the app When I select "Don't show again." in the app And I press "Open file" in the app - Then the app should have opened a browser tab with url "^blob:(third)?" + Then the app should have opened a browser tab with url "^blob:" When I close the browser tab opened by the app - And I press "Open" near "Last modified" in the app - Then the app should have opened a browser tab with url "^blob:(fourth)?" + And I press "Open" in the app + Then the app should have opened a browser tab with url "^blob:" When I close the browser tab opened by the app And I press the back button in the app diff --git a/src/tests/behat/runtime.feature b/src/tests/behat/runtime.feature index 2b9c03657..bfebb3dc3 100644 --- a/src/tests/behat/runtime.feature +++ b/src/tests/behat/runtime.feature @@ -8,8 +8,9 @@ Feature: It has a Behat runtime with testing helpers. Scenario: Finds and presses elements Given I entered the app as "student1" + And I press "Search courses" in the app When I set the following fields to these values in the app: - | Search by activity type or name | Foo bar | + | Search | Foo bar | Then I should find "Search" "button" in the app And I should find "Clear search" in the app And I should be able to press "Search" "button" in the app