Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure: Address failing macOS regression tests #3115

Merged
merged 15 commits into from
Dec 12, 2024

Conversation

stalgiag
Copy link
Contributor

@stalgiag stalgiag commented Sep 16, 2024

This PR adds two small utility methods: isMacOS() and translatePlatformKeys(). The latter utility takes a single Key or an array of Keys and returns the keys with any platform-specific Keys translated. For example, Keys.Control becomes Keys.Meta on macOS.

These utilities are then used in the toolbar_toolbar test to ensure that the OS-specific modifier key is used in the "select all text" chord.

This PR also adds a small delay to a disclosure_navigation_hybrid test to handle a scroll to focus event interfering with an assertion.

see #2735


WAI Preview Link (Last built on Wed, 11 Dec 2024 17:19:43 GMT).

@stalgiag stalgiag changed the title Use Key.META for text area all text selection for OS agnostic testing in toolbar_toolbar Use OS-specific modifier key for select all text in toolbar_toolbar test Sep 16, 2024
@stalgiag stalgiag changed the title Use OS-specific modifier key for select all text in toolbar_toolbar test Use OS-specific modifier key for 'select all text' command in toolbar_toolbar test Sep 16, 2024
Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stalgiag great job on getting this work started!

Found 2 additional failures when running on MacOS:

  1. disclosure_navigation_hybrid › content/patterns/disclosure/examples/disclosure-navigation-hybrid.html [data-test-id="link-aria-current"]: "aria-current" attribute on links
  2. combobox_grid-combo › content/patterns/combobox/examples/grid-combo.html [data-test-id="popup-key-home"]: Home from focus on list puts focus on grid and moves cursor
They were also described in #2735
─

  disclosure_navigation_hybrid › content/patterns/disclosure/examples/disclosure-navigation-hybrid.html [data-test-id="link-aria-current"]: "aria-current" attribute on links

  Rejected promise returned by test. Reason:

  ElementNotInteractableError {
    remoteStacktrace: `RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8␊
    WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:193:5␊
    ElementNotInteractableError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:353:5␊
    webdriverClickElement@chrome://remote/content/marionette/interaction.sys.mjs:167:11␊
    interaction.clickElement@chrome://remote/content/marionette/interaction.sys.mjs:136:11␊
    clickElement@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:205:29␊
    receiveMessage@chrome://remote/content/marionette/actors/MarionetteCommandsChild.sys.mjs:85:31␊
    `,
    message: 'Element <a href="#mythical-page-content"> could not be scrolled into view',
  }

  ElementNotInteractableError: Element <a href="#mythical-page-content"> could not be scrolled into view
      at Object.throwDecodedError (/Users/howard/Projects/aria/aria-practices/node_modules/selenium-webdriver/lib/error.js:521:15)
      at parseHttpResponse (/Users/howard/Projects/aria/aria-practices/node_modules/selenium-webdriver/lib/http.js:514:13)
      at Executor.execute (/Users/howard/Projects/aria/aria-practices/node_modules/selenium-webdriver/lib/http.js:446:28)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async thenableWebDriverProxy.execute (/Users/howard/Projects/aria/aria-practices/node_modules/selenium-webdriver/lib/webdriver.js:742:17)
      at async /Users/howard/Projects/aria/aria-practices/test/tests/disclosure_navigation_hybrid.js:85:9



  combobox_grid-combo › content/patterns/combobox/examples/grid-combo.html [data-test-id="popup-key-home"]: Home from focus on list puts focus on grid and moves cursor

  test/tests/combobox_grid-combo.js:880

   879:                                                           
   880:     t.true(                                               
   881:       await confirmCursorIndex(t, ex.comboboxSelector, 0),

  Cursor should be at index 0 after one ARROW_HOME key

  Value is not `true`:

  false

  › test/tests/combobox_grid-combo.js:880:11

  ─

I do like this approach of starting the OS specific test utilities here and targeted a specific test. It should make resolving those other 2 issues easier to handle in the future.

I'm okay with approving and pushing for this work to get merged. We should also make sure the original issue is updated with a comment so it's clear what the 2 remaining issues are.

@stalgiag stalgiag marked this pull request as draft December 4, 2024 19:28
@stalgiag stalgiag marked this pull request as ready for review December 4, 2024 20:09
@stalgiag stalgiag changed the title Use OS-specific modifier key for 'select all text' command in toolbar_toolbar test Address failing macOS regression tests, add macOS regression tests to workflow suite Dec 4, 2024
await links[0].click();
// Add a small delay here to ensure that the scroll to focus event
// has time to complete and doesn't interfere with the next assertion
await t.context.session.sleep(300);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was giving intermittent failures. I determined that this was due to the scroll to focus event fired by the link click interfering with the assertion (buttons[1] always failed). This small delay fixes this issue.

* @param {string|string[]} keys - The key(s) to translate
* @returns {string[]} - The translated key(s) as a flat array ready for spreading
*/
function translatePlatformKey(keys) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is potentially prematurely complex. I wanted to support instances when a platform key translation may be represented by chord -> single key or single key -> chord. We do not need this functionality now since we don't use any examples of this. I am open to reverting to a map if that is preferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It potentially is but I could see the need for this as we move to ensuring tests are platform agnostic. Perhaps providing a clear example in the JSDoc will also be helpful.

@stalgiag stalgiag requested a review from howard-e December 4, 2024 20:16
Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stalgiag thanks so much for doing so much research into what's happening here! Left some inline comments

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this alone won't be enough because the grep -P flag being used in regression-tests.sh is invalid for macOS's grep. MacOS uses BSD grep which doesn't support perl compatible regex. GNU grep does.

The invalid use is being thrown in the build log (although not throwing an error code).

invalid grep -P option message
> Run ./scripts/regression-tests.sh
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]

