mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
display all metric results in editor (#15031)
This commit is contained in:
parent
11eef251b2
commit
21aa3daae3
@ -45,6 +45,8 @@ export default {
|
|||||||
verbose_name: 'sum__num',
|
verbose_name: 'sum__num',
|
||||||
metric_name: 'sum__num',
|
metric_name: 'sum__num',
|
||||||
description: null,
|
description: null,
|
||||||
|
extra:
|
||||||
|
'{"certification":{"details":"foo", "certified_by":"someone"},"warning_markdown":"bar"}',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
expression: 'AVG(birth_names.num)',
|
expression: 'AVG(birth_names.num)',
|
||||||
|
@ -21,6 +21,9 @@ import { shallow } from 'enzyme';
|
|||||||
import configureStore from 'redux-mock-store';
|
import configureStore from 'redux-mock-store';
|
||||||
import fetchMock from 'fetch-mock';
|
import fetchMock from 'fetch-mock';
|
||||||
import thunk from 'redux-thunk';
|
import thunk from 'redux-thunk';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
import { render, screen } from 'spec/helpers/testing-library';
|
||||||
|
|
||||||
import { Radio } from 'src/components/Radio';
|
import { Radio } from 'src/components/Radio';
|
||||||
|
|
||||||
import Icon from 'src/components/Icon';
|
import Icon from 'src/components/Icon';
|
||||||
@ -56,6 +59,10 @@ describe('DatasourceEditor', () => {
|
|||||||
inst = wrapper.instance();
|
inst = wrapper.instance();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
|
|
||||||
it('is valid', () => {
|
it('is valid', () => {
|
||||||
expect(React.isValidElement(el)).toBe(true);
|
expect(React.isValidElement(el)).toBe(true);
|
||||||
});
|
});
|
||||||
@ -209,3 +216,21 @@ describe('DatasourceEditor', () => {
|
|||||||
isFeatureEnabledMock.mockRestore();
|
isFeatureEnabledMock.mockRestore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('DatasourceEditor RTL', () => {
|
||||||
|
it('properly renders the metric information', async () => {
|
||||||
|
render(<DatasourceEditor {...props} />, { useRedux: true });
|
||||||
|
const metricButton = screen.getByTestId('collection-tab-Metrics');
|
||||||
|
userEvent.click(metricButton);
|
||||||
|
const expandToggle = await screen.findAllByLabelText(/toggle expand/i);
|
||||||
|
userEvent.click(expandToggle[0]);
|
||||||
|
const certificationDetails = await screen.findByPlaceholderText(
|
||||||
|
/certification details/i,
|
||||||
|
);
|
||||||
|
expect(certificationDetails.value).toEqual('foo');
|
||||||
|
const warningMarkdown = await await screen.findByPlaceholderText(
|
||||||
|
/certified by/i,
|
||||||
|
);
|
||||||
|
expect(warningMarkdown.value).toEqual('someone');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -936,7 +936,18 @@ class DatasourceEditor extends React.PureComponent {
|
|||||||
</Fieldset>
|
</Fieldset>
|
||||||
</FormContainer>
|
</FormContainer>
|
||||||
}
|
}
|
||||||
collection={this.state.datasource.metrics}
|
collection={this.state.datasource.metrics?.map(metric => {
|
||||||
|
const {
|
||||||
|
certification: { details, certified_by: certifiedBy } = {},
|
||||||
|
warning_markdown: warningMarkdown,
|
||||||
|
} = JSON.parse(metric.extra || '{}') || {};
|
||||||
|
return {
|
||||||
|
...metric,
|
||||||
|
certification_details: details || '',
|
||||||
|
warning_markdown: warningMarkdown || '',
|
||||||
|
certified_by: certifiedBy,
|
||||||
|
};
|
||||||
|
})}
|
||||||
allowAddItem
|
allowAddItem
|
||||||
onChange={this.onDatasourcePropChange.bind(this, 'metrics')}
|
onChange={this.onDatasourcePropChange.bind(this, 'metrics')}
|
||||||
itemGenerator={() => ({
|
itemGenerator={() => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user