Merge pull request #3385 from dpalou/MOBILE-4117

Mobile 4117
main
Noel De Martin 2022-09-15 17:54:39 +02:00 committed by GitHub
commit 54c9b54846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 220 additions and 6 deletions

View File

@ -823,6 +823,18 @@ class behat_app extends behat_app_helper {
$this->getSession()->switchToWindow($windowNames[1]);
}
/**
* Switches to the app if the user is in a browser tab.
*
* @Given I switch back to the app
*/
public function i_switch_back_to_the_app() {
$windowNames = $this->getSession()->getWindowNames();
if (count($windowNames) > 1) {
$this->getSession()->switchToWindow($windowNames[0]);
}
}
/**
* Force cron tasks instead of waiting for the next scheduled execution.
*

View File

@ -17,6 +17,7 @@ import { CoreError } from '@classes/errors/error';
import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component';
import { CoreCourseContentsPage } from '@features/course/pages/contents/contents';
import { IonContent } from '@ionic/angular';
import { CoreApp } from '@services/app';
import { CoreGroupInfo, CoreGroups } from '@services/groups';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
@ -79,9 +80,10 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
/**
* Get meeting info.
*
* @param updateCache Whether to update info cached data (in server).
* @return Promise resolved when done.
*/
async fetchMeetingInfo(): Promise<void> {
async fetchMeetingInfo(updateCache?: boolean): Promise<void> {
if (!this.bbb) {
return;
}
@ -89,6 +91,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
try {
this.meetingInfo = await AddonModBBB.getMeetingInfo(this.bbb.id, this.groupId, {
cmId: this.module.id,
updateCache,
});
if (this.meetingInfo.statusrunning && this.meetingInfo.userlimit > 0) {
@ -120,9 +123,10 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
/**
* Update meeting info.
*
* @param updateCache Whether to update info cached data (in server).
* @return Promise resolved when done.
*/
async updateMeetingInfo(): Promise<void> {
async updateMeetingInfo(updateCache?: boolean): Promise<void> {
if (!this.bbb) {
return;
}
@ -132,7 +136,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
try {
await AddonModBBB.invalidateAllGroupsMeetingInfo(this.bbb.id);
await this.fetchMeetingInfo();
await this.fetchMeetingInfo(updateCache);
} finally {
this.showLoading = false;
}
@ -182,11 +186,14 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo
try {
const joinUrl = await AddonModBBB.getJoinUrl(this.module.id, this.groupId);
CoreUtils.openInBrowser(joinUrl, {
await CoreUtils.openInBrowser(joinUrl, {
showBrowserWarning: false,
});
this.updateMeetingInfo();
// Leave some time for the room to load.
await CoreApp.waitForResume(10000);
this.updateMeetingInfo(true);
} catch (error) {
CoreDomUtils.showErrorModal(error);
} finally {

View File

@ -151,7 +151,7 @@ export class AddonModBBBService {
async getMeetingInfo(
id: number,
groupId: number = 0,
options: CoreCourseCommonModWSOptions = {},
options: AddonModBBBGetMeetingInfoOptions = {},
): Promise<AddonModBBBMeetingInfoWSResponse> {
const site = await CoreSites.getSite(options.siteId);
@ -161,10 +161,16 @@ export class AddonModBBBService {
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getMeetingInfoCacheKey(id, groupId),
getCacheUsingCacheKey: true,
uniqueCacheKey: true,
component: AddonModBBBService.COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
if (options.updateCache) {
params.updatecache = true;
preSets.getFromCache = false;
}
return site.read<AddonModBBBMeetingInfoWSResponse>(
'mod_bigbluebuttonbn_meeting_info',
@ -380,3 +386,10 @@ export type AddonModBBBEndMeetingWSParams = {
bigbluebuttonbnid: number; // Bigbluebuttonbn instance id.
groupid?: number; // Bigbluebuttonbn group id.
};
/**
* Options for getMeetingInfo.
*/
export type AddonModBBBGetMeetingInfoOptions = CoreCourseCommonModWSOptions & {
updateCache?: boolean;
};

View File

@ -0,0 +1,99 @@
@mod @mod_bigbluebuttonbn @app @javascript @lms_from4.0
Feature: Test basic usage of BBB activity in app
In order to join a BBB meeting while using the mobile app
As a student
I need basic BBB functionality to work
Background:
Given I enable "bigbluebuttonbn" "mod" plugin
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 |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
Scenario: Open and closed dates
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | openingtime | closingtime |
| bigbluebuttonbn | BBB 1 | Test BBB description | C1 | bbb1 | 0 | ## 1 January 2050 00:00 ## | 0 |
| bigbluebuttonbn | BBB 2 | Test BBB description | C1 | bbb2 | 0 | 0 | ## 1 January 2000 00:00 ## |
| bigbluebuttonbn | BBB 3 | Test BBB description | C1 | bbb3 | 0 | ## 1 January 2000 00:00 ## | ## 1 January 2050 00:00 ## |
And I entered the bigbluebuttonbn activity "BBB 1" on course "Course 1" as "student1" in the app
Then I should find "The session has not started yet." in the app
And I should find "Saturday, 1 January 2050, 12:00 AM" within "Open" "ion-item" in the app
When I press the back button in the app
And I press "BBB 2" in the app
Then I should find "The session has ended." in the app
And I should find "Saturday, 1 January 2000, 12:00 AM" within "Close" "ion-item" in the app
When I press the back button in the app
And I press "BBB 3" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should find "Saturday, 1 January 2000, 12:00 AM" within "Open" "ion-item" in the app
And I should find "Saturday, 1 January 2050, 12:00 AM" within "Close" "ion-item" in the app
Scenario: Join meeting (student)
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 0 |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "student1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com"
Given I wait "10" seconds
Then I should find "The session is in progress." in the app
And I should find "1" near "viewer" in the app
And I should find "0" near "moderator" in the app
Scenario: Join meeting (moderator)
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | moderators |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 1 | role:editingteacher |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "teacher1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
When I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com"
Given I wait "10" seconds
Then I should find "The session is in progress." in the app
And I should find "1" near "moderator" in the app
And I should find "0" near "viewer" in the app
Scenario: Wait for moderator
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | moderators |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 1 | role:editingteacher |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "student1" in the app
Then I should find "Waiting for a moderator to join." in the app
And I should not be able to press "Join session" in the app
# Join the session as moderator in a browser.
When I press "Information" in the app
And I press "Open in browser" in the app
And I switch to the browser tab opened by the app
And I log in as "teacher1"
And I click on "Join session" "link"
And I wait "10" seconds
And I switch back to the app
And I press "Close" in the app
And I pull to refresh in the app
Then I should find "The session is in progress." in the app
And I should find "1" near "moderator" in the app
And I should find "0" near "viewer" in the app
And I should be able to press "Join session" in the app
When I close all opened windows
And I press "Join session" in the app
Then the app should have opened a browser tab with url "blindsidenetworks.com"

View File

@ -0,0 +1,83 @@
@mod @mod_bigbluebuttonbn @app @javascript @lms_from4.0
Feature: Test usage of BBB activity with groups in app
Background:
Given I enable "bigbluebuttonbn" "mod" plugin
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 |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "groups" exist:
| name | course | idnumber |
| Group 1 | C1 | G1 |
| Group 2 | C1 | G2 |
And the following "group members" exist:
| user | group |
| student1 | G1 |
Scenario: BBB activity with visible groups
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | groupmode |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 0 | 2 |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "student1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should find "There is a room for each group and you have access to more" in the app
And I should be able to press "Join session" in the app
When I press "Visible groups" in the app
Then I should find "All participants" in the app
And I should find "Group 1" in the app
And I should find "Group 2" in the app
When I press "Group 1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
When I press "Visible groups" in the app
And I press "Group 2" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
Scenario: BBB activity with separate groups (student)
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | groupmode |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 0 | 1 |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "student1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
But I should not find "There is a room for each group and you have access to more" in the app
When I press "Separate groups" in the app
Then I should find "Group 1" in the app
But I should not find "All participants" in the app
And I should not find "Group 2" in the app
Scenario: BBB activity with separate groups (teacher)
Given the following "activities" exist:
| activity | name | intro | course | idnumber | wait | groupmode |
| bigbluebuttonbn | Test BBB | Test BBB description | C1 | bbb1 | 0 | 1 |
And I entered the bigbluebuttonbn activity "Test BBB" on course "Course 1" as "teacher1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should find "There is a room for each group and you have access to more" in the app
And I should be able to press "Join session" in the app
When I press "Separate groups" in the app
Then I should find "All participants" in the app
And I should find "Group 1" in the app
And I should find "Group 2" in the app
When I press "Group 1" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app
When I press "Separate groups" in the app
And I press "Group 2" in the app
Then I should find "This room is ready. You can join the session now." in the app
And I should be able to press "Join session" in the app