feat: Implement drag & drop for metrics and filters labels (#12184)

This commit is contained in:
Kamil Gabryjelski
2020-12-25 05:46:37 +01:00
committed by GitHub
parent 74f3faf1cd
commit f3ab1f41ee
13 changed files with 251 additions and 22 deletions

View File

@@ -71,7 +71,7 @@ function setup(overrides) {
...overrides,
};
const wrapper = shallow(<AdhocFilterControl {...props} />);
const component = wrapper.dive().shallow();
const component = wrapper.dive().dive().shallow();
return { wrapper, component, onChange };
}

View File

@@ -56,6 +56,6 @@ describe('AdhocFilterOption', () => {
const popover = overlay.find(Popover);
expect(popover).toHaveLength(1);
expect(popover.props().defaultVisible).toBe(false);
expect(overlay.find('OptionControlLabel')).toExist();
expect(overlay.find('DraggableOptionControlLabel')).toExist();
});
});

View File

@@ -45,6 +45,9 @@ function setup(overrides) {
savedMetrics: [],
onMetricEdit,
columns,
onMoveLabel: () => {},
onDropLabel: () => {},
index: 0,
...overrides,
};
const wrapper = shallow(<AdhocMetricOption {...props} />)
@@ -57,7 +60,7 @@ describe('AdhocMetricOption', () => {
it('renders an overlay trigger wrapper for the label', () => {
const { wrapper } = setup();
expect(wrapper.find(Popover)).toExist();
expect(wrapper.find('OptionControlLabel')).toExist();
expect(wrapper.find('DraggableOptionControlLabel')).toExist();
});
it('overwrites the adhocMetric in state with onLabelChange', () => {

View File

@@ -53,7 +53,7 @@ function setup(overrides) {
...overrides,
};
const wrapper = shallow(<MetricsControl {...props} />);
const component = wrapper.dive().shallow();
const component = wrapper.dive().dive().shallow();
return { wrapper, component, onChange };
}

View File

@@ -120,7 +120,9 @@ describe('VerifiedMetricsControl', () => {
onChange: mockOnChange,
});
const child = wrapper.find(MetricsControl);
const child = wrapper.find(MetricsControl) as ReactWrapper<{
onChange: (str: string[]) => void;
}>;
child.props().onChange(['abc']);
expect(child.length).toBe(1);