-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: export focusWithKeyboard, focusWithMouse & assert #23
Changes from all commits
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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
import { sendKeys } from '@web/test-runner-commands'; | ||
import { sendKeys, sendMouse } from '@web/test-runner-commands'; | ||
|
||
export const focusWithKeyboard = async(element) => { | ||
await sendKeys({ press: 'Escape' }); | ||
export async function focusWithKeyboard(element) { | ||
await sendKeys({ press: 'Shift' }); // Tab moves focus, Escape causes dismissible things to close | ||
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. As hinted at with the comment, when using this in core
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. Haha and if not we'll just keep expanding the comment until we find something that works |
||
element.focus({ focusVisible: true }); | ||
}; | ||
} | ||
|
||
export async function focusWithMouse(element) { | ||
const { x, y } = element.getBoundingClientRect(); | ||
await sendMouse({ type: 'click', position: [Math.ceil(x), Math.ceil(y)] }); | ||
await sendMouse({ type: 'move', position: [0, 0] }); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { aTimeout, defineCE, expect, html, nextFrame, oneEvent, waitUntil } from '@open-wc/testing'; | ||
export { assert, aTimeout, defineCE, expect, html, nextFrame, oneEvent, waitUntil } from '@open-wc/testing'; | ||
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. Adding |
||
export { focusWithKeyboard, focusWithMouse } from './focus.js'; | ||
export { fixture } from './fixture.js'; |
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.
Does linting want the
function
setup versus theconst
setup, or just trying to match the style of the repo? Or is there an advantage of one over the other?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.
This isn't linting related, it was more of a personal preference. TBH I'm not sure where or why the
const
setup was introduced... maybe in the old visual-diff library and it got copied a bunch of places? If someone knows more about why we'd want one vs. the other, chime in!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'm not sure, I feel like we use the
const
style randomly throughoutcore
, but it's not consistent. https://github.com/BrightspaceUI/core/blob/main/components/form/form-helper.jshttps://github.com/BrightspaceUI/core/blob/main/helpers/gestures.js
And I just flip back and forth depending on what the file is already doing, so was mostly curious!
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.
Outside of using the one that's necessary based on their differences (
this
, scope, hoisting), at the top level like this I'll usually use an arrow function for one-liners and regular function for anything longer.