Skip to content

Commit 4496659

Browse files
[auto-generated] Update plugin files
Check out the commits that caused these changes: moodlehq/moodleapp@f84a0c6...28b48ac
1 parent cd98b99 commit 4496659

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

tests/behat/behat_app.php

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,21 @@ class behat_app extends behat_app_helper {
4444
],
4545
];
4646

47+
protected $featurepath = '';
4748
protected $windowsize = '360x720';
4849

4950
/**
5051
* @BeforeScenario
5152
*/
5253
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;
54+
$feature = $scope->getFeature();
6055

61-
if ($performanceLogs !== 'ALL') {
56+
if (!$feature->hasTag('app')) {
6257
return;
6358
}
6459

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=/';");
60+
$this->featurepath = dirname($feature->getFile());
61+
$this->configure_performance_logs();
6862
}
6963

7064
/**
@@ -89,6 +83,23 @@ public function i_enter_the_app(string $username = null) {
8983
$this->enter_site();
9084
}
9185

86+
/**
87+
* Configure performance logs.
88+
*/
89+
protected function configure_performance_logs() {
90+
global $CFG;
91+
92+
$performanceLogs = $CFG->behat_profiles['default']['capabilities']['extra_capabilities']['goog:loggingPrefs']['performance'] ?? null;
93+
94+
if ($performanceLogs !== 'ALL') {
95+
return;
96+
}
97+
98+
// Enable DB Logging only for app tests with performance logs activated.
99+
$this->getSession()->visit($this->get_app_url() . '/assets/env.json');
100+
$this->execute_script("document.cookie = 'MoodleAppDBLoggingEnabled=true;path=/';");
101+
}
102+
92103
/**
93104
* Check whether the current page is the login form.
94105
*/
@@ -778,6 +789,35 @@ public function i_set_the_following_fields_to_these_values_in_the_app(TableNode
778789
}
779790
}
780791

792+
/**
793+
* Uploads a file to a file input, the file path should be relative to a fixtures folder next to the feature file.
794+
* The ìnput locator can match a container with a file input inside, it doesn't have to be the input itself.
795+
*
796+
* @Given /^I upload "((?:[^"]|\\")+)" to (".+") in the app$/
797+
* @param string $filename
798+
* @param string $inputlocator
799+
*/
800+
public function i_upload_a_file_in_the_app(string $filename, string $inputlocator) {
801+
$filepath = str_replace('/', DIRECTORY_SEPARATOR, "{$this->featurepath}/fixtures/$filename");
802+
$inputlocator = $this->parse_element_locator($inputlocator);
803+
804+
$id = $this->spin(function() use ($inputlocator) {
805+
$result = $this->runtime_js("getFileInputId($inputlocator)");
806+
807+
if (str_starts_with($result, 'ERROR')) {
808+
throw new DriverException('Error finding input - ' . $result);
809+
}
810+
811+
return $result;
812+
});
813+
814+
$this->wait_for_pending_js();
815+
816+
$fileinput = $this ->getSession()->getPage()->findById($id);
817+
818+
$fileinput->attachFile($filepath);
819+
}
820+
781821
/**
782822
* Checks a field matches a certain value in the app.
783823
*

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
defined('MOODLE_INTERNAL') || die;
88

9-
$plugin->version = 2023021600;
9+
$plugin->version = 2023041700;
1010
$plugin->requires = 2016052300;
1111
$plugin->maturity = MATURITY_STABLE;
1212
$plugin->release = '4.1.1';

0 commit comments

Comments
 (0)