Adding data-cy for E2E and fixing Edit Scheduile View YAML (#2977)

Signed-off-by: Sayan Mondal <sayan@chaosnative.com>
This commit is contained in:
Sayan Mondal 2021-07-08 12:23:35 +05:30 committed by GitHub
parent f03647b772
commit cae6574234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 213 additions and 125 deletions

View File

@ -493,6 +493,7 @@ const ScheduleWorkflow = () => {
<div className={classes.innerRecurring}> <div className={classes.innerRecurring}>
<FormControl component="fieldset"> <FormControl component="fieldset">
<RadioGroup <RadioGroup
data-cy="RecurringSchedule"
aria-label="instanceDef" aria-label="instanceDef"
name="instanceDef" name="instanceDef"
value={valueDef} value={valueDef}
@ -750,6 +751,7 @@ const ScheduleWorkflow = () => {
Cancel Cancel
</ButtonOutlined> </ButtonOutlined>
<ButtonFilled <ButtonFilled
data-cy="VerifyButton"
onClick={() => onClick={() =>
history.push({ history.push({
pathname: `/workflows/schedule/${getProjectID()}/${fetchWorkflowNameFromManifest( pathname: `/workflows/schedule/${getProjectID()}/${fetchWorkflowNameFromManifest(

View File

@ -67,6 +67,7 @@ const EditSchedule: React.FC = () => {
}, },
]); ]);
const [yamlOpen, setYAMLOpen] = React.useState(false);
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const [finishModalOpen, setFinishModalOpen] = useState(false); const [finishModalOpen, setFinishModalOpen] = useState(false);
const [errorModal, setErrorModal] = useState(false); const [errorModal, setErrorModal] = useState(false);
@ -204,7 +205,7 @@ const EditSchedule: React.FC = () => {
const handleEditOpen = () => { const handleEditOpen = () => {
setModified(false); setModified(false);
setOpen(true); setYAMLOpen(true);
}; };
const handleEditClose = () => { const handleEditClose = () => {
@ -253,6 +254,35 @@ const EditSchedule: React.FC = () => {
</Typography> </Typography>
<div className={classes.root}> <div className={classes.root}>
<div className={classes.innerContainer}> <div className={classes.innerContainer}>
{yamlOpen ? (
<div className={classes.editorWrapper}>
<div className={`${classes.flex} ${classes.additional}`}>
<div className={classes.flex}>
<img
style={{ width: '2rem' }}
src="/icons/terminal.svg"
alt="Terminal Icon"
/>
<Typography className={classes.name}>
{fetchWorkflowNameFromManifest(manifest)}.yaml
</Typography>
</div>
<ButtonOutlined
onClick={() => setYAMLOpen(false)}
className={classes.editorCloseBtn}
>
x
</ButtonOutlined>
</div>
<YamlEditor
content={manifest}
filename={workflow.name}
readOnly
/>
</div>
) : (
<>
<Typography className={classes.sumText}> <Typography className={classes.sumText}>
{t('createWorkflow.verifyCommit.summary.header')} {t('createWorkflow.verifyCommit.summary.header')}
</Typography> </Typography>
@ -261,7 +291,10 @@ const EditSchedule: React.FC = () => {
<div className={classes.summaryDiv}> <div className={classes.summaryDiv}>
<div className={classes.innerSumDiv}> <div className={classes.innerSumDiv}>
<Typography className={classes.col1}> <Typography className={classes.col1}>
{t('createWorkflow.verifyCommit.summary.workflowName')}: {t(
'createWorkflow.verifyCommit.summary.workflowName'
)}
:
</Typography> </Typography>
</div> </div>
<div className={classes.col2} data-cy="WorkflowName"> <div className={classes.col2} data-cy="WorkflowName">
@ -274,7 +307,8 @@ const EditSchedule: React.FC = () => {
<div className={classes.summaryDiv}> <div className={classes.summaryDiv}>
<div className={classes.innerSumDiv}> <div className={classes.innerSumDiv}>
<Typography className={classes.col1}> <Typography className={classes.col1}>
{t('createWorkflow.verifyCommit.summary.clustername')}: {t('createWorkflow.verifyCommit.summary.clustername')}
:
</Typography> </Typography>
</div> </div>
<Typography className={classes.schCol2}> <Typography className={classes.schCol2}>
@ -301,10 +335,14 @@ const EditSchedule: React.FC = () => {
<div className={classes.schCol2}> <div className={classes.schCol2}>
{cronSyntax === '' ? ( {cronSyntax === '' ? (
<Typography> <Typography>
{t('createWorkflow.verifyCommit.summary.schedulingNow')} {t(
'createWorkflow.verifyCommit.summary.schedulingNow'
)}
</Typography> </Typography>
) : ( ) : (
<Typography>{cronstrue.toString(cronSyntax)}</Typography> <Typography>
{cronstrue.toString(cronSyntax)}
</Typography>
)} )}
<ButtonOutlined <ButtonOutlined
@ -318,7 +356,10 @@ const EditSchedule: React.FC = () => {
}) })
} }
> >
<EditIcon className={classes.editIcon} data-cy="edit" /> <EditIcon
className={classes.editIcon}
data-cy="edit"
/>
{t('editSchedule.edit')} {t('editSchedule.edit')}
</ButtonOutlined> </ButtonOutlined>
</div> </div>
@ -326,7 +367,9 @@ const EditSchedule: React.FC = () => {
<div className={classes.summaryDiv}> <div className={classes.summaryDiv}>
<div className={classes.innerSumDiv}> <div className={classes.innerSumDiv}>
<Typography className={classes.col1}> <Typography className={classes.col1}>
{t('createWorkflow.verifyCommit.summary.adjustedWeights')} {t(
'createWorkflow.verifyCommit.summary.adjustedWeights'
)}
: :
</Typography> </Typography>
</div> </div>
@ -383,6 +426,8 @@ const EditSchedule: React.FC = () => {
</div> </div>
</div> </div>
</div> </div>
</>
)}
</div> </div>
</div> </div>
{/* Cancel and Save Button */} {/* Cancel and Save Button */}
@ -397,7 +442,10 @@ const EditSchedule: React.FC = () => {
> >
{t('editSchedule.cancel')} {t('editSchedule.cancel')}
</ButtonOutlined> </ButtonOutlined>
<ButtonFilled onClick={() => handleNext()}> <ButtonFilled
data-cy="SaveEditScheduleButton"
onClick={() => handleNext()}
>
{t('editSchedule.save')} {t('editSchedule.save')}
</ButtonFilled> </ButtonFilled>
</div> </div>

View File

@ -227,4 +227,33 @@ export const useStyles = makeStyles((theme: Theme) => ({
fontWeight: 'bold', fontWeight: 'bold',
margin: theme.spacing(2, 0), margin: theme.spacing(2, 0),
}, },
// Editor
editorWrapper: {
marginBottom: theme.spacing(-4),
},
flex: {
display: 'flex',
},
additional: {
width: '95%',
margin: '0rem auto',
justifyContent: 'space-between',
},
name: {
margin: theme.spacing(1, 0, 2, 2),
fontWeight: 'bold',
},
editorTopBtn: {
padding: '0.4rem',
fontSize: '0.8rem',
},
editorCloseBtn: {
width: '0.5rem',
borderColor: theme.palette.disabledBackground,
color: theme.palette.text.disabled,
minWidth: '2rem',
padding: '0.2rem',
fontSize: '1rem',
},
})); }));

View File

@ -204,7 +204,10 @@ const WorkflowDetails: React.FC = () => {
</Tabs> </Tabs>
</AppBar> </AppBar>
<TabPanel value={workflowDetailsTabValue} index={0}> <TabPanel value={workflowDetailsTabValue} index={0}>
<div className={classes.graphView}> <div
className={classes.graphView}
data-cy="dagreGraphWorkflowLevel"
>
{/* Argo Workflow DAG Graph */} {/* Argo Workflow DAG Graph */}
<ArgoWorkflow <ArgoWorkflow
nodes={ nodes={

View File

@ -471,6 +471,7 @@ const ScheduleWorkflow = forwardRef((_, ref) => {
<div className={classes.innerRecurring}> <div className={classes.innerRecurring}>
<FormControl component="fieldset"> <FormControl component="fieldset">
<RadioGroup <RadioGroup
data-cy="RecurringSchedule"
aria-label="instanceDef" aria-label="instanceDef"
name="instanceDef" name="instanceDef"
value={valueDef} value={valueDef}

View File

@ -795,6 +795,7 @@ const TuneWorkflow = forwardRef((_, ref) => {
{/* Edit Button */} {/* Edit Button */}
{manifest !== '' && ( {manifest !== '' && (
<ButtonOutlined <ButtonOutlined
data-cy="EditSequenceButton"
disabled={isVisualizationComplete} disabled={isVisualizationComplete}
onClick={() => setEditSequence(true)} onClick={() => setEditSequence(true)}
> >

View File

@ -82,7 +82,6 @@ const useStyles = makeStyles((theme) => ({
// Table // Table
table: { table: {
minWidth: '40rem',
minHeight: '23rem', minHeight: '23rem',
}, },
revertChaos: { revertChaos: {

View File

@ -159,7 +159,7 @@ const LogsSwitcher: React.FC<LogsSwitcherProps> = ({
try { try {
const podLogs = JSON.parse(logs); const podLogs = JSON.parse(logs);
return ( return (
<div> <div data-cy="LogsWindow">
<div> <div>
{workflow !== undefined && {workflow !== undefined &&
JSON.parse(workflow?.execution_data).nodes[pod_name].type === JSON.parse(workflow?.execution_data).nodes[pod_name].type ===
@ -245,7 +245,12 @@ const LogsSwitcher: React.FC<LogsSwitcherProps> = ({
<TabPanel value={selectedTab} index={1} style={{ height: '100%' }}> <TabPanel value={selectedTab} index={1} style={{ height: '100%' }}>
<div className={classes.logs}> <div className={classes.logs}>
<div style={{ whiteSpace: 'pre-wrap' }}> <div style={{ whiteSpace: 'pre-wrap' }}>
<Typography className={classes.text}>{chaosResult}</Typography> <Typography
data-cy="ChaosResultTypography"
className={classes.text}
>
{chaosResult}
</Typography>
</div> </div>
</div> </div>
</TabPanel> </TabPanel>