-
Notifications
You must be signed in to change notification settings - Fork 469
feat: add allowed roles to role query types #670
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,205 @@ | ||
import { Matcher, MatcherOptions } from './matches'; | ||
import { SelectorMatcherOptions } from './query-helpers'; | ||
import { waitForOptions } from './wait-for'; | ||
import {Matcher, MatcherOptions} from './matches' | ||
import {SelectorMatcherOptions} from './query-helpers' | ||
import {waitForOptions} from './wait-for' | ||
import {ARIARole} from 'aria-query' | ||
|
||
export type QueryByBoundAttribute = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
) => HTMLElement | null; | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
) => HTMLElement | null | ||
|
||
export type AllByBoundAttribute = (container: HTMLElement, id: Matcher, options?: MatcherOptions) => HTMLElement[]; | ||
export type AllByBoundAttribute = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
) => HTMLElement[] | ||
|
||
export type FindAllByBoundAttribute = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement[]>; | ||
|
||
export type GetByBoundAttribute = (container: HTMLElement, id: Matcher, options?: MatcherOptions) => HTMLElement; | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement[]> | ||
|
||
export type GetByBoundAttribute = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
) => HTMLElement | ||
|
||
export type FindByBoundAttribute = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement>; | ||
|
||
export type QueryByText = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => HTMLElement | null; | ||
|
||
export type AllByText = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => HTMLElement[]; | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: MatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement> | ||
|
||
export type QueryByText = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
) => HTMLElement | null | ||
|
||
export type AllByText = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
) => HTMLElement[] | ||
|
||
export type FindAllByText = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement[]>; | ||
|
||
export type GetByText = (container: HTMLElement, id: Matcher, options?: SelectorMatcherOptions) => HTMLElement; | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement[]> | ||
|
||
export type GetByText = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
) => HTMLElement | ||
|
||
export type FindByText = ( | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement>; | ||
container: HTMLElement, | ||
id: Matcher, | ||
options?: SelectorMatcherOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement> | ||
|
||
export interface ByRoleOptions extends MatcherOptions { | ||
/** | ||
* If true includes elements in the query set that are usually excluded from | ||
* the accessibility tree. `role="none"` or `role="presentation"` are included | ||
* in either case. | ||
*/ | ||
hidden?: boolean; | ||
/** | ||
* If true only includes elements in the query set that are marked as | ||
* selected in the accessibility tree, i.e., `aria-selected="true"` | ||
*/ | ||
selected?: boolean; | ||
/** | ||
* Includes every role used in the `role` attribute | ||
* For example *ByRole('progressbar', {queryFallbacks: true})` will find <div role="meter progressbar">`. | ||
*/ | ||
queryFallbacks?: boolean; | ||
/** | ||
* Only considers elements with the specified accessible name. | ||
*/ | ||
name?: string | RegExp | ((accessibleName: string, element: Element) => boolean); | ||
/** | ||
* If true includes elements in the query set that are usually excluded from | ||
* the accessibility tree. `role="none"` or `role="presentation"` are included | ||
* in either case. | ||
*/ | ||
hidden?: boolean | ||
/** | ||
* If true only includes elements in the query set that are marked as | ||
* selected in the accessibility tree, i.e., `aria-selected="true"` | ||
*/ | ||
selected?: boolean | ||
/** | ||
* Includes every role used in the `role` attribute | ||
* For example *ByRole('progressbar', {queryFallbacks: true})` will find <div role="meter progressbar">`. | ||
*/ | ||
queryFallbacks?: boolean | ||
/** | ||
* Only considers elements with the specified accessible name. | ||
*/ | ||
name?: | ||
| string | ||
| RegExp | ||
| ((accessibleName: string, element: Element) => boolean) | ||
} | ||
|
||
export type AllByRole = (container: HTMLElement, role: Matcher, options?: ByRoleOptions) => HTMLElement[]; | ||
|
||
export type GetByRole = (container: HTMLElement, role: Matcher, options?: ByRoleOptions) => HTMLElement; | ||
|
||
export type QueryByRole = (container: HTMLElement, role: Matcher, options?: ByRoleOptions) => HTMLElement | null; | ||
|
||
export type FindByRole = ( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement>; | ||
|
||
export type FindAllByRole = ( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
) => Promise<HTMLElement[]>; | ||
|
||
export const getByLabelText: GetByText; | ||
export const getAllByLabelText: AllByText; | ||
export const queryByLabelText: QueryByText; | ||
export const queryAllByLabelText: AllByText; | ||
export const findByLabelText: FindByText; | ||
export const findAllByLabelText: FindAllByText; | ||
export const getByPlaceholderText: GetByBoundAttribute; | ||
export const getAllByPlaceholderText: AllByBoundAttribute; | ||
export const queryByPlaceholderText: QueryByBoundAttribute; | ||
export const queryAllByPlaceholderText: AllByBoundAttribute; | ||
export const findByPlaceholderText: FindByBoundAttribute; | ||
export const findAllByPlaceholderText: FindAllByBoundAttribute; | ||
export const getByText: GetByText; | ||
export const getAllByText: AllByText; | ||
export const queryByText: QueryByText; | ||
export const queryAllByText: AllByText; | ||
export const findByText: FindByText; | ||
export const findAllByText: FindAllByText; | ||
export const getByAltText: GetByBoundAttribute; | ||
export const getAllByAltText: AllByBoundAttribute; | ||
export const queryByAltText: QueryByBoundAttribute; | ||
export const queryAllByAltText: AllByBoundAttribute; | ||
export const findByAltText: FindByBoundAttribute; | ||
export const findAllByAltText: FindAllByBoundAttribute; | ||
export const getByTitle: GetByBoundAttribute; | ||
export const getAllByTitle: AllByBoundAttribute; | ||
export const queryByTitle: QueryByBoundAttribute; | ||
export const queryAllByTitle: AllByBoundAttribute; | ||
export const findByTitle: FindByBoundAttribute; | ||
export const findAllByTitle: FindAllByBoundAttribute; | ||
export const getByDisplayValue: GetByBoundAttribute; | ||
export const getAllByDisplayValue: AllByBoundAttribute; | ||
export const queryByDisplayValue: QueryByBoundAttribute; | ||
export const queryAllByDisplayValue: AllByBoundAttribute; | ||
export const findByDisplayValue: FindByBoundAttribute; | ||
export const findAllByDisplayValue: FindAllByBoundAttribute; | ||
export const getByRole: GetByRole; | ||
export const getAllByRole: AllByRole; | ||
export const queryByRole: QueryByRole; | ||
export const queryAllByRole: AllByRole; | ||
export const findByRole: FindByRole; | ||
export const findAllByRole: FindAllByRole; | ||
export const getByTestId: GetByBoundAttribute; | ||
export const getAllByTestId: AllByBoundAttribute; | ||
export const queryByTestId: QueryByBoundAttribute; | ||
export const queryAllByTestId: AllByBoundAttribute; | ||
export const findByTestId: FindByBoundAttribute; | ||
export const findAllByTestId: FindAllByBoundAttribute; | ||
// disable unified-signatures to have intellisense for aria roles | ||
/* tslint:disable:unified-signatures */ | ||
export function AllByRole( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
): HTMLElement[] | ||
export function AllByRole( | ||
container: HTMLElement, | ||
role: ARIARole, | ||
options?: ByRoleOptions, | ||
): HTMLElement[] | ||
|
||
export function GetByRole( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
): HTMLElement | ||
export function GetByRole( | ||
container: HTMLElement, | ||
role: ARIARole, | ||
options?: ByRoleOptions, | ||
): HTMLElement | ||
|
||
export function QueryByRole( | ||
container: HTMLElement, | ||
role: Matcher | ByRoleOptions, | ||
options?: ByRoleOptions, | ||
): HTMLElement | null | ||
export function QueryByRole( | ||
container: HTMLElement, | ||
role: ARIARole, | ||
options?: ByRoleOptions, | ||
): HTMLElement | null | ||
|
||
export function FindByRole( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
): Promise<HTMLElement> | ||
export function FindByRole( | ||
container: HTMLElement, | ||
role: ARIARole, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
): Promise<HTMLElement> | ||
|
||
export function FindAllByRole( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
): Promise<HTMLElement[]> | ||
export function FindAllByRole( | ||
container: HTMLElement, | ||
role: Matcher, | ||
options?: ByRoleOptions, | ||
waitForElementOptions?: waitForOptions, | ||
): Promise<HTMLElement[]> | ||
/* tslint:enable */ | ||
|
||
export const getByLabelText: GetByText | ||
export const getAllByLabelText: AllByText | ||
export const queryByLabelText: QueryByText | ||
export const queryAllByLabelText: AllByText | ||
export const findByLabelText: FindByText | ||
export const findAllByLabelText: FindAllByText | ||
export const getByPlaceholderText: GetByBoundAttribute | ||
export const getAllByPlaceholderText: AllByBoundAttribute | ||
export const queryByPlaceholderText: QueryByBoundAttribute | ||
export const queryAllByPlaceholderText: AllByBoundAttribute | ||
export const findByPlaceholderText: FindByBoundAttribute | ||
export const findAllByPlaceholderText: FindAllByBoundAttribute | ||
export const getByText: GetByText | ||
export const getAllByText: AllByText | ||
export const queryByText: QueryByText | ||
export const queryAllByText: AllByText | ||
export const findByText: FindByText | ||
export const findAllByText: FindAllByText | ||
export const getByAltText: GetByBoundAttribute | ||
export const getAllByAltText: AllByBoundAttribute | ||
export const queryByAltText: QueryByBoundAttribute | ||
export const queryAllByAltText: AllByBoundAttribute | ||
export const findByAltText: FindByBoundAttribute | ||
export const findAllByAltText: FindAllByBoundAttribute | ||
export const getByTitle: GetByBoundAttribute | ||
export const getAllByTitle: AllByBoundAttribute | ||
export const queryByTitle: QueryByBoundAttribute | ||
export const queryAllByTitle: AllByBoundAttribute | ||
export const findByTitle: FindByBoundAttribute | ||
export const findAllByTitle: FindAllByBoundAttribute | ||
export const getByDisplayValue: GetByBoundAttribute | ||
export const getAllByDisplayValue: AllByBoundAttribute | ||
export const queryByDisplayValue: QueryByBoundAttribute | ||
export const queryAllByDisplayValue: AllByBoundAttribute | ||
export const findByDisplayValue: FindByBoundAttribute | ||
export const findAllByDisplayValue: FindAllByBoundAttribute | ||
export const getByRole: typeof GetByRole | ||
export const getAllByRole: typeof AllByRole | ||
export const queryByRole: typeof QueryByRole | ||
export const queryAllByRole: typeof AllByRole | ||
export const findByRole: typeof FindByRole | ||
export const findAllByRole: typeof FindAllByRole | ||
export const getByTestId: GetByBoundAttribute | ||
export const getAllByTestId: AllByBoundAttribute | ||
export const queryByTestId: QueryByBoundAttribute | ||
export const queryAllByTestId: AllByBoundAttribute | ||
export const findByTestId: FindByBoundAttribute | ||
export const findAllByTestId: FindAllByBoundAttribute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Disabled whitespace checks because this clashes with our prettier configuration.