Mercurial > hg > cmmr2012-drupal-site
annotate core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\FunctionalJavascriptTests\Ajax; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase; |
Chris@0 | 6 |
Chris@0 | 7 /** |
Chris@0 | 8 * Tests the Ajax image buttons work with key press events. |
Chris@0 | 9 * |
Chris@0 | 10 * @group Ajax |
Chris@0 | 11 */ |
Chris@0 | 12 class AjaxFormImageButtonTest extends JavascriptTestBase { |
Chris@0 | 13 |
Chris@0 | 14 /** |
Chris@0 | 15 * {@inheritdoc} |
Chris@0 | 16 */ |
Chris@0 | 17 public static $modules = ['ajax_forms_test']; |
Chris@0 | 18 |
Chris@0 | 19 /** |
Chris@0 | 20 * Tests image buttons can be operated with the keyboard ENTER key. |
Chris@0 | 21 */ |
Chris@0 | 22 public function testAjaxImageButton() { |
Chris@0 | 23 // Get a Field UI manage-display page. |
Chris@0 | 24 $this->drupalGet('ajax_forms_image_button_form'); |
Chris@0 | 25 $assertSession = $this->assertSession(); |
Chris@0 | 26 $session = $this->getSession(); |
Chris@0 | 27 |
Chris@0 | 28 $enter_key_event = <<<JS |
Chris@0 | 29 jQuery('#edit-image-button') |
Chris@0 | 30 .trigger(jQuery.Event('keypress', { |
Chris@0 | 31 which: 13 |
Chris@0 | 32 })); |
Chris@0 | 33 JS; |
Chris@0 | 34 // PhantomJS driver has buggy behavior with key events, we send a JavaScript |
Chris@0 | 35 // key event instead. |
Chris@0 | 36 // @todo: use WebDriver event when we remove PhantomJS driver. |
Chris@0 | 37 $session->executeScript($enter_key_event); |
Chris@0 | 38 |
Chris@0 | 39 $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed'); |
Chris@0 | 40 } |
Chris@0 | 41 |
Chris@0 | 42 } |