Skip to content

Commit

Permalink
F #6718: Add data-cy for tests (#3246)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloboescalona2 authored Sep 25, 2024
1 parent 1fcb2ba commit 3c94ba9
Show file tree
Hide file tree
Showing 31 changed files with 110 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/fireedge/src/client/components/MultipleTags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ MultipleTags.propTypes = {
tags: PropTypes.any,
limitTags: PropTypes.number,
clipboard: PropTypes.bool,
truncateText: PropTypes.bool,
truncateText: PropTypes.number,
}
MultipleTags.displayName = 'MultipleTags'

Expand Down
2 changes: 1 addition & 1 deletion src/fireedge/src/client/components/Tables/ACLs/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ACL_TABLE_VIEWS } from 'client/constants'
import PropTypes from 'prop-types'

const Row = (viewType) => {
const aclRow = ({ original, value, headerList, ...props }) => {
const aclRow = ({ original, value, headerList, rowDataCy, ...props }) => {
// Check what view show in the table cards
if (viewType === ACL_TABLE_VIEWS.NAMES.type) {
return <ACLCardNames rootProps={props} acl={value} />
Expand Down
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/AllImages/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { T } from 'client/constants'
import * as Helper from 'client/models/Helper'
import * as ImageModel from 'client/models/Image'

const Row = ({ original, value, headerList, ...props }) => {
const Row = ({ original, value, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const {
ID,
Expand Down Expand Up @@ -127,6 +127,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/BackupJobs/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import backupjobApi, {
import { jsonToXml } from 'client/models/Helper'

const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateBackupJobMutation()

const state = backupjobApi.endpoints.getBackupJobs.useQueryState(
Expand Down Expand Up @@ -68,6 +68,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'VirtualDataCenterRow'
Expand Down
10 changes: 9 additions & 1 deletion src/fireedge/src/client/components/Tables/Backups/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ import { T } from 'client/constants'
import * as Helper from 'client/models/Helper'
import * as ImageModel from 'client/models/Image'

const Row = ({ original, value, onClickLabel, headerList, ...props }) => {
const Row = ({
original,
value,
onClickLabel,
headerList,
rowDataCy,
...props
}) => {
const [update] = useUpdateImageMutation()
const { labels: userLabels } = useAuth()

Expand Down Expand Up @@ -188,6 +195,7 @@ Row.propTypes = {
handleClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/Clusters/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { rowStyles } from 'client/components/Tables/styles'
import { Tr } from 'client/components/HOC'
import { T } from 'client/constants'

const Row = ({ original, value, headerList, ...props }) => {
const Row = ({ original, value, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { ID, NAME, HOSTS, DATASTORES, VNETS, PROVIDER_NAME } = value

Expand Down Expand Up @@ -77,6 +77,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
11 changes: 10 additions & 1 deletion src/fireedge/src/client/components/Tables/Datastores/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ import api, {
} from 'client/features/OneApi/datastore'

const Row = memo(
({ original, value, onClickLabel, zone, headerList, ...props }) => {
({
original,
value,
onClickLabel,
zone,
headerList,
rowDataCy,
...props
}) => {
const [update] = useUpdateDatastoreMutation()
const {
data: datastores,
Expand Down Expand Up @@ -73,6 +81,7 @@ Row.propTypes = {
onClickLabel: PropTypes.func,
zone: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'DatastoreRow'
Expand Down
13 changes: 10 additions & 3 deletions src/fireedge/src/client/components/Tables/Enhanced/WrapperRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ const listStyles = makeStyles(({ palette }) => ({
*/
const RowStyle = memo(
({
original,
value,
original = {},
value = {},
onClickLabel,
onDeleteLabel,
globalErrors,
headerList = [],
className,
rowDataCy = '',
...props
}) => {
const { ID = '' } = original
const styles = listStyles()

return (
<TableRow {...props} className={`${styles.row} ${className}`}>
<TableRow
data-cy={`list-${rowDataCy}-${ID}`}
{...props}
className={`${styles.row} ${className}`}
>
{headerList.map(({ id, accessor }) => {
switch (typeof accessor) {
case 'string':
Expand All @@ -71,6 +77,7 @@ RowStyle.propTypes = {
onDeleteLabel: PropTypes.func,
globalErrors: PropTypes.array,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
className: PropTypes.string,
}

Expand Down
6 changes: 6 additions & 0 deletions src/fireedge/src/client/components/Tables/Enhanced/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const DataListPerPage = memo(
zoneId,
cannotFilterByLabel,
styles,
rootProps: rootPropsTable,
}) => {
if (!page.length) {
return ''
Expand All @@ -102,6 +103,7 @@ const DataListPerPage = memo(
{...(messageValues.length && {
globalErrors: messageValues,
})}
rowDataCy={rootPropsTable?.['data-cy'] ?? ''}
className={isSelected ? 'selected' : ''}
{...(!cannotFilterByLabel && {
onClickLabel: (label) => {
Expand Down Expand Up @@ -165,6 +167,9 @@ DataListPerPage.propTypes = {
zoneId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
cannotFilterByLabel: PropTypes.any,
styles: PropTypes.any,
rootProps: PropTypes.shape({
'data-cy': PropTypes.string,
}),
}

DataListPerPage.displayName = 'DataListPerPage'
Expand Down Expand Up @@ -509,6 +514,7 @@ const EnhancedTable = ({

{/* DATALIST PER PAGE */}
<DataListPerPage
rootProps={rootProps}
page={page}
prepareRow={prepareRow}
RowComponent={RowComponent}
Expand Down
11 changes: 10 additions & 1 deletion src/fireedge/src/client/components/Tables/Hosts/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ import PropTypes from 'prop-types'
import { memo, useCallback, useMemo } from 'react'

const Row = memo(
({ original, value, onClickLabel, zone, headerList, ...props }) => {
({
original,
value,
onClickLabel,
zone,
headerList,
rowDataCy,
...props
}) => {
const [update] = useUpdateHostMutation()

const {
Expand Down Expand Up @@ -72,6 +80,7 @@ Row.propTypes = {
onClickLabel: PropTypes.func,
zone: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'HostRow'
Expand Down
10 changes: 9 additions & 1 deletion src/fireedge/src/client/components/Tables/Images/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ import { prettyBytes } from 'client/utils'
import * as Helper from 'client/models/Helper'
import * as ImageModel from 'client/models/Image'

const Row = ({ original, value, onClickLabel, headerList, ...props }) => {
const Row = ({
original,
value,
onClickLabel,
headerList,
rowDataCy,
...props
}) => {
const [update] = useUpdateImageMutation()
const { labels: userLabels } = useAuth()

Expand Down Expand Up @@ -168,6 +175,7 @@ Row.propTypes = {
handleClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/Increments/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { prettyBytes } from 'client/utils'

import * as Helper from 'client/models/Helper'

const Row = ({ original, value, headerList, ...props }) => {
const Row = ({ original, value, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { ID, TYPE, DATE, SIZE, SOURCE } = value

Expand Down Expand Up @@ -79,6 +79,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import api, {
import { jsonToXml } from 'client/models/Helper'

const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateAppMutation()

const state = api.endpoints.getMarketplaceApps.useQueryState(undefined, {
Expand Down Expand Up @@ -65,6 +65,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'MarketplaceAppRow'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { MarketplaceCard } from 'client/components/Cards'
import marketplaceApi from 'client/features/OneApi/marketplace'

const Row = memo(
({ original, value, headerList, ...props }) => {
({ original, value, headerList, rowDataCy, ...props }) => {
const state = marketplaceApi.endpoints.getMarketplaces.useQueryState(
undefined,
{
Expand All @@ -43,6 +43,7 @@ Row.propTypes = {
className: PropTypes.string,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'MarketplaceRow'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import PropTypes from 'prop-types'
import { memo, useCallback, useMemo } from 'react'

const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateSecGroupMutation()

const {
Expand Down Expand Up @@ -75,6 +75,7 @@ Row.propTypes = {
handleClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'SecurityGroupRow'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import serviceTemplateApi, {
} from 'client/features/OneApi/serviceTemplate'

const Row = memo(
({ original, value, headerList, ...props }) => {
({ original, value, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateServiceTemplateMutation()

const state =
Expand Down Expand Up @@ -64,6 +64,7 @@ Row.propTypes = {
className: PropTypes.string,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'ServiceTemplateRow'
Expand Down
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/Services/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ServiceCard } from 'client/components/Cards'
import serviceApi from 'client/features/OneApi/service'

const Row = memo(
({ original, value, headerList, ...props }) => {
({ original, value, headerList, rowDataCy, ...props }) => {
const state = serviceApi.endpoints.getServices.useQueryState(undefined, {
selectFromResult: ({ data = [] }) =>
data.find((service) => +service.ID === +original.ID),
Expand All @@ -40,6 +40,7 @@ Row.propTypes = {
className: PropTypes.string,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'ServiceRow'
Expand Down
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/Support/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { memo } from 'react'
import { SupportCard } from 'client/components/Cards'

const Row = memo(
({ original, value, headerList, ...props }) => (
({ original, value, headerList, rowDataCy, ...props }) => (
<SupportCard ticket={original} rootProps={props} />
),
(prev, next) => prev.className === next.className
Expand All @@ -32,6 +32,7 @@ Row.propTypes = {
className: PropTypes.string,
onClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

Row.displayName = 'SupportRow'
Expand Down
3 changes: 2 additions & 1 deletion src/fireedge/src/client/components/Tables/Users/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import PropTypes from 'prop-types'

import { UserCard } from 'client/components/Cards'

const Row = ({ original, value, headerList, ...props }) => (
const Row = ({ original, value, headerList, rowDataCy, ...props }) => (
<UserCard rootProps={props} user={value} />
)

Expand All @@ -28,6 +28,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { T } from 'client/constants'

import * as Helper from 'client/models/Helper'

const Row = ({ original, value, headerList, ...props }) => {
const Row = ({ original, value, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { ID, NAME, UNAME, GNAME, LOCK, REGTIME, PROVISION_ID } = value

Expand Down Expand Up @@ -69,6 +69,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}

export default Row
Loading

0 comments on commit 3c94ba9

Please sign in to comment.