Merge pull request #5377 from dsesami/new-ids

Updated some selector attributes for E2E

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-11-25 14:00:50 +00:00 committed by GitHub
commit 2cb5b0563b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 2 deletions

View File

@ -112,6 +112,9 @@ afterEach(() => {
...
```
**Test Attributes** -
It should be noted that the `dataCy` prop, as well as its equivalent attribute `data-cy`, are used as flags for any UI test that wants to avoid relying on brittle CSS selectors such as `nth-of-type()`.
## Handling API Errors
API requests can and will fail occasionally so they should include explicit error handling. The three _main_ categories of errors from our perspective are: content loading errors, form submission errors, and other errors. The patterns currently in place for these are described below:

View File

@ -25,17 +25,21 @@ const DetailValue = styled(({ fullWidth, ...props }) => (
`}
`;
const Detail = ({ label, value, fullWidth, className }) => {
const Detail = ({ label, value, fullWidth, className, dataCy }) => {
if (!value && typeof value !== 'number') {
return null;
}
const labelCy = dataCy ? `${dataCy}-label` : null;
const valueCy = dataCy ? `${dataCy}-value` : null;
return (
<>
<DetailName
className={className}
component={TextListItemVariants.dt}
fullWidth={fullWidth}
data-cy={labelCy}
>
{label}
</DetailName>
@ -43,6 +47,7 @@ const Detail = ({ label, value, fullWidth, className }) => {
className={className}
component={TextListItemVariants.dd}
fullWidth={fullWidth}
data-cy={valueCy}
>
{value}
</DetailValue>

View File

@ -95,6 +95,7 @@ class PageHeaderToolbar extends Component {
<Tooltip position="left" content={<div>{i18n._(t`User`)}</div>}>
<ToolbarItem>
<Dropdown
id="toolbar-user-dropdown"
isPlain
isOpen={isUserOpen}
position={DropdownPosition.right}

View File

@ -389,10 +389,12 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
>
<Detail__DetailName
component="dt"
data-cy={null}
fullWidth={false}
>
<StyledComponent
component="dt"
data-cy={null}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
@ -422,14 +424,17 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
<Component
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
component="dt"
data-cy={null}
fullWidth={false}
>
<TextListItem
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
component="dt"
data-cy={null}
>
<dt
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
data-cy={null}
data-pf-content={true}
>
Name
@ -440,10 +445,12 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
</Detail__DetailName>
<Detail__DetailValue
component="dd"
data-cy={null}
fullWidth={false}
>
<StyledComponent
component="dd"
data-cy={null}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
@ -473,14 +480,17 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
<Component
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
component="dd"
data-cy={null}
fullWidth={false}
>
<TextListItem
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
component="dd"
data-cy={null}
>
<dd
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
data-cy={null}
data-pf-content={true}
>
jane brown
@ -563,10 +573,12 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
>
<Detail__DetailName
component="dt"
data-cy={null}
fullWidth={false}
>
<StyledComponent
component="dt"
data-cy={null}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
@ -596,14 +608,17 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
<Component
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
component="dt"
data-cy={null}
fullWidth={false}
>
<TextListItem
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
component="dt"
data-cy={null}
>
<dt
className="Detail__DetailName-sc-16ypsyv-0 erdIBg"
data-cy={null}
data-pf-content={true}
>
Team Roles
@ -614,10 +629,12 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
</Detail__DetailName>
<Detail__DetailValue
component="dd"
data-cy={null}
fullWidth={false}
>
<StyledComponent
component="dd"
data-cy={null}
forwardedComponent={
Object {
"$$typeof": Symbol(react.forward_ref),
@ -647,14 +664,17 @@ exports[`<ResourceAccessListItem /> initially renders succesfully 1`] = `
<Component
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
component="dd"
data-cy={null}
fullWidth={false}
>
<TextListItem
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
component="dd"
data-cy={null}
>
<dd
className="Detail__DetailValue-sc-16ypsyv-1 yHlYM"
data-cy={null}
data-pf-content={true}
>
<ChipGroup

View File

@ -197,7 +197,11 @@ class JobTemplateDetail extends Component {
isInitialized && (
<CardBody css="padding-top: 20px;">
<DetailList gutter="sm">
<Detail label={i18n._(t`Name`)} value={name} />
<Detail
label={i18n._(t`Name`)}
value={name}
dataCy="jt-detail-name"
/>
<Detail label={i18n._(t`Description`)} value={description} />
<Detail label={i18n._(t`Job Type`)} value={job_type} />