Skip to content

Commit f4c5299

Browse files
authored
feat(frontend): add required gates to cli automate page (#2948)
1 parent b3d0cd8 commit f4c5299

File tree

8 files changed

+45
-12
lines changed

8 files changed

+45
-12
lines changed

web/src/components/RunDetailAutomateMethods/methods/CLICommand/CliCommand.styled.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,9 @@ export const SwitchLabel = styled.label<{$disabled?: boolean}>`
4242
export const ControlsContainer = styled.div`
4343
margin-top: 16px;
4444
`;
45-
export const OptionsContainer = styled.div``;
45+
46+
export const OptionsContainer = styled.div`
47+
margin-bottom: 24px;
48+
`;
49+
4650
export const FormatContainer = styled.div``;

web/src/components/RunDetailAutomateMethods/methods/CLICommand/Controls.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import {Form, Radio, Typography} from 'antd';
22
import {toUpper} from 'lodash';
33
import {useEffect, useMemo} from 'react';
4+
import RequiredGatesInput from 'components/Settings/TestRunner/RequiredGatesInput';
5+
import {TooltipQuestion} from 'components/TooltipQuestion/TooltipQuestion';
46
import {CliCommandFormat, CliCommandOption, TCliCommandConfig} from 'services/CliCommand.service';
57
import {ResourceType} from 'types/Resource.type';
68
import * as S from './CliCommand.styled';
@@ -47,6 +49,7 @@ const Controls = ({onChange, id, environmentId, fileName, resourceType}: IProps)
4749
const [form] = Form.useForm<TCliCommandConfig>();
4850
const options = Form.useWatch('options', form);
4951
const format = Form.useWatch('format', form);
52+
const requiredGates = Form.useWatch('required-gates', form);
5053
const optionsMetadata = useMemo(
5154
() => getOptionsMetadata({isEnvironmentSelected: !!environmentId, resourceType}),
5255
[environmentId, resourceType]
@@ -56,12 +59,13 @@ const Controls = ({onChange, id, environmentId, fileName, resourceType}: IProps)
5659
onChange({
5760
options: options ?? defaultOptions,
5861
format: format ?? CliCommandFormat.Pretty,
62+
requiredGates,
5963
id,
6064
environmentId,
6165
fileName,
6266
resourceType,
6367
});
64-
}, [environmentId, fileName, format, onChange, options, id, resourceType]);
68+
}, [environmentId, fileName, format, requiredGates, onChange, options, id, resourceType]);
6569

6670
return (
6771
<Form<TCliCommandConfig>
@@ -82,6 +86,21 @@ const Controls = ({onChange, id, environmentId, fileName, resourceType}: IProps)
8286
</Form.Item>
8387
))}
8488
</S.OptionsContainer>
89+
90+
<Form.Item name="required-gates">
91+
<RequiredGatesInput
92+
title={
93+
<Typography.Paragraph>
94+
Override default Required Gates:{' '}
95+
<TooltipQuestion
96+
margin={6}
97+
title="Required Gates are used by the test runner to evaluate if a test is failed or not. You can override the default Required Gates for this run"
98+
/>
99+
</Typography.Paragraph>
100+
}
101+
/>
102+
</Form.Item>
103+
85104
<S.FormatContainer>
86105
<Typography.Paragraph>Output Format:</Typography.Paragraph>
87106
<Form.Item name="format" noStyle>

web/src/components/RunDetailAutomateMethods/methods/CLICommand/SwitchControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const SwitchControl = ({value = false, onChange = noop, text, id, disabled, help
1818
<S.SwitchLabel htmlFor={id} $disabled={disabled}>
1919
{text}
2020
</S.SwitchLabel>
21-
{!!help && <TooltipQuestion title={help} />}
21+
{!!help && <TooltipQuestion margin={6} title={help} />}
2222
</S.SwitchContainer>
2323
);
2424

web/src/components/Settings/TestRunner/RequiredGatesInput.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ import * as S from '../common/Settings.styled';
99
interface IProps {
1010
value?: string[];
1111
onChange?(value: string[]): void;
12+
title?: React.ReactNode;
1213
}
1314

1415
const supportedGates = Object.values(SupportedRequiredGates);
1516

16-
const RequiredGatesInput = ({value = [], onChange = noop}: IProps) => {
17+
const RequiredGatesInput = ({value = [], onChange = noop, title}: IProps) => {
1718
const handleChange = useCallback(
1819
(gate: SupportedRequiredGates, isChecked: boolean) => {
1920
const newValue = isChecked ? [...value, gate] : value.filter(g => g !== gate);
@@ -24,10 +25,10 @@ const RequiredGatesInput = ({value = [], onChange = noop}: IProps) => {
2425

2526
return (
2627
<>
27-
<Typography.Title level={3}>Required Gates</Typography.Title>
28+
{title || <Typography.Title level={3}>Required Gates</Typography.Title>}
2829
<S.SwitchListContainer>
2930
{supportedGates.map(gate => (
30-
<S.SwitchContainer>
31+
<S.SwitchContainer key={gate}>
3132
<Switch checked={value.includes(gate)} onChange={isChecked => handleChange(gate, isChecked)} id={gate} />
3233
<label htmlFor={gate}>
3334
<Typography.Text>

web/src/models/TestRunner.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export const SupportedRequiredGatesDescription = {
1515
[SupportedRequiredGates.AnalyzerScore]:
1616
'Test Runs will be marked as failed if the Analyzer Score is below the configured threshold',
1717
[SupportedRequiredGates.AnalyzerRules]:
18-
'Test Runs will be marked as failed if one the Error Level Analyzer Rules are not met',
19-
[SupportedRequiredGates.TestSpecs]: 'Test Runs will be marked as failed if on of the defined Test Specs fail',
18+
'Test Runs will be marked as failed if one the Error Level Analyzer Rules fails',
19+
[SupportedRequiredGates.TestSpecs]: 'Test Runs will be marked as failed if one of the defined Test Specs fails',
2020
} as const;
2121

2222
const TestRunner = ({spec: rawTestRunner = {}}: TRawTestRunnerResource = {}): TestRunner =>

web/src/pages/TransactionRunAutomate/TransactionRunAutomate.styled.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import styled from 'styled-components';
33
export const Container = styled.div`
44
background: ${({theme}) => theme.color.white};
55
display: flex;
6-
height: 100%;
6+
flex: auto;
7+
min-height: 0;
78
width: 100%;
89
`;
910

web/src/pages/TransactionRunOverview/TransactionRunOverview.styled.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import styled from 'styled-components';
33
export const Container = styled.div`
44
background: ${({theme}) => theme.color.white};
55
display: flex;
6-
height: 100%;
6+
flex: auto;
7+
min-height: 0;
78
width: 100%;
89
`;
910

web/src/services/CliCommand.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type TCliCommandConfig = {
2323
environmentId?: string;
2424
fileName: string;
2525
format: CliCommandFormat;
26+
requiredGates: string[];
2627
resourceType: ResourceType;
2728
};
2829

@@ -54,13 +55,19 @@ const CliCommandService = () => ({
5455
: 'tracetest'
5556
} ${command}`,
5657
} as Record<CliCommandOption, TApplyOption>,
57-
getCommand({options, format, id, environmentId, fileName, resourceType}: TCliCommandConfig) {
58-
const command = Object.entries(options).reduce(
58+
59+
applyRequiredGates: (command: string, requiredGates: string[]) =>
60+
requiredGates?.length ? `${command} --required-gates ${requiredGates.join(',')}` : command,
61+
62+
getCommand({options, format, id, environmentId, fileName, requiredGates, resourceType}: TCliCommandConfig) {
63+
let command = Object.entries(options).reduce(
5964
(acc, [option, enabled]) =>
6065
this.applyOptions[option as CliCommandOption]({command: acc, enabled, id, environmentId, fileName}),
6166
`run ${resourceType}`
6267
);
6368

69+
command = this.applyRequiredGates(command, requiredGates);
70+
6471
return `${command} --output ${format}`;
6572
},
6673
});

0 commit comments

Comments
 (0)