MOBILE-4496 behat: Fix webserver url

main
Noel De Martin 2024-01-25 17:41:28 +01:00
parent e0d92072a8
commit da976a08a7
3 changed files with 10 additions and 5 deletions

View File

@ -292,6 +292,8 @@ class behat_app_helper extends behat_base {
/** /**
* Replaces $WWWROOT for the url of the Moodle site. * Replaces $WWWROOT for the url of the Moodle site.
* *
* Using $WWWROOTPATTERN will replace it for a regex pattern.
*
* @Transform /^(.*\$WWWROOT.*)$/ * @Transform /^(.*\$WWWROOT.*)$/
* @param string $text Text. * @param string $text Text.
* @return string * @return string
@ -299,7 +301,10 @@ class behat_app_helper extends behat_base {
public function replace_wwwroot($text) { public function replace_wwwroot($text) {
global $CFG; global $CFG;
return str_replace('$WWWROOT', $CFG->behat_wwwroot, $text); $text = str_replace('$WWWROOTPATTERN', preg_quote($CFG->behat_wwwroot, '/'), $text);
$text = str_replace('$WWWROOT', $CFG->behat_wwwroot, $text);
return $text;
} }
/** /**

View File

@ -96,7 +96,7 @@ Feature: Test basic usage of login in app
And I should find "You must change your password to proceed." in the app And I should find "You must change your password to proceed." in the app
When I press "Change password" "ion-button" in the app When I press "Change password" "ion-button" in the app
Then the app should have opened a browser tab with url "webserver" Then the app should have opened a browser tab with url "$WWWROOTPATTERN"
When I close the browser tab opened by the app When I close the browser tab opened by the app
Then I should find "If you didn't change your password correctly, you'll be asked to do it again." in the app Then I should find "If you didn't change your password correctly, you'll be asked to do it again." in the app
@ -115,7 +115,7 @@ Feature: Test basic usage of login in app
But I should not find "Reconnect" in the app But I should not find "Reconnect" in the app
When I press "Change password" "ion-button" in the app When I press "Change password" "ion-button" in the app
Then the app should have opened a browser tab with url "webserver" Then the app should have opened a browser tab with url "$WWWROOTPATTERN"
When I switch to the browser tab opened by the app When I switch to the browser tab opened by the app
And I set the field "username" to "student1" And I set the field "username" to "student1"

View File

@ -17,7 +17,7 @@ Feature: Test basic usage of user features
And I should find "Before you continue, please fill in the required fields in your user profile." in the app And I should find "Before you continue, please fill in the required fields in your user profile." in the app
When I press "Complete profile" in the app When I press "Complete profile" in the app
Then the app should have opened a browser tab with url "webserver" Then the app should have opened a browser tab with url "$WWWROOTPATTERN"
When I close the browser tab opened by the app When I close the browser tab opened by the app
Then I should find "If you didn't complete your profile correctly, you'll be asked to do it again." in the app Then I should find "If you didn't complete your profile correctly, you'll be asked to do it again." in the app
@ -36,7 +36,7 @@ Feature: Test basic usage of user features
But I should not find "Reconnect" in the app But I should not find "Reconnect" in the app
When I press "Complete profile" in the app When I press "Complete profile" in the app
Then the app should have opened a browser tab with url "webserver" Then the app should have opened a browser tab with url "$WWWROOTPATTERN"
When I switch to the browser tab opened by the app When I switch to the browser tab opened by the app
And I set the field "username" to "student1" And I set the field "username" to "student1"