Problem/Motivation
AjaxFormImageButtonTest now extends WebDriverTestBase instead of JavascriptTestBase. There's a TODO item which was waiting for this change.
#2942900: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver
JavascriptTestBase is deprecated in favor of WebDriverTestBase
Keypress events weren't reliable with the PhantomJS driver, so the workaround was to trigger keypress events using \Behat\Mink\Session::executeScript(). This workaround is no longer needed, now that we're using the Selenium driver.
Note, this class only tests that the button responds to the enter key. However buttons are expected to respond when either the enter or space key is pressed. Let's cover this situation too. It's common to see faux-buttons like this in the wild:
<a href="#" role="button" onclick="foo()">Edit</a>
The button role tells screen readers to announce it as a button, yet it doesn't behave like a button because it can't be activated by the space key. That's a bug we can guard against by testing both keys.
Proposed resolution
- Replace the executeScript workaround. Find the button, and use a keyPress event.
Replicate the ENTER key press test, so we test the SPACE key behaviour too.DEFERRED to #3030363: Add test to assert ajax buttons are operable with the spacebar key..
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | interdiff-2996404-2-7.txt | 906 bytes | andrewmacpherson |
| #7 | 2996404-7.patch | 1.36 KB | andrewmacpherson |
Comments
Comment #2
andrewmacpherson commentedComment #3
krzysztof domańskiLooks good!
1. These changes are out-of-scope and we should open an additional tusk for this.
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
@@ -39,4 +39,17 @@ public function testAjaxImageButton() {
$this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed');
}
+ /**
+ * Tests image buttons can be operated with the keyboard SPACE key.
+ */
+ public function testAjaxImageButtonKeypressSpace() {
+ // Get a Field UI manage-display page.
+ $this->drupalGet('ajax_forms_image_button_form');
+ $assertSession = $this->assertSession();
+ $session = $this->getSession();
+
+ $button = $session->getPage()->findButton('Edit');
+ $button->keyPress(32);
+ }
+
}
2. I think this should be eligible for 8.6.x (test only).
#2942900: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver - has been changed in 8.6.x-dev.
JavascriptTestBase is deprecated in favor of WebDriverTestBase
Comment #4
andrewmacpherson commented@Krzysztof Domański - how is #3.1 out of scope?
Comment #5
andrewmacpherson commentedComment #6
krzysztof domański"Replicate the ENTER key press" and "Replace old keypress workaround in AjaxFormImageButtonTest" are two different topics.
We should avoid mixing a several bugs with one tusk so IMO this needs a separate issue.
Comment #7
andrewmacpherson commentedAh right, I didn't twig that you meant a separate d.o issue. To me it seemed that the existing test was flawed and could easily be improved at the same time.
Here's an updated patch which only updates the existing test. I'll file the spacebar test as a followup issue.
I kept the function name change to reflect what behaviour is actually being tested.
Haven't run the test locally yet, this change is simple enough to just send it to the test bots.
Comment #8
andrewmacpherson commentedtask 2 spun out to #3030363: Add test to assert ajax buttons are operable with the spacebar key.
Comment #9
krzysztof domańskiComment #10
knyshuk.vova commented+1 to RTBC
Comment #12
krzysztof domański#2990645: "Build Successful" is treated as a test failure
Comment #14
krzysztof domański#2990645: "Build Successful" is treated as a test failure
Comment #16
krzysztof domańskiRandom test failure.
#3035320: Random fails in TimestampAgoFormatterTest and DateTimeTimeAgoFormatterTest
Comment #18
krzysztof domańskiUnrelated test failure.
#3035318: `DateFormatter()` assumes 30 days per month, while February only has 28 days. Causes fails in tests.
Comment #19
tim.plunkettFixing tag
Comment #20
catchCommitted 369f1a0 and pushed to 8.7.x. Thanks!
Comment #22
andrewmacpherson commentedThe follow-up issue has a patch that needs review. #3030363: Add test to assert ajax buttons are operable with the spacebar key..