mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
feat: Add Saved Metrics tab to metrics popover (#12123)
* Implement saved metrics * Fix bug in sql editor * Fix unit tests * Fix outlines in popovers * Add types for saved metrics * Add translations * Move savedMetricType to a separate file
This commit is contained in:
committed by
GitHub
parent
8e625e0a64
commit
2a23744223
@@ -49,6 +49,8 @@ function setup(overrides) {
|
||||
const onClose = sinon.spy();
|
||||
const props = {
|
||||
adhocMetric: sumValueAdhocMetric,
|
||||
savedMetric: {},
|
||||
savedMetrics: [],
|
||||
onChange,
|
||||
onClose,
|
||||
onResize: () => {},
|
||||
@@ -62,7 +64,7 @@ function setup(overrides) {
|
||||
describe('AdhocMetricEditPopover', () => {
|
||||
it('renders a popover with edit metric form contents', () => {
|
||||
const { wrapper } = setup();
|
||||
expect(wrapper.find(FormGroup)).toHaveLength(3);
|
||||
expect(wrapper.find(FormGroup)).toHaveLength(4);
|
||||
expect(wrapper.find(Button)).toHaveLength(2);
|
||||
});
|
||||
|
||||
|
||||
@@ -41,11 +41,15 @@ function setup(overrides) {
|
||||
const onMetricEdit = sinon.spy();
|
||||
const props = {
|
||||
adhocMetric: sumValueAdhocMetric,
|
||||
savedMetric: {},
|
||||
savedMetrics: [],
|
||||
onMetricEdit,
|
||||
columns,
|
||||
...overrides,
|
||||
};
|
||||
const wrapper = shallow(<AdhocMetricOption {...props} />);
|
||||
const wrapper = shallow(<AdhocMetricOption {...props} />)
|
||||
.find('AdhocMetricPopoverTrigger')
|
||||
.shallow();
|
||||
return { wrapper, onMetricEdit };
|
||||
}
|
||||
|
||||
@@ -56,13 +60,6 @@ describe('AdhocMetricOption', () => {
|
||||
expect(wrapper.find('OptionControlLabel')).toExist();
|
||||
});
|
||||
|
||||
it('overlay should open if metric is new', () => {
|
||||
const { wrapper } = setup({
|
||||
adhocMetric: sumValueAdhocMetric.duplicateWith({ isNew: true }),
|
||||
});
|
||||
expect(wrapper.find(Popover).props().defaultVisible).toBe(true);
|
||||
});
|
||||
|
||||
it('overwrites the adhocMetric in state with onLabelChange', () => {
|
||||
const { wrapper } = setup();
|
||||
wrapper.instance().onLabelChange({ target: { value: 'new label' } });
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('MetricDefinitionValue', () => {
|
||||
const wrapper = shallow(
|
||||
<MetricDefinitionValue option={{ metric_name: 'a_saved_metric' }} />,
|
||||
);
|
||||
expect(wrapper.find('OptionControlLabel')).toExist();
|
||||
expect(wrapper.find('AdhocMetricOption')).toExist();
|
||||
});
|
||||
|
||||
it('renders an AdhocMetricOption given an adhoc metric', () => {
|
||||
|
||||
@@ -169,7 +169,7 @@ describe('MetricsControl', () => {
|
||||
const editedMetric = sumValueAdhocMetric.duplicateWith({
|
||||
aggregate: AGGREGATES.AVG,
|
||||
});
|
||||
component.instance().onMetricEdit(editedMetric);
|
||||
component.instance().onMetricEdit(editedMetric, sumValueAdhocMetric);
|
||||
|
||||
expect(onChange.lastCall.args).toEqual([[editedMetric]]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user