ui feedbacks for 1.5.0 (#17545)

* ui feedbacks for 1.5.0

* fix sonar issue due to cron changes

* minor fix
This commit is contained in:
Ashish Gupta 2024-08-22 15:17:15 +05:30 committed by GitHub
parent cf347adf72
commit 7f7dbef411
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 43 additions and 53 deletions

View File

@ -30,7 +30,7 @@ export interface SelectTestSuiteProps {
export interface TestCaseFormProps {
initialValue?: CreateTestCase;
onSubmit: (data: CreateTestCase) => void;
onSubmit: (data: CreateTestCase) => Promise<void>;
onCancel: (data: CreateTestCase) => void;
table: Table;
}

View File

@ -72,11 +72,12 @@ const ParameterForm: React.FC<ParameterFormProps> = ({ definition, table }) => {
DynamicField?: ReactElement
) => {
const ruleValidation: RuleRender = ({ getFieldValue }) => ({
validator(_, value) {
validator(_, formValue) {
if (data?.validationRule) {
const fieldValue = data.validationRule.parameterField
? getFieldValue(['params', data.validationRule.parameterField])
? +getFieldValue(['params', data.validationRule.parameterField])
: undefined;
const value = +formValue;
if (fieldValue && value) {
switch (data.validationRule.rule) {
case Rule.GreaterThanOrEquals:

View File

@ -46,6 +46,7 @@ import {
getListTestDefinitions,
} from '../../../../rest/testAPI';
import {
filterSelectOptions,
getNameFromFQN,
replaceAllSpacialCharWith_,
} from '../../../../utils/CommonUtils';
@ -88,6 +89,7 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
);
const [testCases, setTestCases] = useState<TestCase[]>([]);
const [currentColumnType, setCurrentColumnType] = useState<string>();
const [loading, setLoading] = useState(false);
const columnName = Form.useWatch('column', form);
@ -196,8 +198,10 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
};
};
const handleFormSubmit: FormProps['onFinish'] = (value) => {
onSubmit(createTestCaseObj(value));
const handleFormSubmit: FormProps['onFinish'] = async (value) => {
setLoading(true);
await onSubmit(createTestCaseObj(value));
setLoading(false);
};
const onBack = () => {
@ -277,6 +281,16 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
});
}, [activeColumnFqn]);
const testTypeOptions = useMemo(
() =>
testDefinitions.map((suite) => ({
label: getEntityName(suite),
value: suite.fullyQualifiedName ?? '',
})),
[testDefinitions]
);
return (
<Form
data-testid="test-case-form"
@ -359,10 +373,8 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
<Select
showSearch
data-testid="test-type"
options={testDefinitions.map((suite) => ({
label: getEntityName(suite),
value: suite.fullyQualifiedName,
}))}
filterOption={filterSelectOptions}
options={testTypeOptions}
placeholder={t('label.select-field', { field: t('label.test-type') })}
onChange={handleTestDefinitionChange}
/>
@ -401,10 +413,14 @@ const TestCaseForm: React.FC<TestCaseFormProps> = ({
<Form.Item noStyle>
<Space className="w-full justify-end" size={16}>
<Button data-testid="cancel-btn" onClick={onBack}>
<Button data-testid="cancel-btn" disabled={loading} onClick={onBack}>
{t('label.back')}
</Button>
<Button data-testid="submit-test" htmlType="submit" type="primary">
<Button
data-testid="submit-test"
htmlType="submit"
loading={loading}
type="primary">
{t('label.submit')}
</Button>
</Space>

View File

@ -142,6 +142,11 @@ const EntityDeleteModal = ({
type="text"
value={name}
onChange={handleOnChange}
onKeyDown={(e) => {
if (e.key === 'Enter' && isNameMatching) {
handleSave();
}
}}
/>
</div>
</Modal>

View File

@ -22,11 +22,6 @@ export const getPeriodOptions = () => {
value: '',
prep: '',
},
{
label: i18n.t('label.minute-plural'),
value: 'minute',
prep: '',
},
{
label: i18n.t('label.hour'),
value: 'hour',

View File

@ -33,9 +33,6 @@ const mockProps: CronEditorProp = {
const getHourDescription = (value: string) =>
`label.schedule-to-run-every hour ${value} past the hour`;
const getMinuteDescription = (value: string) =>
`label.schedule-to-run-every ${value}`;
const getDayDescription = () => 'label.schedule-to-run-every day at 00:00';
const handleScheduleEverySelector = async (text: string) => {
@ -104,40 +101,6 @@ describe('Test CronEditor component', () => {
);
});
it('Minute option should render corresponding component', async () => {
render(<CronEditor disabled={false} onChange={jest.fn} />);
await handleScheduleEverySelector('label.minute-plural');
expect(screen.getByTestId('schedule-description')).toHaveTextContent(
getMinuteDescription('5')
);
expect(
await screen.findByTestId('minute-segment-container')
).toBeInTheDocument();
const minutesOptions = await screen.findByTestId('minute-segment-options');
expect(minutesOptions).toBeInTheDocument();
const minuteSelect = await findByRole(minutesOptions, 'combobox');
act(() => {
userEvent.click(minuteSelect);
});
await waitForElement(() => screen.getByText('15'));
await act(async () => {
fireEvent.click(screen.getByText('15'));
});
expect(await screen.getAllByText('15')).toHaveLength(2);
expect(screen.getByTestId('schedule-description')).toHaveTextContent(
getMinuteDescription('15')
);
});
it('Day option should render corresponding component', async () => {
render(<CronEditor disabled={false} onChange={jest.fn} />);

View File

@ -870,3 +870,13 @@ export const getServiceTypeExploreQueryFilter = (serviceType: string) => {
},
});
};
export const filterSelectOptions = (
input: string,
option?: { label: string; value: string }
) => {
return (
toLower(option?.label).includes(toLower(input)) ||
toLower(option?.value).includes(toLower(input))
);
};