-
Notifications
You must be signed in to change notification settings - Fork 359
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
Changes from 8 commits
efaa27c
25084fd
ef0f7ba
0a84f39
75bf788
900f783
856188e
05cdaa6
7b3c6a5
a0b7fde
a4688c0
bc9922f
60d40b1
aa905f6
607299d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,11 @@ ariaTest( | |
|
||
if (links.length > 0) { | ||
await buttons[b].click(); | ||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ( |
||
|
||
t.is( | ||
await links[0].getAttribute('aria-current'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ const assertAttributeValues = require('../util/assertAttributeValues'); | |
const assertRovingTabindex = require('../util/assertRovingTabindex'); | ||
const assertHasFocus = require('../util/assertHasFocus'); | ||
const assertAttributeCanBeToggled = require('../util/assertAttributeCanBeToggled'); | ||
const translatePlatformKey = require('../util/translatePlatformKey'); | ||
|
||
const exampleFile = 'content/patterns/toolbar/examples/toolbar.html'; | ||
|
||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This being There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! I addressed with aa905f6. |
||
await textarea.sendKeys(Key.chord(...modifierKey, 'a')); | ||
let originalText = await textarea.getAttribute('value'); | ||
|
||
const buttons = await t.context.queryElements( | ||
|
@@ -1206,7 +1208,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); | ||
await textarea.sendKeys(Key.chord(...modifierKey, 'a')); | ||
let originalText = await textarea.getAttribute('value'); | ||
|
||
const buttons = await t.context.queryElements( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Returns true if the current platform is macOS | ||
* | ||
* @returns {boolean} | ||
*/ | ||
module.exports = function isMacOS() { | ||
return process.platform === 'darwin'; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { Key } = require('selenium-webdriver'); | ||
const isMacOS = require('./isMacOS'); | ||
|
||
const MAC_KEY_MAPPINGS = { | ||
[Key.CONTROL]: Key.META, | ||
}; | ||
|
||
/** | ||
* Translates a key or key combination for the current OS | ||
* | ||
* @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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
const keyArray = Array.isArray(keys) ? keys : [keys]; | ||
if (!isMacOS()) { | ||
return keyArray; | ||
} | ||
|
||
return keyArray.reduce((acc, key) => { | ||
const mappedKey = MAC_KEY_MAPPINGS[key] || key; | ||
return acc.concat(mappedKey); | ||
}, []); | ||
} | ||
|
||
module.exports = translatePlatformKey; |
There was a problem hiding this comment.
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
A few options here could be to:
regression-tests.sh
grep commands to not use-P
regression-tests.sh
to use perl commands directlyThere was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Reverted!