Skip to content

Commit

Permalink
feat: editable title xl certified badge (apache#18626)
Browse files Browse the repository at this point in the history
* Add size to EditableTitle certified badge

* Lint EditableTitle file

Co-authored-by: Emmanuel Bavoux <[email protected]>

add native filter test for time grain filter
  • Loading branch information
opus-42 authored and jinghua-qa committed Feb 10, 2022
1 parent f03b4db commit bfbf236
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/
import qs from 'querystring';
import { dashboardView, nativeFilters } from 'cypress/support/directories';
import { dashboardView, nativeFilters,exploreView } from 'cypress/support/directories';
import { testItems } from './dashboard.helper';
import { DASHBOARD_LIST } from '../dashboard_list/dashboard_list.helper';
import { CHART_LIST } from '../chart_list/chart_list.helper';
import { FORM_DATA_DEFAULTS } from '../explore/visualizations/shared.helper';

const getTestTitle = (
test: Mocha.Suite = (Cypress as any).mocha.getRunner().suite.ctx.test,
Expand Down Expand Up @@ -298,23 +299,128 @@ describe('Nativefilters Sanity test', () => {
.trigger('mouseover', { force: true });
cy.contains('Exclude selected values');
});
it("User can check 'Filter has default value'", () => {
it('User can create a time grain filter', () => {
const VIZ_DEFAULTS = {
...FORM_DATA_DEFAULTS,
viz_type: 'echarts_timeseries',
datasource: '3__table',
granularity_sqla: 'purpose__last_set',
time_range_endpoints: ['inclusive', 'exclusive'],
time_grain_sqla: 'P1D',
time_range: 'No filter',
metrics: ['count'],
comparison_type: 'values',
forecastPeriods: 10,
forecastInterval: 0.8,
x_axis_title_margin: 15,
y_axis_title_margin: 15,
y_axis_title_position: 'Left',
color_scheme: 'supersetColors',
seriesType: 'line',
only_total: true,
opacity: 0.2,
markerSize: 6,
legendType: 'scroll',
legendOrientation: 'top',
x_axis_time_format: 'smart_date',
rich_tooltip: true,
tooltipTimeFormat: 'smart_date',
y_axis_format: 'SMART_NUMBER',
};
cy.visitChartByParams({
...VIZ_DEFAULTS,
});
cy
.get(exploreView.controlPanel.runButton)
.should('be.visible', { timeout: 10000 });
cy.get(exploreView.controlPanel.saveQuery).click();
cy.get(exploreView.saveModal.modal).within(() => {
cy
.get(exploreView.saveModal.chartNameInput)
.type(`${testItems.chart}{enter}`);
cy
.get(exploreView.saveModal.dashboardNameInput)
.type(`${testItems.dashboard}{enter}`, { delay: 100 ,force:true});
cy.get(exploreView.saveModal.saveAndGoToDashboard).click();
});

cy
.get(nativeFilters.filterFromDashboardView.expand)
.click({force:true});
cy
.get(nativeFilters.filterFromDashboardView.createFilterButton)
.should('be.visible')
.click();
cy
.get(nativeFilters.filtersPanel.filterTypeInput)
.find(nativeFilters.filtersPanel.filterTypeItem)
.click();
cy.get('[label="Time grain"]').click();
cy
.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click()
.clear()
.type('time grain');
cy
.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.datasetName)
.click()
.type('wb_health_population');
cy.get(nativeFilters.silentLoading).should('not.exist');
cy.get('[label="wb_health_population"]').click();

cy
.get(nativeFilters.modal.footer)
.contains('Save')
.should('be.visible')
.click();
cy.intercept(`/api/v1/chart/data?form_data=**`).as('chart');
cy.get(nativeFilters.modal.container).should('not.exist');
// cy.wait('@chart');
cy
.get(nativeFilters.filterFromDashboardView.filterValueInput)
.should('be.visible', { timeout: 10000 })
.click()
.type('Month{enter}');
cy.get(nativeFilters.applyFilter).click();
cy.wait('@chart');
cy.url().then((u) => {
const ur = new URL(u);
expect(ur.search).to.include('native_filters');
});
cy
.get(nativeFilters.filterFromDashboardView.filterName)
.contains('time grain')
.should('be.visible');
cy
.get(nativeFilters.filterFromDashboardView.filterContent)
.contains('Month')
.should('be.visible');
});

it("User can check 'Filter has default value'", () => {
cy.get(nativeFilters.filterFromDashboardView.expand).click({ force: true });
cy.get(nativeFilters.createFilterButton)
.should('be.visible')
.click({ force: true });
cy.get(nativeFilters.modal.container).should('be.visible');
cy.get(nativeFilters.filtersPanel.filterTypeInput)
.find(nativeFilters.filtersPanel.filterTypeItem)
.click({ force: true });
cy.get('[label="Value"]').click();
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click({ force: true })
.clear()
.type('country_name');

cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.datasetName)
.click({ force: true })
.within(() =>
cy.get('input').type('wb_health_population{enter}', { force: true }),
);
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click({ force: true })
.type('country_name');
// hack for unclickable datetime
cy.wait(5000);
cy.get(nativeFilters.filtersPanel.filterInfoInput)
Expand Down
9 changes: 7 additions & 2 deletions superset-frontend/cypress-base/cypress/support/directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,23 @@ export const nativeFilters = {
filterName: dataTestLocator('filters-config-modal__name-input'),
datasetName: dataTestLocator('filters-config-modal__datasource-input'),
filterInfoInput: '.ant-select-selection-search-input',
filterTypeItem:".ant-select-selection-item",
inputDropdown: '.ant-select-item-option-content',
columnEmptyInput: '.ant-select-selection-placeholder',
filterTypeInput: dataTestLocator('filters-config-modal__filter-type'),
fieldInput: dataTestLocator('field-input'),
},
filterFromDashboardView: {
filterValueInput: '[class="ant-select-selection-search-input"]',
expand: dataTestLocator('filter-bar__expand-button'),
collapse: dataTestLocator('filter-bar__collapse-button'),
filterName: dataTestLocator('filter-control-name'),
filterContent: '.ant-select-selection-item-content',
filterContent: '.ant-select-selection-item',
createFilterButton: dataTestLocator('create-filter'),
},
createFilterButton: dataTestLocator('filter-bar__create-filter'),
removeFilter: '[aria-label="remove"]',
silentLoading: '.loading inline-centered css-101mkpk',
filterConfigurationSections: {
collapseExpandButton: '.ant-collapse-arrow',
checkedCheckbox: '.ant-checkbox-wrapper-checked',
Expand Down Expand Up @@ -460,13 +464,14 @@ export const exploreView = {
saveModal: {
modal: '.ant-modal-content',
chartNameInput: dataTestLocator('new-chart-name'),
dashboardNameInput: '#dashboard-creatable-select',
dashboardNameInput: '.ant-select-selection-search-input',
addToDashboardInput: dataTestLocator(
'save-chart-modal-select-dashboard-form',
),
saveButton: dataTestLocator('btn-modal-save'),
saveAsCircle: dataTestLocator('saveas-radio'),
overwriteCircle: dataTestLocator('save-overwrite-radio'),
saveAndGoToDashboard: '#btn_modal_save_goto_dash',
},
controlPanel: {
panel: dataTestLocator('control-tabs'),
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/components/EditableTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export default function EditableTitle({
<StyledCertifiedBadge
certifiedBy={certifiedBy}
details={certificationDetails}
size="xl"
/>{' '}
</>
)}
Expand Down

0 comments on commit bfbf236

Please sign in to comment.