2019-01-15 18:53:27 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2016-11-02 15:57:44 -04:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
2020-09-09 16:18:55 -04:00
|
|
|
import { getChartControlPanelRegistry, t } from '@superset-ui/core';
|
2019-04-30 14:45:06 -04:00
|
|
|
import { defaultControls } from 'src/explore/store';
|
|
|
|
import { getFormDataFromControls } from 'src/explore/controlUtils';
|
2018-10-24 01:33:51 -04:00
|
|
|
import { ControlPanelsContainer } from 'src/explore/components/ControlPanelsContainer';
|
|
|
|
import ControlPanelSection from 'src/explore/components/ControlPanelSection';
|
2016-11-02 15:57:44 -04:00
|
|
|
|
|
|
|
describe('ControlPanelsContainer', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
2019-09-11 11:58:24 -04:00
|
|
|
beforeAll(() => {
|
|
|
|
getChartControlPanelRegistry().registerValue('table', {
|
|
|
|
controlPanelSections: [
|
|
|
|
{
|
|
|
|
label: t('GROUP BY'),
|
2019-11-27 17:02:48 -05:00
|
|
|
description: t(
|
|
|
|
'Use this section if you want a query that aggregates',
|
|
|
|
),
|
2019-09-11 11:58:24 -04:00
|
|
|
expanded: true,
|
|
|
|
controlSetRows: [
|
|
|
|
['groupby'],
|
|
|
|
['metrics'],
|
|
|
|
['percent_metrics'],
|
|
|
|
['timeseries_limit_metric', 'row_limit'],
|
|
|
|
['include_time', 'order_desc'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: t('NOT GROUPED BY'),
|
|
|
|
description: t('Use this section if you want to query atomic rows'),
|
|
|
|
expanded: true,
|
|
|
|
controlSetRows: [
|
|
|
|
['all_columns'],
|
|
|
|
['order_by_cols'],
|
|
|
|
['row_limit', null],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: t('Query'),
|
|
|
|
expanded: true,
|
2019-11-27 17:02:48 -05:00
|
|
|
controlSetRows: [['adhoc_filters']],
|
2019-09-11 11:58:24 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: t('Options'),
|
|
|
|
expanded: true,
|
|
|
|
controlSetRows: [
|
|
|
|
['table_timestamp_format'],
|
|
|
|
['page_length', null],
|
|
|
|
['include_search', 'table_filter'],
|
|
|
|
['align_pn', 'color_pn'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-24 01:33:51 -04:00
|
|
|
afterAll(() => {
|
2019-09-11 11:58:24 -04:00
|
|
|
getChartControlPanelRegistry().remove('table');
|
2016-11-02 15:57:44 -04:00
|
|
|
});
|
|
|
|
|
2019-09-11 11:58:24 -04:00
|
|
|
function getDefaultProps() {
|
|
|
|
return {
|
|
|
|
datasource_type: 'table',
|
|
|
|
actions: {},
|
|
|
|
controls: defaultControls,
|
|
|
|
// Note: default viz_type is table
|
|
|
|
form_data: getFormDataFromControls(defaultControls),
|
|
|
|
isDatasourceMetaLoading: false,
|
|
|
|
exploreState: {},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-05-16 03:02:37 -04:00
|
|
|
it('renders ControlPanelSections', () => {
|
2019-09-11 11:58:24 -04:00
|
|
|
wrapper = shallow(<ControlPanelsContainer {...getDefaultProps()} />);
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(wrapper.find(ControlPanelSection)).toHaveLength(6);
|
2016-11-02 15:57:44 -04:00
|
|
|
});
|
|
|
|
});
|