Skip to content

Commit 15fafef

Browse files
authored
Merge pull request #3570 from moodlehq/integration
Integration
2 parents a7b5091 + 9a2720a commit 15fafef

File tree

329 files changed

+6615
-1449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+6615
-1449
lines changed

.github/workflows/acceptance.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
env:
2727
MOODLE_DOCKER_DB: pgsql
2828
MOODLE_DOCKER_BROWSER: chrome
29-
MOODLE_DOCKER_PHP_VERSION: 7.4
29+
MOODLE_DOCKER_PHP_VERSION: '8.0'
3030
MOODLE_BRANCH: ${{ github.event.inputs.moodle_branch || 'master' }}
3131
MOODLE_REPOSITORY: ${{ github.event.inputs.moodle_repository || 'https://github.com/moodle/moodle' }}
3232
BEHAT_TAGS: ${{ github.event.inputs.behat_tags || '~@performance' }}
@@ -42,6 +42,12 @@ jobs:
4242
git clone --branch master --depth 1 https://github.com/moodlehq/moodle-docker $GITHUB_WORKSPACE/moodle-docker
4343
- name: Install npm packages
4444
run: npm ci --no-audit
45+
- name: Create Behat faildumps folder
46+
run: |
47+
mkdir moodle/behatfaildumps
48+
chmod 777 moodle/behatfaildumps
49+
- name: Install Behat Snapshots plugin
50+
run: git clone --branch main --depth 1 https://github.com/NoelDeMartin/moodle-local_behatsnapshots $GITHUB_WORKSPACE/moodle/local/behatsnapshots
4551
- name: Generate Behat tests plugin
4652
run: |
4753
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
@@ -50,12 +56,21 @@ jobs:
5056
run: |
5157
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
5258
cp $GITHUB_WORKSPACE/moodle-docker/config.docker-template.php $GITHUB_WORKSPACE/moodle/config.php
59+
sed -i "61c\$CFG->behat_faildump_path = '/var/www/html/behatfaildumps';" $GITHUB_WORKSPACE/moodle/config.php
5360
sed -i "61i\$CFG->behat_increasetimeout = 2;" $GITHUB_WORKSPACE/moodle/config.php
5461
sed -i "61i\$CFG->behat_ionic_wwwroot = 'http://moodleapp';" $GITHUB_WORKSPACE/moodle/config.php
62+
sed -i "61i\$CFG->behat_snapshots_path = '/var/www/html/local/moodleappbehat/tests/behat/snapshots';" $GITHUB_WORKSPACE/moodle/config.php
5563
echo "define('TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER', 'http://bbbmockserver/hash' . sha1(\$CFG->behat_wwwroot));" >> $GITHUB_WORKSPACE/moodle/config.php
5664
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose pull
5765
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose up -d
5866
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-db
67+
- name: Install Imagick PHP extension
68+
run: |
69+
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
70+
./moodle-docker/bin/moodle-docker-compose exec webserver apt-get update
71+
./moodle-docker/bin/moodle-docker-compose exec webserver apt-get install -y libmagickwand-dev --no-install-recommends
72+
./moodle-docker/bin/moodle-docker-compose exec webserver pecl install imagick
73+
./moodle-docker/bin/moodle-docker-compose exec webserver docker-php-ext-enable imagick
5974
- name: Compile & launch app with Docker
6075
run: |
6176
docker build --build-arg build_command="npm run build:test" -t moodlehq/moodleapp:behat .
@@ -65,8 +80,20 @@ jobs:
6580
- name: Init Behat
6681
run: |
6782
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
68-
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php --parallel=8 --optimize-runs='@app&&$BEHAT_TAGS'"
83+
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php --parallel=8 --optimize-runs='@app&&~@local&&$BEHAT_TAGS'"
6984
- name: Run Behat tests
7085
run: |
7186
export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle
72-
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --verbose --tags='@app&&$BEHAT_TAGS' --auto-rerun=3"
87+
$GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --verbose --tags='@app&&~@local&&$BEHAT_TAGS' --auto-rerun=3"
88+
- name: Upload Snapshot failures
89+
uses: actions/upload-artifact@v3
90+
if: ${{ failure() }}
91+
with:
92+
name: snapshot_failures
93+
path: moodle/local/moodleappbehat/tests/behat/snapshots/failures/*
94+
- name: Upload Behat failures
95+
uses: actions/upload-artifact@v3
96+
if: ${{ failure() }}
97+
with:
98+
name: behat_failures
99+
path: moodle/behatfaildumps

.github/workflows/performance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
env:
99
MOODLE_DOCKER_DB: pgsql
1010
MOODLE_DOCKER_BROWSER: chrome
11-
MOODLE_DOCKER_PHP_VERSION: 7.4
11+
MOODLE_DOCKER_PHP_VERSION: '8.0'
1212
steps:
1313
- uses: actions/checkout@v2
1414
- uses: actions/setup-node@v3

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ WORKDIR /app
66
# Prepare node dependencies
77
RUN apt-get update && apt-get install libsecret-1-0 -y
88
COPY package*.json ./
9+
COPY patches ./patches
10+
RUN echo "unsafe-perm=true" > ./.npmrc
911
RUN npm ci --no-audit
1012

1113
# Build source

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Moodle App
44
This is the primary repository of source code for the official mobile app for Moodle.
55

66
* [User documentation](https://docs.moodle.org/en/Moodle_app)
7-
* [Developer documentation](http://docs.moodle.org/dev/Moodle_App)
8-
* [Development environment setup](https://docs.moodle.org/dev/Setting_up_your_development_environment_for_the_Moodle_App)
7+
* [Developer documentation](https://moodledev.io/general/app)
8+
* [Development environment setup](https://moodledev.io/general/app/development/setup)
99
* [Bug Tracker](https://tracker.moodle.org/browse/MOBILE)
10-
* [Release Notes](https://docs.moodle.org/dev/Moodle_App_Release_Notes)
10+
* [Release Notes](https://moodledev.io/general/app_releases)
11+
12+
This project is tested with BrowserStack.
1113

1214
License
1315
-------

angular.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@
4242
"input": "src/theme/theme.scss"
4343
}
4444
],
45-
"scripts": []
45+
"scripts": [],
46+
"webWorkerTsConfig": "tsconfig.worker.json"
4647
},
4748
"configurations": {
4849
"production": {
4950
"fileReplacements": [
5051
{
5152
"replace": "src/testing/testing.module.ts",
5253
"with": "src/testing/testing.module.prod.ts"
54+
},
55+
{
56+
"replace": "src/core/features/emulator/emulator.module.ts",
57+
"with": "src/core/features/emulator/emulator.module.prod.ts"
5358
}
5459
],
5560
"optimization": {

config.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget android-versionCode="41001" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.1.0.1" version="4.1.0" versionCode="41001" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget android-versionCode="41100" id="com.moodle.moodlemobile" ios-CFBundleVersion="4.1.1.0" version="4.1.1" versionCode="41100" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>Moodle</name>
44
<description>Moodle official app</description>
55
<author email="[email protected]" href="http://moodle.com">Moodle Mobile team</author>
@@ -27,7 +27,7 @@
2727
<preference name="UIWebViewBounce" value="false" />
2828
<preference name="DisallowOverscroll" value="true" />
2929
<preference name="prerendered-icon" value="true" />
30-
<preference name="AppendUserAgent" value="MoodleMobile 4.1.0 (41001)" />
30+
<preference name="AppendUserAgent" value="MoodleMobile 4.1.1 (41100)" />
3131
<preference name="BackupWebStorage" value="none" />
3232
<preference name="ScrollEnabled" value="false" />
3333
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
@@ -196,13 +196,9 @@
196196
<param name="android-package" value="com.adobe.phonegap.push.PushPlugin" />
197197
</feature>
198198
</config-file>
199-
<config-file parent="/*" target="res/xml/config.xml">
200-
<feature name="Media">
201-
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
202-
</feature>
203-
</config-file>
204199
<config-file parent="/*" target="AndroidManifest.xml">
205200
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
201+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
206202
</config-file>
207203
<config-file parent="/*" target="AndroidManifest.xml">
208204
<queries>
@@ -236,7 +232,7 @@
236232
<true />
237233
</edit-config>
238234
<edit-config file="*-Info.plist" mode="merge" target="CFBundleShortVersionString">
239-
<string>4.1.0</string>
235+
<string>4.1.1</string>
240236
</edit-config>
241237
<edit-config file="*-Info.plist" mode="overwrite" target="CFBundleLocalizations">
242238
<array>

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ gulp.task('watch', () => {
7171
});
7272

7373
gulp.task('watch-behat', () => {
74-
gulp.watch(['./src/**/*.feature', './local_moodleappbehat'], { interval: 500 }, gulp.parallel('behat'));
74+
gulp.watch(['./src/**/*.feature', './src/**/*.png', './local_moodleappbehat'], { interval: 500 }, gulp.parallel('behat'));
7575
});

