Skip to content

Commit

Permalink
F #5888: add data-cy (#2249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloboescalona2 authored and rsmontero committed Jul 27, 2022
1 parent 2e7a52d commit 246e426
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,7 @@ FIREEDGE_SUNSTONE_ETC_VIEW_ADMIN="src/fireedge/etc/sunstone/admin/vm-tab.yaml \
src/fireedge/etc/sunstone/admin/vm-template-tab.yaml \
src/fireedge/etc/sunstone/admin/marketplace-app-tab.yaml \
src/fireedge/etc/sunstone/admin/vnet-tab.yaml \
src/fireedge/etc/sunstone/admin/image-tab.yaml\
src/fireedge/etc/sunstone/admin/host-tab.yaml"

FIREEDGE_SUNSTONE_ETC_VIEW_USER="src/fireedge/etc/sunstone/user/vm-tab.yaml \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const ImageCreateCard = memo(
const classes = useStyles()

return (
<Grid item xs={12} md={6} onClick={onClick}>
<Grid item xs={12} md={6} onClick={onClick} data-cy="create">
<Paper variant="outlined" className={classes.root}>
{Icon && (
<Box className={classes.figure}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import { T } from 'client/constants'

export const STEP_ID = 'advanced'

const Content = () => <FormWithSchema id={STEP_ID} fields={FIELDS} />
const Content = () => (
<FormWithSchema id={STEP_ID} fields={FIELDS} cy={`${STEP_ID}`} />
)

/**
* Advanced options create image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import { T } from 'client/constants'

export const STEP_ID = 'general'

const Content = () => <FormWithSchema id={STEP_ID} fields={FIELDS} />
const Content = () => (
<FormWithSchema id={STEP_ID} fields={FIELDS} cy={`${STEP_ID}`} />
)

/**
* General configuration about VM Template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default [
{ Header: 'Name', accessor: 'NAME' },
{ Header: 'Owner', accessor: 'UNAME' },
{ Header: 'Group', accessor: 'GNAME' },
{ Header: 'Locked', id: 'locked', accessor: 'LOCK' },
{
Header: 'State',
id: 'STATE',
Expand Down
4 changes: 2 additions & 2 deletions src/fireedge/src/client/components/Tables/Images/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Row = ({ original, value, ...props }) => {
TYPE,
DISK_TYPE,
PERSISTENT,
LOCK,
locked,
DATASTORE,
TOTAL_VMS,
RUNNING_VMS,
Expand All @@ -59,7 +59,7 @@ const Row = ({ original, value, ...props }) => {
<Typography noWrap component="span" data-cy="name">
{NAME}
</Typography>
{LOCK && <Lock />}
{locked && <Lock />}
<span className={classes.labels}>
{labels.map((label) => (
<StatusChip key={label} text={label} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import { StatusChip } from 'client/components/Status'
import { List } from 'client/components/Tabs/Common'

import { getType, getState } from 'client/models/Image'
import { timeToString, booleanToString } from 'client/models/Helper'
import {
timeToString,
booleanToString,
levelLockToString,
} from 'client/models/Helper'
import { arrayToOptions, prettyBytes } from 'client/utils'
import { T, Image, IMAGE_ACTIONS, IMAGE_TYPES } from 'client/constants'
import { PATH } from 'client/apps/sunstone/routesOne'
Expand All @@ -49,6 +53,7 @@ const InformationPanel = ({ image = {}, actions }) => {
NAME,
SIZE,
PERSISTENT,
LOCK,
REGTIME,
DATASTORE_ID,
DATASTORE = '--',
Expand Down Expand Up @@ -110,6 +115,11 @@ const InformationPanel = ({ image = {}, actions }) => {
handleEdit: handleChangeType,
dataCy: 'type',
},
{
name: T.Locked,
value: levelLockToString(LOCK?.LOCKED),
dataCy: 'locked',
},
{
name: T.Persistent,
value: booleanToString(+PERSISTENT),
Expand All @@ -127,6 +137,7 @@ const InformationPanel = ({ image = {}, actions }) => {
{
name: T.State,
value: <StatusChip text={stateName} stateColor={stateColor} />,
dataCy: 'state',
},
{
name: T.RunningVMs,
Expand Down
15 changes: 14 additions & 1 deletion src/fireedge/src/client/features/OneApi/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Permission,
IMAGE_TYPES_STR,
} from 'client/constants'
import { getType } from 'client/models/Image'

const { IMAGE } = ONE_RESOURCES
const { IMAGE_POOL } = ONE_RESOURCES_POOL
Expand All @@ -50,7 +51,19 @@ const imageApi = oneApi.injectEndpoints({

return { params, command }
},
transformResponse: (data) => [data?.IMAGE_POOL?.IMAGE ?? []].flat(),
transformResponse: (data) => {
const images = data?.IMAGE_POOL?.IMAGE?.filter?.((image) => {
const type = getType(image)

return (
type === IMAGE_TYPES_STR.OS ||
type === IMAGE_TYPES_STR.CDROM ||
type === IMAGE_TYPES_STR.DATABLOCK
)
})

return [images ?? []].flat()
},
providesTags: (images) =>
images
? [
Expand Down

0 comments on commit 246e426

Please sign in to comment.