Issue #2937073 by tim.plunkett, Saviktor, tedbow: Improve robustness of FieldBlockTest
parent
e1832a2c2b
commit
06dbc81f02
|
@ -91,7 +91,7 @@ class FieldBlockTest extends WebDriverTestBase {
|
|||
$assert_session->fieldNotExists('settings[formatter][settings][format_type]');
|
||||
$assert_session->fieldExists('settings[formatter][settings][granularity]');
|
||||
$page->pressButton('Save block');
|
||||
$assert_session->pageTextContains('The block configuration has been saved.');
|
||||
$this->assertTrue($assert_session->waitForText('The block configuration has been saved.'));
|
||||
|
||||
// Configure the block and change the formatter again.
|
||||
$this->clickLink('Configure');
|
||||
|
@ -101,7 +101,7 @@ class FieldBlockTest extends WebDriverTestBase {
|
|||
$page->selectFieldOption('settings[formatter][settings][format_type]', 'long');
|
||||
|
||||
$page->pressButton('Save block');
|
||||
$assert_session->pageTextContains('The block configuration has been saved.');
|
||||
$this->assertTrue($assert_session->waitForText('The block configuration has been saved.'));
|
||||
|
||||
// Assert that the field value is updated.
|
||||
$this->clickLink('Configure');
|
||||
|
|
|
@ -101,6 +101,26 @@ JS;
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the specified text and returns its element when available.
|
||||
*
|
||||
* @param string $text
|
||||
* The text to wait for.
|
||||
* @param int $timeout
|
||||
* (Optional) Timeout in milliseconds, defaults to 10000.
|
||||
*
|
||||
* @return \Behat\Mink\Element\NodeElement|null
|
||||
* The page element node if found and visible, NULL if not.
|
||||
*/
|
||||
public function waitForText($text, $timeout = 10000) {
|
||||
$page = $this->session->getPage();
|
||||
return $page->waitFor($timeout / 1000, function () use ($page, $text) {
|
||||
$actual = preg_replace('/\s+/u', ' ', $page->getText());
|
||||
$regex = '/' . preg_quote($text, '/') . '/ui';
|
||||
return (bool) preg_match($regex, $actual);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a button (input[type=submit|image|button|reset], button) with
|
||||
* specified locator and returns it.
|
||||
|
|
Loading…
Reference in New Issue