fix: Make column name a selection box only for tableRowInsertedCountToBeBetween test (#10527)

This commit is contained in:
Shailesh Parmar 2023-03-11 20:23:34 +05:30 committed by GitHub
parent 0a2f7ec599
commit 203d41c88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 2 deletions

View File

@ -14,6 +14,7 @@
import { act, render, screen } from '@testing-library/react'; import { act, render, screen } from '@testing-library/react';
import { TestDefinition } from 'generated/tests/testDefinition'; import { TestDefinition } from 'generated/tests/testDefinition';
import { import {
MOCK_TABLE_COLUMN_NAME_TO_EXIST,
MOCK_TABLE_ROW_INSERTED_COUNT_TO_BE_BETWEEN, MOCK_TABLE_ROW_INSERTED_COUNT_TO_BE_BETWEEN,
MOCK_TABLE_WITH_DATE_TIME_COLUMNS, MOCK_TABLE_WITH_DATE_TIME_COLUMNS,
} from 'mocks/TestSuite.mock'; } from 'mocks/TestSuite.mock';
@ -32,7 +33,7 @@ describe('ParameterForm component test', () => {
/> />
); );
}); });
// test definition should be "tableRowInsertedCountToBeBetween"
const selectBox = await screen.findByRole('combobox'); const selectBox = await screen.findByRole('combobox');
const parameters = await screen.findAllByTestId('parameter'); const parameters = await screen.findAllByTestId('parameter');
@ -61,4 +62,23 @@ describe('ParameterForm component test', () => {
MOCK_TABLE_ROW_INSERTED_COUNT_TO_BE_BETWEEN.parameterDefinition.length MOCK_TABLE_ROW_INSERTED_COUNT_TO_BE_BETWEEN.parameterDefinition.length
); );
}); });
it('Select box should not render if "columnName" field is present but test definition is not "tableRowInsertedCountToBeBetween"', async () => {
await act(async () => {
render(
<ParameterForm
definition={MOCK_TABLE_COLUMN_NAME_TO_EXIST as TestDefinition}
table={MOCK_TABLE_WITH_DATE_TIME_COLUMNS}
/>
);
});
const selectBox = screen.queryByRole('combobox');
const parameters = await screen.findAllByTestId('parameter');
expect(selectBox).not.toBeInTheDocument();
expect(parameters).toHaveLength(
MOCK_TABLE_COLUMN_NAME_TO_EXIST.parameterDefinition.length
);
});
}); });

View File

@ -39,7 +39,11 @@ const ParameterForm: React.FC<ParameterFormProps> = ({ definition, table }) => {
); );
switch (data.dataType) { switch (data.dataType) {
case TestDataType.String: case TestDataType.String:
if (data.name === 'columnName' && !isUndefined(table)) { if (
!isUndefined(table) &&
definition.name === 'tableRowInsertedCountToBeBetween' &&
data.name === 'columnName'
) {
const partitionColumnOptions = table.columns.reduce( const partitionColumnOptions = table.columns.reduce(
(result, column) => { (result, column) => {
if (SUPPORTED_PARTITION_TYPE.includes(column.dataType)) { if (SUPPORTED_PARTITION_TYPE.includes(column.dataType)) {

View File

@ -738,3 +738,29 @@ export const MOCK_TABLE_ROW_INSERTED_COUNT_TO_BE_BETWEEN = {
href: 'http://sandbox-beta.open-metadata.org/api/v1/testDefinition/756c7770-0af3-49a9-9905-75a2886e5eec', href: 'http://sandbox-beta.open-metadata.org/api/v1/testDefinition/756c7770-0af3-49a9-9905-75a2886e5eec',
deleted: false, deleted: false,
}; };
export const MOCK_TABLE_COLUMN_NAME_TO_EXIST = {
id: '6d4e4673-fd7f-4b37-811e-7645c3c17e93',
name: 'tableColumnNameToExist',
displayName: 'Table Column Name To Exist',
fullyQualifiedName: 'tableColumnNameToExist',
description:
'This test defines the test TableColumnNameToExist. Test the table columns exists in the table.',
entityType: 'TABLE',
testPlatforms: ['OpenMetadata'],
supportedDataTypes: [],
parameterDefinition: [
{
name: 'columnName',
displayName: 'Column Name',
dataType: 'STRING',
description: 'Expected column of the table to exist',
required: true,
},
],
version: 0.1,
updatedAt: 1672236872076,
updatedBy: 'admin',
href: 'http://sandbox-beta.open-metadata.org/api/v1/testDefinition/6d4e4673-fd7f-4b37-811e-7645c3c17e93',
deleted: false,
};