MDL-75985 behat: Standardise HTML output when comparing editor content

This commit adds a standardise_html function and updates the matches
function to compare normalised content.

This allows for a wider variety of valid editor output to be handled
using the standard value matching steps in Behat, thus supporting
editors other than Atto better.
This commit is contained in:
Andrew Nicols 2022-10-13 16:03:49 +08:00
parent 3bc792b9b8
commit febd5d944c
3 changed files with 72 additions and 6 deletions

View file

@ -1776,7 +1776,17 @@ EOF;
* @param string $keys The key, or list of keys, to type
*/
public function i_type(string $keys): void {
behat_base::type_keys($this->getSession(), str_split($keys));
// Certain keys, such as the newline character, must be converted to the appropriate character code.
// Without this, keys will behave differently depending on the browser.
$keylist = array_map(function($key): string {
switch ($key) {
case '\n':
behat_keys::ENTER;
default:
return $key;
}
}, str_split($keys));
behat_base::type_keys($this->getSession(), $keylist);
}
/**