local_moodleappbehat/tests/behat/behat_app.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
2020
require_once(__DIR__ . '/behat_app_helper.php');
2121

22+
use Behat\Behat\Hook\Scope\ScenarioScope;
2223
use Behat\Gherkin\Node\TableNode;
2324
use Behat\Mink\Exception\DriverException;
2425
use Behat\Mink\Exception\ExpectationException;
@@ -45,6 +46,27 @@ class behat_app extends behat_app_helper {
4546

4647
protected $windowsize = '360x720';
4748

49+
/**
50+
* @BeforeScenario
51+
*/
52+
public function before_scenario(ScenarioScope $scope) {
53+
if (!$scope->getFeature()->hasTag('app')) {
54+
return;
55+
}
56+
57+
global $CFG;
58+
59+
$performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null;
60+
61+
if ($performanceLogs !== 'ALL') {
62+
return;
63+
}
64+
65+
// Enable DB Logging only for app tests with performance logs activated.
66+
$this->getSession()->visit($this->get_app_url() . '/assets/env.json');
67+
$this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';");
68+
}
69+
4870
/**
4971
* Opens the Moodle App in the browser and optionally logs in.
5072
*
@@ -215,13 +237,21 @@ public function i_load_more_items_in_the_app(bool $not = false) {
215237
/**
216238
* Trigger swipe gesture.
217239
*
218-
* @When /^I swipe to the (left|right) in the app$/
240+
* @When /^I swipe to the (left|right) (in (".+") )?in the app$/
219241
* @param string $direction Swipe direction
242+
* @param bool $hasLocator Whether a reference locator is used.
243+
* @param string $locator Reference locator.
220244
*/
221-
public function i_swipe_in_the_app(string $direction) {
222-
$method = 'swipe' . ucwords($direction);
245+
public function i_swipe_in_the_app(string $direction, bool $hasLocator = false, string $locator = '') {
246+
if ($hasLocator) {
247+
$locator = $this->parse_element_locator($locator);
248+
}
249+
250+
$result = $this->zone_js("swipe('$direction'" . ($hasLocator ? ", $locator" : '') . ')');
223251

224-
$this->zone_js("getAngularInstance('ion-content', 'CoreSwipeNavigationDirective').$method()");
252+
if ($result !== 'OK') {
253+
throw new DriverException('Error when swiping - ' . $result);
254+
}
225255

226256
$this->wait_for_pending_js();
227257

local_moodleappbehat/tests/behat/snapshots/failures/.gitkeep

Whitespace-only changes.

moodle.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"app_id": "com.moodle.moodlemobile",
33
"appname": "Moodle Mobile",
4-
"versioncode": 41001,
5-
"versionname": "4.1.0",
4+
"versioncode": 41100,
5+
"versionname": "4.1.1",
66
"cache_update_frequency_usually": 420000,
77
"cache_update_frequency_often": 1200000,
88
"cache_update_frequency_sometimes": 3600000,

0 commit comments

Comments
 (0)