1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #6718: add data-cy for tests (#3245)

This commit is contained in:
Jorge Miguel Lobo Escalona 2024-09-25 18:29:46 +02:00 committed by GitHub
parent efa5e62be2
commit 6db0940e2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 110 additions and 32 deletions

View File

@ -116,7 +116,7 @@ MultipleTags.propTypes = {
tags: PropTypes.any,
limitTags: PropTypes.number,
clipboard: PropTypes.bool,
truncateText: PropTypes.bool,
truncateText: PropTypes.number,
}
MultipleTags.displayName = 'MultipleTags'

View File

@ -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} />

View File

@ -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,
@ -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

View File

@ -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(
@ -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'

View File

@ -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()
@ -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

View File

@ -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
@ -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

View File

@ -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,
@ -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'

View File

@ -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':
@ -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,
}

View File

@ -79,6 +79,7 @@ const DataListPerPage = memo(
zoneId,
cannotFilterByLabel,
styles,
rootProps: rootPropsTable,
}) => {
if (!page.length) {
return ''
@ -102,6 +103,7 @@ const DataListPerPage = memo(
{...(messageValues.length && {
globalErrors: messageValues,
})}
rowDataCy={rootPropsTable?.['data-cy'] ?? ''}
className={isSelected ? 'selected' : ''}
{...(!cannotFilterByLabel && {
onClickLabel: (label) => {
@ -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'
@ -509,6 +514,7 @@ const EnhancedTable = ({
{/* DATALIST PER PAGE */}
<DataListPerPage
rootProps={rootProps}
page={page}
prepareRow={prepareRow}
RowComponent={RowComponent}

View File

@ -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 {
@ -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'

View File

@ -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()
@ -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

View File

@ -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
@ -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

View File

@ -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, {
@ -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'

View File

@ -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,
{
@ -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'

View File

@ -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 {
@ -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'

View File

@ -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 =
@ -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'

View File

@ -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),
@ -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'

View File

@ -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
@ -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'

View File

@ -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} />
)
@ -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

View File

@ -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
@ -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

View File

@ -21,7 +21,7 @@ import { NetworkCard } from 'client/components/Cards'
import api, { useUpdateVNetMutation } from 'client/features/OneApi/network'
const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateVNetMutation()
const {
data: vnetworks,
@ -70,6 +70,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VirtualNetworkRow'

View File

@ -23,7 +23,7 @@ import vrouterTemplatesApi, {
import { jsonToXml } from 'client/models/Helper'
const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateTemplateMutation()
const state =
@ -69,6 +69,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VRouterTemplateRow'

View File

@ -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, UNAME, GNAME, VMS, TEMPLATE_ID } = value
@ -66,6 +66,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
export default Row

View File

@ -21,7 +21,7 @@ import vdcApi, { useUpdateVDCMutation } from 'client/features/OneApi/vdc'
import { jsonToXml } from 'client/models/Helper'
const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateVDCMutation()
const state = vdcApi.endpoints.getVDCs.useQueryState(undefined, {
@ -63,6 +63,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VirtualDataCenterRow'

View File

@ -19,7 +19,7 @@ import { memo, useMemo } from 'react'
import { DiskCard } from 'client/components/Cards'
const Row = memo(
({ original, value, headerList, ...props }) => {
({ original, value, headerList, rowDataCy, ...props }) => {
const memoDisk = useMemo(() => original, [original])
return <DiskCard disk={memoDisk} rootProps={props} />
@ -34,6 +34,7 @@ Row.propTypes = {
className: PropTypes.string,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VmDiskRow'

View File

@ -18,7 +18,7 @@ import PropTypes from 'prop-types'
import { VmGroupCard } from 'client/components/Cards'
const Row = ({ original, value, headerList, ...props }) => (
const Row = ({ original, value, headerList, rowDataCy, ...props }) => (
<VmGroupCard rootProps={props} vmgroup={value} />
)
@ -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

View File

@ -23,7 +23,7 @@ import vmTemplateApi, {
import { jsonToXml } from 'client/models/Helper'
const Row = memo(
({ original, value, onClickLabel, headerList, ...props }) => {
({ original, value, onClickLabel, headerList, rowDataCy, ...props }) => {
const [update] = useUpdateTemplateMutation()
const state = vmTemplateApi.endpoints.getTemplates.useQueryState(
@ -68,6 +68,7 @@ Row.propTypes = {
onClick: PropTypes.func,
onClickLabel: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VmTemplateRow'

View File

@ -27,7 +27,15 @@ const { VNC, RDP, SSH, VMRC } = VM_ACTIONS
const CONNECTION_TYPES = [VNC, RDP, SSH, VMRC]
const Row = memo(
({ original, value, onClickLabel, globalErrors, headerList, ...props }) => {
({
original,
value,
onClickLabel,
globalErrors,
headerList,
rowDataCy,
...props
}) => {
// This is for not showing VNC coneections when the user use other zone.
const { zone, defaultZone } = useGeneral()
@ -89,6 +97,7 @@ Row.propTypes = {
onClickLabel: PropTypes.func,
globalErrors: PropTypes.array,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'VirtualMachineRow'

View File

@ -28,7 +28,7 @@ import { Row as RowType } from 'react-table'
* @param {Function} props.handleClick - Action by click
* @returns {ReactElement} - Table row
*/
const Row = memo(({ original, headerList, ...props }) => {
const Row = memo(({ original, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { DEPLOY_ID, VM_NAME } = original
@ -53,6 +53,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'WildsRow'

View File

@ -28,7 +28,7 @@ import { Row as RowType } from 'react-table'
* @param {Function} props.handleClick - Action by click
* @returns {ReactElement} - Table row
*/
const Row = memo(({ original, headerList, ...props }) => {
const Row = memo(({ original, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { DEPLOY_ID, VM_NAME } = original
@ -50,6 +50,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
Row.displayName = 'ZombiesRow'

View File

@ -25,7 +25,7 @@ import { HomeShield } from 'iconoir-react'
import * as ZoneModel from 'client/models/Zone'
const Row = ({ original, value, headerList, ...props }) => {
const Row = ({ original, value, headerList, rowDataCy, ...props }) => {
const classes = rowStyles()
const { ID, NAME, ENDPOINT } = value
@ -58,6 +58,7 @@ Row.propTypes = {
isSelected: PropTypes.bool,
handleClick: PropTypes.func,
headerList: PropTypes.oneOfType([PropTypes.array, PropTypes.bool]),
rowDataCy: PropTypes.string,
}
export default Row