-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add Autocomplete test helpers #248
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@crowdstrike/ember-toucan-core': patch | ||
'@crowdstrike/ember-toucan-form': patch | ||
--- | ||
|
||
add Autocomplete test helpers. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,12 +96,12 @@ export default class ToucanCoreAutocompleteOptionComponent extends Component<Tou | |
<template> | ||
{{! template-lint-disable require-presentational-children }} | ||
<li | ||
aria-current={{if @isActive "true" "false"}} | ||
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. 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. Replaces 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. Oh very nice! |
||
aria-selected={{if @isSelected "true" "false"}} | ||
class="my-0 flex cursor-default items-center gap-2 px-2 py-2 leading-4 | ||
{{this.styles}} | ||
{{this.className}} | ||
" | ||
data-active={{if @isActive "true" "false"}} | ||
id="{{@popoverId}}-{{@index}}" | ||
role="option" | ||
{{on "click" this.onClick}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { PageObject } from 'fractal-page-object'; | ||
|
||
export class AutocompletePageObject extends PageObject { | ||
get active() { | ||
return this.element | ||
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. We spread |
||
?.closest('[data-autocomplete]') | ||
?.querySelector('[aria-current="true"]'); | ||
} | ||
|
||
get list() { | ||
return this.element | ||
?.closest('[data-autocomplete]') | ||
?.querySelector('[role="listbox"]'); | ||
} | ||
|
||
get options() { | ||
return this.element | ||
?.closest('[data-autocomplete]') | ||
?.querySelectorAll('[role="option"]'); | ||
} | ||
|
||
get selected() { | ||
return this.element | ||
?.closest('[data-autocomplete]') | ||
?.querySelector('[aria-selected="true"]'); | ||
} | ||
|
||
get status() { | ||
return this.element | ||
?.closest('[data-autocomplete]') | ||
?.querySelector('[role="status"]'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { click } from '@ember/test-helpers'; | |
|
||
import { PageObject } from 'fractal-page-object'; | ||
|
||
export class Button extends PageObject { | ||
export class ButtonPageObject extends PageObject { | ||
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. Due to an export name change, should we consider a breaking-change changeset? I'd be okay making it a 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. I'm cool with that. Though I tend to wait to add a changeset until after PR review in case there's some discussion. I'll make sure to add one after approval. 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. Done. |
||
async click() { | ||
if (this.element) { | ||
await click(this.element); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { Button } from './components/button'; | ||
export { AutocompletePageObject } from './components/autocomplete'; | ||
export { ButtonPageObject } from './components/button'; |
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.
Bonus. Moved to the top. Happy to revert! But I'm guessing this what most people will be looking for when they visit the repository.