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

  1. Replace the executeScript workaround. Find the button, and use a keyPress event.
  2. 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..

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Status: Active » Needs review
StatusFileSize
new1.91 KB
krzysztof domański’s picture

Version: 8.7.x-dev » 8.6.x-dev
Issue summary: View changes
Status: Needs review » Needs work

Looks 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

andrewmacpherson’s picture

@Krzysztof Domański - how is #3.1 out of scope?

krzysztof domański’s picture

how is #3.1 out of scope?

"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.

andrewmacpherson’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +Needs followup
StatusFileSize
new1.36 KB
new906 bytes

Ah 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.

krzysztof domański’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Accessibility +accessibility
knyshuk.vova’s picture

+1 to RTBC

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2996404-7.patch, failed testing. View results

krzysztof domański’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2996404-7.patch, failed testing. View results

krzysztof domański’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2996404-7.patch, failed testing. View results

krzysztof domański’s picture

Status: Needs work » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2996404-7.patch, failed testing. View results

krzysztof domański’s picture

Status: Needs work » Reviewed & tested by the community
tim.plunkett’s picture

Issue tags: -accessibility (duplicate tag) +Accessibility

Fixing tag

catch’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 369f1a0 and pushed to 8.7.x. Thanks!

  • catch committed 944b157 on 8.7.x
    Issue #2996404 by andrewmacpherson, Krzysztof Domański: Replace old...
andrewmacpherson’s picture

The follow-up issue has a patch that needs review. #3030363: Add test to assert ajax buttons are operable with the spacebar key..

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.