mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 14:39:26 -02:30
Merge pull request #10245 from tiagodread/add-testability
Add testability to the search and pagination fields Add locators to search fields See: #10241 Reviewed-by: Jake McDermott <yo@jakemcdermott.me>
This commit is contained in:
@@ -19,6 +19,7 @@ const AWXPagination = styled(PFPagination)`
|
|||||||
|
|
||||||
export default props => (
|
export default props => (
|
||||||
<AWXPagination
|
<AWXPagination
|
||||||
|
ouiaId="pagination"
|
||||||
titles={{
|
titles={{
|
||||||
items: t`items`,
|
items: t`items`,
|
||||||
page: t`page`,
|
page: t`page`,
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ function AdvancedSearch({
|
|||||||
return (
|
return (
|
||||||
<AdvancedGroup>
|
<AdvancedGroup>
|
||||||
<Select
|
<Select
|
||||||
|
ouiaId="set-type-typeahead"
|
||||||
aria-label={t`Set type select`}
|
aria-label={t`Set type select`}
|
||||||
className="setTypeSelect"
|
className="setTypeSelect"
|
||||||
variant={SelectVariant.typeahead}
|
variant={SelectVariant.typeahead}
|
||||||
@@ -99,22 +100,26 @@ function AdvancedSearch({
|
|||||||
noResultsFoundText={t`No results found`}
|
noResultsFoundText={t`No results found`}
|
||||||
>
|
>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="and-option-select"
|
||||||
key="and"
|
key="and"
|
||||||
value="and"
|
value="and"
|
||||||
description={t`Returns results that satisfy this one as well as other filters. This is the default set type if nothing is selected.`}
|
description={t`Returns results that satisfy this one as well as other filters. This is the default set type if nothing is selected.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="or-option-select"
|
||||||
key="or"
|
key="or"
|
||||||
value="or"
|
value="or"
|
||||||
description={t`Returns results that satisfy this one or any other filters.`}
|
description={t`Returns results that satisfy this one or any other filters.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="not-option-select"
|
||||||
key="not"
|
key="not"
|
||||||
value="not"
|
value="not"
|
||||||
description={t`Returns results that have values other than this one as well as other filters.`}
|
description={t`Returns results that have values other than this one as well as other filters.`}
|
||||||
/>
|
/>
|
||||||
</Select>
|
</Select>
|
||||||
<Select
|
<Select
|
||||||
|
ouiaId="set-key-typeahead"
|
||||||
aria-label={t`Key select`}
|
aria-label={t`Key select`}
|
||||||
className="keySelect"
|
className="keySelect"
|
||||||
variant={SelectVariant.typeahead}
|
variant={SelectVariant.typeahead}
|
||||||
@@ -131,12 +136,17 @@ function AdvancedSearch({
|
|||||||
noResultsFoundText={t`No results found`}
|
noResultsFoundText={t`No results found`}
|
||||||
>
|
>
|
||||||
{allKeys.map(optionKey => (
|
{allKeys.map(optionKey => (
|
||||||
<SelectOption key={optionKey} value={optionKey}>
|
<SelectOption
|
||||||
|
key={optionKey}
|
||||||
|
value={optionKey}
|
||||||
|
id={`select-option-${optionKey}`}
|
||||||
|
>
|
||||||
{optionKey}
|
{optionKey}
|
||||||
</SelectOption>
|
</SelectOption>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
<Select
|
<Select
|
||||||
|
ouiaId="set-lookup-typeahead"
|
||||||
aria-label={t`Lookup select`}
|
aria-label={t`Lookup select`}
|
||||||
className="lookupSelect"
|
className="lookupSelect"
|
||||||
variant={SelectVariant.typeahead}
|
variant={SelectVariant.typeahead}
|
||||||
@@ -151,81 +161,97 @@ function AdvancedSearch({
|
|||||||
noResultsFoundText={t`No results found`}
|
noResultsFoundText={t`No results found`}
|
||||||
>
|
>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="exact-option-select"
|
||||||
key="exact"
|
key="exact"
|
||||||
value="exact"
|
value="exact"
|
||||||
description={t`Exact match (default lookup if not specified).`}
|
description={t`Exact match (default lookup if not specified).`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="iexact-option-select"
|
||||||
key="iexact"
|
key="iexact"
|
||||||
value="iexact"
|
value="iexact"
|
||||||
description={t`Case-insensitive version of exact.`}
|
description={t`Case-insensitive version of exact.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="contains-option-select"
|
||||||
key="contains"
|
key="contains"
|
||||||
value="contains"
|
value="contains"
|
||||||
description={t`Field contains value.`}
|
description={t`Field contains value.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="icontains-option-select"
|
||||||
key="icontains"
|
key="icontains"
|
||||||
value="icontains"
|
value="icontains"
|
||||||
description={t`Case-insensitive version of contains`}
|
description={t`Case-insensitive version of contains`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="startswith-option-select"
|
||||||
key="startswith"
|
key="startswith"
|
||||||
value="startswith"
|
value="startswith"
|
||||||
description={t`Field starts with value.`}
|
description={t`Field starts with value.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="istartswith-option-select"
|
||||||
key="istartswith"
|
key="istartswith"
|
||||||
value="istartswith"
|
value="istartswith"
|
||||||
description={t`Case-insensitive version of startswith.`}
|
description={t`Case-insensitive version of startswith.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="endswith-option-select"
|
||||||
key="endswith"
|
key="endswith"
|
||||||
value="endswith"
|
value="endswith"
|
||||||
description={t`Field ends with value.`}
|
description={t`Field ends with value.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="iendswith-option-select"
|
||||||
key="iendswith"
|
key="iendswith"
|
||||||
value="iendswith"
|
value="iendswith"
|
||||||
description={t`Case-insensitive version of endswith.`}
|
description={t`Case-insensitive version of endswith.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="regex-option-select"
|
||||||
key="regex"
|
key="regex"
|
||||||
value="regex"
|
value="regex"
|
||||||
description={t`Field matches the given regular expression.`}
|
description={t`Field matches the given regular expression.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="iregex-option-select"
|
||||||
key="iregex"
|
key="iregex"
|
||||||
value="iregex"
|
value="iregex"
|
||||||
description={t`Case-insensitive version of regex.`}
|
description={t`Case-insensitive version of regex.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="gt-option-select"
|
||||||
key="gt"
|
key="gt"
|
||||||
value="gt"
|
value="gt"
|
||||||
description={t`Greater than comparison.`}
|
description={t`Greater than comparison.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="gte-option-select"
|
||||||
key="gte"
|
key="gte"
|
||||||
value="gte"
|
value="gte"
|
||||||
description={t`Greater than or equal to comparison.`}
|
description={t`Greater than or equal to comparison.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="lt-option-select"
|
||||||
key="lt"
|
key="lt"
|
||||||
value="lt"
|
value="lt"
|
||||||
description={t`Less than comparison.`}
|
description={t`Less than comparison.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="lte-option-select"
|
||||||
key="lte"
|
key="lte"
|
||||||
value="lte"
|
value="lte"
|
||||||
description={t`Less than or equal to comparison.`}
|
description={t`Less than or equal to comparison.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="isnull-option-select"
|
||||||
key="isnull"
|
key="isnull"
|
||||||
value="isnull"
|
value="isnull"
|
||||||
description={t`Check whether the given field or related object is null; expects a boolean value.`}
|
description={t`Check whether the given field or related object is null; expects a boolean value.`}
|
||||||
/>
|
/>
|
||||||
<SelectOption
|
<SelectOption
|
||||||
|
id="in-option-select"
|
||||||
key="in"
|
key="in"
|
||||||
value="in"
|
value="in"
|
||||||
description={t`Check whether the given field's value is present in the list provided; expects a comma-separated list of items.`}
|
description={t`Check whether the given field's value is present in the list provided; expects a comma-separated list of items.`}
|
||||||
@@ -233,6 +259,7 @@ function AdvancedSearch({
|
|||||||
</Select>
|
</Select>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
data-cy="advanced-search-text-input"
|
||||||
type="search"
|
type="search"
|
||||||
aria-label={t`Advanced search value input`}
|
aria-label={t`Advanced search value input`}
|
||||||
isDisabled={!keySelection}
|
isDisabled={!keySelection}
|
||||||
@@ -242,6 +269,7 @@ function AdvancedSearch({
|
|||||||
/>
|
/>
|
||||||
<div css={!searchValue && `cursor:not-allowed`}>
|
<div css={!searchValue && `cursor:not-allowed`}>
|
||||||
<Button
|
<Button
|
||||||
|
ouiaId="advanced-search-text-input"
|
||||||
variant={ButtonVariant.control}
|
variant={ButtonVariant.control}
|
||||||
isDisabled={!searchValue}
|
isDisabled={!searchValue}
|
||||||
aria-label={t`Search submit button`}
|
aria-label={t`Search submit button`}
|
||||||
@@ -253,6 +281,7 @@ function AdvancedSearch({
|
|||||||
</InputGroup>
|
</InputGroup>
|
||||||
<Tooltip content={t`Advanced search documentation`} position="bottom">
|
<Tooltip content={t`Advanced search documentation`} position="bottom">
|
||||||
<Button
|
<Button
|
||||||
|
ouiaId="search-docs-button"
|
||||||
component="a"
|
component="a"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ function Search({
|
|||||||
{/* TODO: add support for dates:
|
{/* TODO: add support for dates:
|
||||||
qsConfig.dateFields.filter(field => field === key).length && "date" */}
|
qsConfig.dateFields.filter(field => field === key).length && "date" */}
|
||||||
<TextInput
|
<TextInput
|
||||||
|
data-cy="search-text-input"
|
||||||
type={
|
type={
|
||||||
(qsConfig.integerFields.find(
|
(qsConfig.integerFields.find(
|
||||||
field => field === searchKey
|
field => field === searchKey
|
||||||
@@ -279,6 +280,7 @@ function Search({
|
|||||||
/>
|
/>
|
||||||
<div css={!searchValue && `cursor:not-allowed`}>
|
<div css={!searchValue && `cursor:not-allowed`}>
|
||||||
<Button
|
<Button
|
||||||
|
ouiaId="search-submit-button"
|
||||||
variant={ButtonVariant.control}
|
variant={ButtonVariant.control}
|
||||||
isDisabled={!searchValue || isDisabled}
|
isDisabled={!searchValue || isDisabled}
|
||||||
aria-label={t`Search submit button`}
|
aria-label={t`Search submit button`}
|
||||||
|
|||||||
Reference in New Issue
Block a user