From 5adad7fd00ce4b8c623079f1a5617bec2834e445 Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Fri, 10 Feb 2023 14:57:56 +0100 Subject: [PATCH] MOBILE-4132 Book: Fix single activity navigation --- src/addons/mod/book/components/index/index.ts | 14 ++++---- .../book/tests/behat/single_activity.feature | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 src/addons/mod/book/tests/behat/single_activity.feature diff --git a/src/addons/mod/book/components/index/index.ts b/src/addons/mod/book/components/index/index.ts index 191a698fa..93c64972f 100644 --- a/src/addons/mod/book/components/index/index.ts +++ b/src/addons/mod/book/components/index/index.ts @@ -18,6 +18,7 @@ import { AddonModBook, AddonModBookBookWSData, AddonModBookNumbering, AddonModBo import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; +import { AddonModBookModuleHandlerService } from '../../services/handlers/module'; /** * Component that displays a book entry page. @@ -109,14 +110,11 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp * * @param chapterId Chapter to open, undefined for last chapter viewed. */ - openBook(chapterId?: number): void { - CoreNavigator.navigate('contents', { - params: { - cmId: this.module.id, - courseId: this.courseId, - chapterId, - }, - }); + async openBook(chapterId?: number): Promise { + await CoreNavigator.navigateToSitePath( + `${AddonModBookModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/contents`, + { params: { chapterId } }, + ); this.hasStartedBook = true; } diff --git a/src/addons/mod/book/tests/behat/single_activity.feature b/src/addons/mod/book/tests/behat/single_activity.feature new file mode 100644 index 000000000..f247c2034 --- /dev/null +++ b/src/addons/mod/book/tests/behat/single_activity.feature @@ -0,0 +1,33 @@ +@app @javascript @mod @mod_book +Feature: Test single activity of book type in app + In order to view a book while using the mobile app + As a student + I need single activity of book type functionality to work + + Background: + Given the following "users" exist: + | username | firstname | lastname | + | student1 | First | Student | + And the following "courses" exist: + | fullname | shortname | category | format | activitytype | + | Course 1 | C1 | 0 | singleactivity | book | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And the following "activity" exist: + | activity | name | intro | course | idnumber | numbering | section | + | book | Single activity book | Test book description | C1 | 1 | 1 | 0 | + And the following "mod_book > chapter" exist: + | book | title | content | subchapter | hidden | pagenum | + | Single activity book | Chapt 1 | This is the first chapter | 0 | 0 | 1 | + | Single activity book | Chapt 2 | This is the second chapter | 0 | 0 | 1 | + | Single activity book | Chapt 3 | This is the third chapter | 0 | 0 | 1 | + + Scenario: Single activity book + Given I entered the course "Course 1" as "student1" in the app + Then I should find "Chapt 1" in the app + And I should find "Chapt 2" in the app + And I press "Chapt 1" in the app + Then I should find "Chapt 1" in the app + And I should find "This is the first chapter" in the app + But I should not find "This is the second chapter" in the app