mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 17:34:41 +00:00
Minor: fixed profiler setting is not persist for sample data count (#14350)
This commit is contained in:
parent
b3ac8de405
commit
d3ebe6fb4b
@ -818,4 +818,128 @@ describe('Data Quality and Profiler should work properly', () => {
|
|||||||
expect(text).to.eq('Table test case display name');
|
expect(text).to.eq('Table test case display name');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Update profiler setting modal', () => {
|
||||||
|
const profilerSetting = {
|
||||||
|
profileSample: 60,
|
||||||
|
sampleDataCount: 100,
|
||||||
|
profileQuery: 'select * from table',
|
||||||
|
excludeColumns: 'user_id',
|
||||||
|
includeColumns: 'shop_id',
|
||||||
|
partitionColumnName: 'name',
|
||||||
|
partitionIntervalType: 'COLUMN-VALUE',
|
||||||
|
partitionValues: 'test',
|
||||||
|
};
|
||||||
|
interceptURL('GET', '/api/v1/tables/*/tableProfile?*', 'tableProfiler');
|
||||||
|
interceptURL('GET', '/api/v1/tables/*/systemProfile?*', 'systemProfiler');
|
||||||
|
interceptURL(
|
||||||
|
'GET',
|
||||||
|
'/api/v1/tables/*/tableProfilerConfig*',
|
||||||
|
'tableProfilerConfig'
|
||||||
|
);
|
||||||
|
visitEntityDetailsPage({
|
||||||
|
term: DATABASE_SERVICE.entity.name,
|
||||||
|
serviceName: DATABASE_SERVICE.service.name,
|
||||||
|
entity: DATA_ASSETS.tables,
|
||||||
|
});
|
||||||
|
cy.get('[data-testid="profiler"]').should('be.visible').click();
|
||||||
|
verifyResponseStatusCode('@tableProfiler', 200);
|
||||||
|
verifyResponseStatusCode('@systemProfiler', 200);
|
||||||
|
cy.get('[data-testid="profiler-setting-btn"]').click();
|
||||||
|
verifyResponseStatusCode('@tableProfilerConfig', 200);
|
||||||
|
cy.get('.ant-modal-body').should('be.visible');
|
||||||
|
cy.get('[data-testid="slider-input"]')
|
||||||
|
.clear()
|
||||||
|
.type(profilerSetting.profileSample);
|
||||||
|
cy.get('[data-testid="sample-data-count-input"]')
|
||||||
|
.clear()
|
||||||
|
.type(profilerSetting.sampleDataCount);
|
||||||
|
cy.get('[data-testid="exclude-column-select"]')
|
||||||
|
.scrollIntoView()
|
||||||
|
.type(`${profilerSetting.excludeColumns}{enter}`);
|
||||||
|
cy.clickOutside();
|
||||||
|
cy.get('.CodeMirror-scroll')
|
||||||
|
.scrollIntoView()
|
||||||
|
.click()
|
||||||
|
.type(profilerSetting.profileQuery);
|
||||||
|
|
||||||
|
cy.get('[data-testid="include-column-select"]').scrollIntoView().click();
|
||||||
|
cy.get('.ant-select-dropdown')
|
||||||
|
.not('.ant-select-dropdown-hidden')
|
||||||
|
.find(`[title="${profilerSetting.includeColumns}"]`)
|
||||||
|
.click();
|
||||||
|
cy.get('[data-testid="enable-partition-switch"]').scrollIntoView().click();
|
||||||
|
cy.get('[data-testid="interval-type"]').scrollIntoView().click();
|
||||||
|
cy.get('.ant-select-dropdown')
|
||||||
|
.not('.ant-select-dropdown-hidden')
|
||||||
|
.find(`[title="${profilerSetting.partitionIntervalType}"]`)
|
||||||
|
.click();
|
||||||
|
cy.get('[data-testid="column-name"]').click();
|
||||||
|
cy.get('.ant-select-dropdown')
|
||||||
|
.not('.ant-select-dropdown-hidden')
|
||||||
|
.find(`[title="${profilerSetting.partitionColumnName}"]`)
|
||||||
|
.click();
|
||||||
|
cy.get('[data-testid="partition-value"]')
|
||||||
|
.scrollIntoView()
|
||||||
|
.type(profilerSetting.partitionValues);
|
||||||
|
|
||||||
|
interceptURL(
|
||||||
|
'PUT',
|
||||||
|
'/api/v1/tables/*/tableProfilerConfig',
|
||||||
|
'updateTableProfilerConfig'
|
||||||
|
);
|
||||||
|
cy.get('.ant-modal-footer').contains('Save').scrollIntoView().click();
|
||||||
|
cy.wait('@updateTableProfilerConfig').then(({ request }) => {
|
||||||
|
expect(request.body).to.deep.equal({
|
||||||
|
excludeColumns: ['user_id'],
|
||||||
|
profileQuery: 'select * from table',
|
||||||
|
profileSample: 60,
|
||||||
|
profileSampleType: 'PERCENTAGE',
|
||||||
|
includeColumns: [{ columnName: 'shop_id' }],
|
||||||
|
partitioning: {
|
||||||
|
partitionColumnName: 'name',
|
||||||
|
partitionIntervalType: 'COLUMN-VALUE',
|
||||||
|
partitionValues: ['test'],
|
||||||
|
enablePartitioning: true,
|
||||||
|
},
|
||||||
|
sampleDataCount: 100,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.reload();
|
||||||
|
// verify profiler setting details
|
||||||
|
verifyResponseStatusCode('@tableProfiler', 200);
|
||||||
|
verifyResponseStatusCode('@systemProfiler', 200);
|
||||||
|
cy.get('[data-testid="profiler-setting-btn"]').click();
|
||||||
|
verifyResponseStatusCode('@tableProfilerConfig', 200);
|
||||||
|
|
||||||
|
cy.get('[data-testid="slider-input"]').should(
|
||||||
|
'have.value',
|
||||||
|
`${profilerSetting.profileSample}%`
|
||||||
|
);
|
||||||
|
cy.get('.CodeMirror-scroll').should(
|
||||||
|
'contain',
|
||||||
|
profilerSetting.profileQuery
|
||||||
|
);
|
||||||
|
cy.get('[data-testid="exclude-column-select"]').should(
|
||||||
|
'contain',
|
||||||
|
profilerSetting.excludeColumns
|
||||||
|
);
|
||||||
|
cy.get('[data-testid="enable-partition-switch"]').should(
|
||||||
|
'have.value',
|
||||||
|
'true'
|
||||||
|
);
|
||||||
|
cy.get('[data-testid="interval-type"]').should(
|
||||||
|
'contain',
|
||||||
|
profilerSetting.partitionIntervalType
|
||||||
|
);
|
||||||
|
cy.get('[data-testid="column-name"]').should(
|
||||||
|
'contain',
|
||||||
|
profilerSetting.partitionColumnName
|
||||||
|
);
|
||||||
|
cy.get('[data-testid="partition-value"]').should(
|
||||||
|
'have.value',
|
||||||
|
profilerSetting.partitionValues
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
import {
|
import {
|
||||||
act,
|
act,
|
||||||
cleanup,
|
cleanup,
|
||||||
|
findByText,
|
||||||
fireEvent,
|
fireEvent,
|
||||||
render,
|
render,
|
||||||
screen,
|
screen,
|
||||||
} from '@testing-library/react';
|
} from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MOCK_TABLE } from '../../../mocks/TableData.mock';
|
import { MOCK_TABLE } from '../../../mocks/TableData.mock';
|
||||||
|
import { getTableProfilerConfig } from '../../../rest/tableAPI';
|
||||||
import { ProfilerSettingsModalProps } from '../TableProfiler.interface';
|
import { ProfilerSettingsModalProps } from '../TableProfiler.interface';
|
||||||
import ProfilerSettingsModal from './ProfilerSettingsModal';
|
import ProfilerSettingsModal from './ProfilerSettingsModal';
|
||||||
|
|
||||||
@ -103,4 +105,69 @@ describe('Test ProfilerSettingsModal component', () => {
|
|||||||
expect(intervalType).not.toHaveClass('ant-select-disabled');
|
expect(intervalType).not.toHaveClass('ant-select-disabled');
|
||||||
expect(columnName).not.toHaveClass('ant-select-disabled');
|
expect(columnName).not.toHaveClass('ant-select-disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('initial values should be visible in the form', async () => {
|
||||||
|
const tableProfilerConfig = {
|
||||||
|
profileSample: 60.0,
|
||||||
|
profileSampleType: 'PERCENTAGE',
|
||||||
|
sampleDataCount: 500,
|
||||||
|
profileQuery: 'select * from table',
|
||||||
|
excludeColumns: ['address_id'],
|
||||||
|
includeColumns: [
|
||||||
|
{
|
||||||
|
columnName: 'first_name',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
partitioning: {
|
||||||
|
enablePartitioning: true,
|
||||||
|
partitionColumnName: 'last_name',
|
||||||
|
partitionIntervalType: 'COLUMN-VALUE',
|
||||||
|
partitionValues: ['test'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
(getTableProfilerConfig as jest.Mock).mockImplementationOnce(() =>
|
||||||
|
Promise.resolve({ ...MOCK_TABLE, tableProfilerConfig })
|
||||||
|
);
|
||||||
|
render(<ProfilerSettingsModal {...mockProps} />);
|
||||||
|
|
||||||
|
const excludeSelect = await screen.findByTestId('exclude-column-select');
|
||||||
|
const includeSelect = await screen.findByTestId('include-column-select');
|
||||||
|
const partitionSwitch = await screen.findByTestId(
|
||||||
|
'enable-partition-switch'
|
||||||
|
);
|
||||||
|
const intervalType = await screen.findByTestId('interval-type');
|
||||||
|
const columnName = await screen.findByTestId('column-name');
|
||||||
|
|
||||||
|
expect(await screen.findByTestId('sample-data-count-input')).toHaveValue(
|
||||||
|
tableProfilerConfig.sampleDataCount.toString()
|
||||||
|
);
|
||||||
|
expect(await screen.findByTestId('slider-input')).toHaveValue(
|
||||||
|
`${tableProfilerConfig.profileSample}%`
|
||||||
|
);
|
||||||
|
expect(await screen.findByTestId('partition-value')).toHaveValue(
|
||||||
|
tableProfilerConfig.partitioning.partitionValues[0]
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
await findByText(excludeSelect, tableProfilerConfig.excludeColumns[0])
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
await findByText(
|
||||||
|
includeSelect,
|
||||||
|
tableProfilerConfig.includeColumns[0].columnName
|
||||||
|
)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
await findByText(
|
||||||
|
intervalType,
|
||||||
|
tableProfilerConfig.partitioning.partitionIntervalType
|
||||||
|
)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
await findByText(
|
||||||
|
columnName,
|
||||||
|
tableProfilerConfig.partitioning.partitionColumnName
|
||||||
|
)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(partitionSwitch).toHaveAttribute('aria-checked', 'true');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -171,6 +171,9 @@ const ProfilerSettingsModal: React.FC<ProfilerSettingsModalProps> = ({
|
|||||||
profileSampleType ?? ProfileSampleType.Percentage,
|
profileSampleType ?? ProfileSampleType.Percentage,
|
||||||
sampleDataCount,
|
sampleDataCount,
|
||||||
});
|
});
|
||||||
|
form.setFieldsValue({
|
||||||
|
sampleDataCount: sampleDataCount ?? initialState.sampleDataCount,
|
||||||
|
});
|
||||||
|
|
||||||
const profileSampleTypeCheck =
|
const profileSampleTypeCheck =
|
||||||
profileSampleType === ProfileSampleType.Percentage;
|
profileSampleType === ProfileSampleType.Percentage;
|
||||||
@ -575,7 +578,7 @@ const ProfilerSettingsModal: React.FC<ProfilerSettingsModalProps> = ({
|
|||||||
name={[name, 'columnName']}>
|
name={[name, 'columnName']}>
|
||||||
<Select
|
<Select
|
||||||
className="w-full"
|
className="w-full"
|
||||||
data-testid="exclude-column-select"
|
data-testid="include-column-select"
|
||||||
options={selectOptions}
|
options={selectOptions}
|
||||||
placeholder={t(
|
placeholder={t(
|
||||||
'label.select-column-plural-to-include'
|
'label.select-column-plural-to-include'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user