A few options here could be to:

  1. Rewriting regression-tests.sh grep commands to not use -P
  2. Converting regression-tests.sh to use perl commands directly
  3. Using GNU's homebrew provided grep in the workflow. (I already have an example of this here and it seems like the most straightforward option to do)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I decided to go with number 3 since you already have a well-written example.

With these updates, I see that there are a handful of tests that do not fail on my local machine but do fail on macOS in the Github workflows. Unfortunately, many of these appear to be flakey failures. I see two options:

  1. Revert the changes that add mac regression testing to CI
  2. Address the new set of tests that only fail on CI in this PR as well

I am open to either. I just don't want to merge new workflows in that stand to impede development with flakey failures. Curious what your thoughts are.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, definitely flaky. I prefer going with number 1 here. I'd rather there be some dedicated focus and surety so as to not introduce additional CI flakiness. Would rather a follow up PR to introduce these workflows after some robust testing.

Also re-ran the tests multiple times on my macOS and not seeing those failures, so some dedicated effort on figuring out why it's happening in CI would be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Reverted!

test/tests/combobox_grid-combo.js Show resolved Hide resolved
* @param {string|string[]} keys - The key(s) to translate
* @returns {string[]} - The translated key(s) as a flat array ready for spreading
*/
function translatePlatformKey(keys) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It potentially is but I could see the need for this as we move to ensuring tests are platform agnostic. Perhaps providing a clear example in the JSDoc will also be helpful.

@@ -1115,7 +1116,8 @@ ariaTest(
'toolbar-button-enter-or-space',
async (t) => {
let textarea = await t.context.session.findElement(By.css('textarea'));
await textarea.sendKeys(Key.chord(Key.CONTROL, 'a'));
let modifierKey = translatePlatformKey(Key.CONTROL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This being modifierKey as an array could be confusing. Renaming to modifierKeys works? Although maybe just as confusing given a single value was passed. I suppose this goes back to having the function provide a clear example of usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I addressed with aa905f6.

@stalgiag stalgiag requested a review from howard-e December 11, 2024 17:20
@howard-e howard-e changed the title Address failing macOS regression tests, add macOS regression tests to workflow suite Infrastructure: Address failing macOS regression tests, add macOS regression tests to workflow suite Dec 12, 2024
@howard-e howard-e added Infrastructure Related to maintaining task force and repo operations, processes, systems, documentation regression-testing Related to AVA regression tests of example pages or AVA framework implementation within repo labels Dec 12, 2024
Copy link
Contributor

@howard-e howard-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stalgiag thanks for addressing the feedback. These changes LGTM now and should also make future instances of platform based issues easier to handle!

@howard-e howard-e changed the title Infrastructure: Address failing macOS regression tests, add macOS regression tests to workflow suite Infrastructure: Address failing macOS regression tests Dec 12, 2024
@howard-e howard-e merged commit 37c5fc7 into main Dec 12, 2024
17 checks passed
@howard-e howard-e deleted the fix-toolbar_toolbar-tests branch December 12, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Related to maintaining task force and repo operations, processes, systems, documentation regression-testing Related to AVA regression tests of example pages or AVA framework implementation within repo
Projects
Status: In staging/sandbox
Development

Successfully merging this pull request may close these issues.

2 participants