Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(native filter): add test for time range filter #18647

Merged
merged 3 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,76 @@ describe('Nativefilters Sanity test', () => {
.trigger('mouseover', { force: true });
cy.contains('Exclude selected values');
});
it('User can create a time range filter', () => {
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({ force: true });
cy.get('[label="Time range"]').click();
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click()
.clear()
.type('time range');
cy.get(nativeFilters.modal.footer)
.contains('Save')
.should('be.visible')
.click();
cy.intercept(`/api/v1/chart/data?form_data=**`).as('chart');
cy.get(dashboardView.salesDashboardSpecific.vehicleSalesFilterTimeRange)
.should('be.visible')
.click();
cy.get('.control-label').contains('RANGE TYPE').should('be.visible');
cy.get('.ant-popover-content .ant-select-selector')
.should('be.visible')
.click();
cy.get('[label="Advanced"]').should('be.visible').click();
cy.get('.section-title')
.contains('Advanced Time Range')
.should('be.visible');
cy.get('.ant-popover-inner-content')
.find('[class^=ant-input]')
.first()
.type('2005-12-17');
cy.get(dashboardView.timeRangeModal.applyButton).click();
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 range')
.should('be.visible');
cy.get(nativeFilters.filterFromDashboardView.timeRangeFilterContent)
.contains('2005-12-17')
.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
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,20 @@ export const nativeFilters = {
columnEmptyInput: '.ant-select-selection-placeholder',
filterTypeInput: dataTestLocator('filters-config-modal__filter-type'),
fieldInput: dataTestLocator('field-input'),
filterTypeItem: '.ant-select-selection-item',
},
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',
createFilterButton: dataTestLocator('create-filter'),
timeRangeFilterContent: dataTestLocator('time-range-trigger'),
},
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 @@ -467,6 +472,7 @@ export const exploreView = {
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