From 5b5d654b32335b1ac2fece7d1eec8a0aadb222c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 2 May 2022 16:39:40 +0200 Subject: [PATCH] MOBILE-4061 behat: Adapt files to new behat plugin --- scripts/build-behat-plugin.js | 3 ++- scripts/templates/behat-plugin/classes/output/mobile.php | 2 +- scripts/templates/behat-plugin/db/mobile.php | 4 ++-- tests/behat/app_behat_runtime.js | 2 +- tests/behat/behat_app.php | 6 +++--- tests/behat/classes/performance_measure.php | 4 +++- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/build-behat-plugin.js b/scripts/build-behat-plugin.js index 9d12c355d..810243ac6 100755 --- a/scripts/build-behat-plugin.js +++ b/scripts/build-behat-plugin.js @@ -80,7 +80,8 @@ async function main() { } const newPath = featurePath.substring(0, featurePath.length - ('/tests/behat'.length)); - const prefix = relative(behatTempFeaturesPath, newPath).replace('/','-') || 'core'; + const searchRegExp = new RegExp('/', 'g'); + const prefix = relative(behatTempFeaturesPath, newPath).replace(searchRegExp,'-') || 'core'; const featureFilename = prefix + '-' + basename(featureFile); renameSync(featureFile, behatFeaturesPath + '/' + featureFilename); } diff --git a/scripts/templates/behat-plugin/classes/output/mobile.php b/scripts/templates/behat-plugin/classes/output/mobile.php index 88732ab38..bddc07bd8 100644 --- a/scripts/templates/behat-plugin/classes/output/mobile.php +++ b/scripts/templates/behat-plugin/classes/output/mobile.php @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -namespace local_moodlemobileapp\output; +namespace local_moodleappbehat\output; defined('MOODLE_INTERNAL') || die(); diff --git a/scripts/templates/behat-plugin/db/mobile.php b/scripts/templates/behat-plugin/db/mobile.php index 91b0def21..c829fa09d 100644 --- a/scripts/templates/behat-plugin/db/mobile.php +++ b/scripts/templates/behat-plugin/db/mobile.php @@ -16,7 +16,7 @@ // along with Moodle. If not, see . $addons = [ - 'local_moodlemobileapp' => [ + 'local_moodleappbehat' => [ 'handlers' => [ 'index' => [ 'delegate' => 'CoreMainMenuDelegate', @@ -28,7 +28,7 @@ $addons = [ ], ], 'lang' => [ - ['pluginname', 'local_moodlemobileapp'], + ['pluginname', 'local_moodleappbehat'], ], ], ]; diff --git a/tests/behat/app_behat_runtime.js b/tests/behat/app_behat_runtime.js index 19c3c7b75..9846e0cf1 100644 --- a/tests/behat/app_behat_runtime.js +++ b/tests/behat/app_behat_runtime.js @@ -601,7 +601,7 @@ case 'more menu': foundButton = findElementsBasedOnText({ text: 'More', - near: { text: 'Messages' }, + selector: 'ion-tab-button', })[0]; break; case 'user menu' : diff --git a/tests/behat/behat_app.php b/tests/behat/behat_app.php index 5cc4eb45c..1bbc5ba55 100644 --- a/tests/behat/behat_app.php +++ b/tests/behat/behat_app.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Mobile/desktop app steps definitions. + * Moodle App steps definitions. * * @package core * @category test @@ -49,7 +49,7 @@ interface behat_app_listener { } /** - * Mobile/desktop app steps definitions. + * Moodle App steps definitions. * * @package core * @category test @@ -518,7 +518,7 @@ class behat_app extends behat_base { $this->execute_script(" var script = document.createElement('script'); - script.src = '{$CFG->behat_wwwroot}/local/moodlemobileapp/tests/behat/app_behat_runtime.js'; + script.src = '{$CFG->behat_wwwroot}/local/moodleappbehat/tests/behat/app_behat_runtime.js'; document.body.append(script); "); diff --git a/tests/behat/classes/performance_measure.php b/tests/behat/classes/performance_measure.php index 4e3c8ee7d..f56125ae5 100644 --- a/tests/behat/classes/performance_measure.php +++ b/tests/behat/classes/performance_measure.php @@ -18,6 +18,8 @@ use Behat\Mink\Exception\DriverException; use Facebook\WebDriver\Exception\InvalidArgumentException; use Moodle\BehatExtension\Driver\WebDriver; +require_once(__DIR__ . '/../behat_app.php'); + /** * Performance measures for one particular metric. */ @@ -334,7 +336,7 @@ class performance_measure implements behat_app_listener { " ],", " ],", " ],", - ");", + "];", "", ]) );