Merge pull request #9606 from nixocio/ui_add_selectors

Improve selectors to ease testing

Improve selectors to ease testing

Reviewed-by: Keith Grant <None>
This commit is contained in:
softwarefactory-project-zuul[bot]
2021-03-17 18:12:22 +00:00
committed by GitHub
7 changed files with 21 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { withI18n } from '@lingui/react'; import { withI18n } from '@lingui/react';
import { t } from '@lingui/macro'; import { t } from '@lingui/macro';
import { Button } from '@patternfly/react-core'; import { Button } from '@patternfly/react-core';
@@ -12,6 +13,7 @@ function DeleteButton({
variant, variant,
children, children,
isDisabled, isDisabled,
ouiaId,
}) { }) {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
@@ -22,6 +24,7 @@ function DeleteButton({
aria-label={i18n._(t`Delete`)} aria-label={i18n._(t`Delete`)}
isDisabled={isDisabled} isDisabled={isDisabled}
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
ouiaId={ouiaId}
> >
{children || i18n._(t`Delete`)} {children || i18n._(t`Delete`)}
</Button> </Button>
@@ -58,4 +61,12 @@ function DeleteButton({
); );
} }
DeleteButton.propTypes = {
ouiaId: PropTypes.string,
};
DeleteButton.defaultProps = {
ouiaId: null,
};
export default withI18n()(DeleteButton); export default withI18n()(DeleteButton);

View File

@@ -10,6 +10,7 @@ const FormActionGroup = ({ onCancel, onSubmit, submitDisabled, i18n }) => {
<FormFullWidthLayout> <FormFullWidthLayout>
<ActionGroup> <ActionGroup>
<Button <Button
ouiaId="Save"
aria-label={i18n._(t`Save`)} aria-label={i18n._(t`Save`)}
variant="primary" variant="primary"
type="button" type="button"
@@ -19,6 +20,7 @@ const FormActionGroup = ({ onCancel, onSubmit, submitDisabled, i18n }) => {
{i18n._(t`Save`)} {i18n._(t`Save`)}
</Button> </Button>
<Button <Button
ouiaId="Cancel"
aria-label={i18n._(t`Cancel`)} aria-label={i18n._(t`Cancel`)}
variant="link" variant="link"
type="button" type="button"

View File

@@ -38,6 +38,7 @@ function PaginatedTable({
i18n, i18n,
renderToolbar, renderToolbar,
emptyContentMessage, emptyContentMessage,
ouiaId,
}) { }) {
const history = useHistory(); const history = useHistory();
@@ -95,7 +96,7 @@ function PaginatedTable({
Content = ( Content = (
<div css="overflow: auto"> <div css="overflow: auto">
{hasContentLoading && <LoadingSpinner />} {hasContentLoading && <LoadingSpinner />}
<TableComposable aria-label={dataListLabel}> <TableComposable aria-label={dataListLabel} ouiaId={ouiaId}>
{headerRow} {headerRow}
<Tbody>{items.map(renderRow)}</Tbody> <Tbody>{items.map(renderRow)}</Tbody>
</TableComposable> </TableComposable>
@@ -181,6 +182,7 @@ PaginatedTable.propTypes = {
renderToolbar: PropTypes.func, renderToolbar: PropTypes.func,
hasContentLoading: PropTypes.bool, hasContentLoading: PropTypes.bool,
contentError: PropTypes.shape(), contentError: PropTypes.shape(),
ouiaId: PropTypes.string,
}; };
PaginatedTable.defaultProps = { PaginatedTable.defaultProps = {
@@ -192,6 +194,7 @@ PaginatedTable.defaultProps = {
pluralizedItemName: 'Items', pluralizedItemName: 'Items',
showPageSizeOptions: true, showPageSizeOptions: true,
renderToolbar: props => <DataListToolbar {...props} />, renderToolbar: props => <DataListToolbar {...props} />,
ouiaId: null,
}; };
export { PaginatedTable as _PaginatedTable }; export { PaginatedTable as _PaginatedTable };

View File

@@ -111,6 +111,7 @@ function ExecutionEnvironmentList({ i18n }) {
<PageSection> <PageSection>
<Card> <Card>
<PaginatedTable <PaginatedTable
ouiaId="execution-environment-table"
contentError={contentError} contentError={contentError}
hasContentLoading={isLoading || deleteLoading} hasContentLoading={isLoading || deleteLoading}
items={executionEnvironments} items={executionEnvironments}

View File

@@ -56,6 +56,7 @@ function ExecutionEnvironmentListItem({
tooltip={i18n._(t`Edit Execution Environment`)} tooltip={i18n._(t`Edit Execution Environment`)}
> >
<Button <Button
ouiaId={`edit-ee-${executionEnvironment.id}`}
aria-label={i18n._(t`Edit Execution Environment`)} aria-label={i18n._(t`Edit Execution Environment`)}
variant="plain" variant="plain"
component={Link} component={Link}

View File

@@ -23,7 +23,7 @@ function OrganizationExecEnvListItem({
<DataListItem <DataListItem
key={executionEnvironment.id} key={executionEnvironment.id}
aria-labelledby={labelId} aria-labelledby={labelId}
id={`${executionEnvironment.id} `} id={`${executionEnvironment.id}`}
> >
<DataListItemRow> <DataListItemRow>
<DataListItemCells <DataListItemCells

View File

@@ -32,7 +32,7 @@ function UserTeamListItem({ team, isSelected, onSelect, i18n }) {
dataListCells={[ dataListCells={[
<DataListCell key="name"> <DataListCell key="name">
<Link to={`/teams/${team.id}/details`} id={`team-${team.id}`}> <Link to={`/teams/${team.id}/details`} id={`team-${team.id}`}>
{team.name} <b>{team.name}</b>
</Link> </Link>
</DataListCell>, </DataListCell>,
<DataListCell key="organization"> <DataListCell key="organization">