2020-12-18 20:06:37 -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.
|
|
|
|
*/
|
2021-10-28 23:08:18 -04:00
|
|
|
import { dashboardView, nativeFilters } from 'cypress/support/directories';
|
|
|
|
import { testItems } from './dashboard.helper';
|
2021-02-05 01:54:00 -05:00
|
|
|
import { DASHBOARD_LIST } from '../dashboard_list/dashboard_list.helper';
|
2020-12-18 20:06:37 -05:00
|
|
|
|
2021-10-28 23:08:18 -04:00
|
|
|
const getTestTitle = (
|
|
|
|
test: Mocha.Suite = (Cypress as any).mocha.getRunner().suite.ctx.test,
|
|
|
|
): string =>
|
|
|
|
test.parent?.title
|
|
|
|
? `${getTestTitle(test.parent)} -- ${test.title}`
|
|
|
|
: test.title;
|
|
|
|
|
2021-04-27 13:28:38 -04:00
|
|
|
// TODO: fix flaky init logic and re-enable
|
2021-02-05 01:54:00 -05:00
|
|
|
const milliseconds = new Date().getTime();
|
|
|
|
const dashboard = `Test Dashboard${milliseconds}`;
|
2021-10-28 23:08:18 -04:00
|
|
|
|
|
|
|
describe('Nativefilters Sanity test', () => {
|
|
|
|
before(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.intercept('/api/v1/dashboard/?q=**').as('dashboardsList');
|
|
|
|
cy.intercept('POST', '**/copy_dash/*').as('copy');
|
|
|
|
cy.intercept('/api/v1/dashboard/*').as('dashboard');
|
|
|
|
cy.request(
|
|
|
|
'api/v1/dashboard/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:100)',
|
|
|
|
).then(xhr => {
|
|
|
|
const dashboards = xhr.body.result;
|
|
|
|
const worldBankDashboard = dashboards.find(
|
|
|
|
d => d.dashboard_title === "World Bank's Data",
|
|
|
|
);
|
|
|
|
cy.visit(worldBankDashboard.url);
|
|
|
|
});
|
|
|
|
cy.get(dashboardView.threeDotsMenuIcon).should('be.visible').click();
|
|
|
|
cy.get(dashboardView.saveAsMenuOption).should('be.visible').click();
|
|
|
|
cy.get(dashboardView.saveModal.dashboardNameInput)
|
|
|
|
.should('be.visible')
|
|
|
|
.clear()
|
|
|
|
.type(testItems.dashboard);
|
|
|
|
cy.get(dashboardView.saveModal.saveButton).click();
|
|
|
|
cy.wait('@copy', { timeout: 45000 })
|
|
|
|
.its('response.statusCode')
|
|
|
|
.should('eq', 200);
|
|
|
|
});
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.request(
|
|
|
|
'api/v1/dashboard/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:100)',
|
|
|
|
).then(xhr => {
|
|
|
|
const dashboards = xhr.body.result;
|
|
|
|
const testDashboard = dashboards.find(
|
|
|
|
d => d.dashboard_title === testItems.dashboard,
|
|
|
|
);
|
|
|
|
cy.visit(testDashboard.url);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('User can expand / retract native filter sidebar on a dashboard', () => {
|
|
|
|
cy.get(nativeFilters.createFilterButton).should('not.exist');
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.expand)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.createFilterButton).should('be.visible');
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.expand).should(
|
|
|
|
'not.be.visible',
|
|
|
|
);
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.collapse)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.collapse).should(
|
|
|
|
'not.be.visible',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('User can enter filter edit pop-up by clicking on pencil icon', () => {
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.expand)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.createFilterButton).should('be.visible').click();
|
|
|
|
cy.get(nativeFilters.modal.container).should('be.visible');
|
|
|
|
});
|
|
|
|
it('User can add a new native filter', () => {
|
|
|
|
cy.get(nativeFilters.filterFromDashboardView.expand)
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.createFilterButton).should('be.visible').click();
|
|
|
|
cy.get(nativeFilters.modal.container)
|
|
|
|
.find(nativeFilters.filtersPanel.filterName)
|
|
|
|
.click()
|
|
|
|
.type('Country name');
|
|
|
|
cy.get(nativeFilters.modal.container)
|
|
|
|
.find(nativeFilters.filtersPanel.datasetName)
|
|
|
|
.click()
|
|
|
|
.type('wb_health_population{enter}');
|
|
|
|
|
|
|
|
// Add following step to avoid flaky enter value in line 177
|
|
|
|
cy.get(nativeFilters.filtersPanel.inputDropdown)
|
|
|
|
.should('be.visible', { timeout: 20000 })
|
|
|
|
.last()
|
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.get('.loading inline-centered css-101mkpk').should('not.exist');
|
|
|
|
// hack for unclickable country_name
|
|
|
|
cy.wait(5000);
|
|
|
|
cy.get(nativeFilters.filtersPanel.filterInfoInput)
|
|
|
|
.last()
|
|
|
|
.should('be.visible')
|
|
|
|
.click({ force: true });
|
|
|
|
cy.get(nativeFilters.filtersPanel.filterInfoInput)
|
|
|
|
.last()
|
|
|
|
.type('country_name');
|
|
|
|
cy.get(nativeFilters.filtersPanel.inputDropdown)
|
|
|
|
.should('be.visible', { timeout: 20000 })
|
|
|
|
.last()
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.modal.footer)
|
|
|
|
.contains('Save')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get(nativeFilters.modal.container).should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-04-27 13:28:38 -04:00
|
|
|
xdescribe('Nativefilters', () => {
|
2021-02-05 01:54:00 -05:00
|
|
|
before(() => {
|
|
|
|
cy.login();
|
|
|
|
cy.visit(DASHBOARD_LIST);
|
|
|
|
cy.get('[data-test="new-dropdown"]').click();
|
|
|
|
cy.get('[data-test="menu-item-Dashboard"]').click({ force: true });
|
|
|
|
cy.get('[data-test="editable-title-input"]')
|
|
|
|
.click()
|
|
|
|
.clear()
|
|
|
|
.type(`${dashboard}{enter}`);
|
|
|
|
cy.get('[data-test="header-save-button"]').click();
|
|
|
|
cy.visit(CHART_LIST);
|
|
|
|
cy.get('[data-test="search-input"]').type('Treemap{enter}');
|
|
|
|
cy.get('[data-test="Treemap-list-chart-title"]')
|
|
|
|
.should('be.visible', { timeout: 5000 })
|
|
|
|
.click();
|
|
|
|
cy.get('[data-test="query-save-button"]').click();
|
|
|
|
cy.get('[data-test="save-chart-modal-select-dashboard-form"]')
|
2021-09-27 11:14:58 -04:00
|
|
|
.find('input[aria-label="Select a dashboard"]')
|
|
|
|
.type(`${dashboard}`, { force: true });
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('[data-test="btn-modal-save"]').click();
|
|
|
|
});
|
2020-12-18 20:06:37 -05:00
|
|
|
beforeEach(() => {
|
|
|
|
cy.login();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.visit(DASHBOARD_LIST);
|
|
|
|
cy.get('[data-test="search-input"]').click().type(`${dashboard}{enter}`);
|
|
|
|
cy.contains('[data-test="cell-text"]', `${dashboard}`).click();
|
2020-12-18 20:06:37 -05:00
|
|
|
});
|
2021-02-05 01:54:00 -05:00
|
|
|
|
2020-12-18 20:06:37 -05:00
|
|
|
it('should show filter bar and allow user to create filters ', () => {
|
|
|
|
cy.get('[data-test="filter-bar"]').should('be.visible');
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__expand-button"]').click();
|
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2020-12-18 20:06:37 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
|
|
|
|
|
|
|
cy.get('.ant-modal')
|
2021-04-20 05:24:12 -04:00
|
|
|
.find('[data-test="filters-config-modal__name-input"]')
|
2021-02-05 01:54:00 -05:00
|
|
|
.click()
|
|
|
|
.type('Country name');
|
2020-12-18 20:06:37 -05:00
|
|
|
|
2021-04-12 19:10:29 -04:00
|
|
|
cy.get('.ant-modal')
|
2021-04-20 07:07:08 -04:00
|
|
|
.find('[data-test="filters-config-modal__datasource-input"]')
|
2021-04-12 19:10:29 -04:00
|
|
|
.click()
|
|
|
|
.type('wb_health_population');
|
2020-12-18 20:06:37 -05:00
|
|
|
|
2021-04-20 07:07:08 -04:00
|
|
|
cy.get(
|
|
|
|
'.ant-modal [data-test="filters-config-modal__datasource-input"] .Select__menu',
|
|
|
|
)
|
2020-12-18 20:06:37 -05:00
|
|
|
.contains('wb_health_population')
|
|
|
|
.click();
|
|
|
|
|
2021-02-05 01:54:00 -05:00
|
|
|
// hack for unclickable country_name
|
|
|
|
cy.get('.ant-modal').find('[data-test="field-input"]').type('country_name');
|
|
|
|
cy.get('.ant-modal')
|
2020-12-18 20:06:37 -05:00
|
|
|
.find('[data-test="field-input"]')
|
2021-02-05 01:54:00 -05:00
|
|
|
.type('{downarrow}{downarrow}{enter}');
|
|
|
|
cy.get('[data-test="apply-changes-instantly-checkbox"]').check();
|
|
|
|
cy.get('.ant-modal-footer')
|
|
|
|
.find('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.should('be.visible')
|
2020-12-18 20:06:37 -05:00
|
|
|
.click();
|
2021-02-05 01:54:00 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should show newly added filter in filter bar menu', () => {
|
|
|
|
cy.get('[data-test="filter-bar"]').should('be.visible');
|
|
|
|
cy.get('[data-test="filter-control-name"]').should('be.visible');
|
|
|
|
cy.get('[data-test="form-item-value"]').should('be.visible');
|
|
|
|
});
|
|
|
|
it('should filter dashboard with selected filter value', () => {
|
|
|
|
cy.get('[data-test="form-item-value"]').should('be.visible').click();
|
|
|
|
cy.get('.ant-select-selection-search').type('Hong Kong{enter}');
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__apply-button"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('HKG').should('be.visible');
|
|
|
|
cy.contains('USA').should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
2021-03-11 19:49:01 -05:00
|
|
|
xit('default value is respected after revisit', () => {
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
2021-03-11 19:49:01 -05:00
|
|
|
// TODO: replace with proper wait for filter to finish loading
|
|
|
|
cy.wait(1000);
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('[data-test="default-input"]').click();
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="default-input"]')
|
2021-03-11 19:49:01 -05:00
|
|
|
.type('Sweden{enter}');
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.visit(DASHBOARD_LIST);
|
|
|
|
cy.get('[data-test="search-input"]').click().type(`${dashboard}{enter}`);
|
|
|
|
cy.contains('[data-test="cell-text"]', `${dashboard}`).click();
|
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('SWE').should('be.visible');
|
|
|
|
cy.contains('USA').should('not.exist');
|
|
|
|
});
|
|
|
|
cy.contains('Sweden');
|
|
|
|
});
|
|
|
|
it('should allow for deleted filter restore', () => {
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
|
|
|
cy.get('.ant-tabs-nav-list').within(() => {
|
|
|
|
cy.get('.ant-tabs-tab-remove').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get('[data-test="undo-button"]').should('be.visible').click();
|
|
|
|
cy.get('.ant-tabs-nav-list').within(() => {
|
|
|
|
cy.get('.ant-tabs-tab-remove').click();
|
|
|
|
});
|
|
|
|
cy.get('[data-test="restore-filter-button"]').should('be.visible').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should stop filtering when filter is removed', () => {
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
|
|
|
cy.get('.ant-tabs-nav-list').within(() => {
|
|
|
|
cy.get('.ant-tabs-tab-remove').click();
|
|
|
|
});
|
|
|
|
cy.get('.ant-modal-footer')
|
|
|
|
.find('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('HKG').should('be.visible');
|
|
|
|
cy.contains('USA').should('be.visible');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('Parent Filters', () => {
|
|
|
|
it('should allow for creating parent filters ', () => {
|
|
|
|
cy.get('[data-test="filter-bar"]').should('be.visible');
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__expand-button"]').click();
|
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
|
|
|
|
|
|
|
cy.get('.ant-modal')
|
2021-04-20 05:24:12 -04:00
|
|
|
.find('[data-test="filters-config-modal__name-input"]')
|
2021-02-05 01:54:00 -05:00
|
|
|
.click()
|
|
|
|
.type('Country name');
|
|
|
|
|
2021-04-12 19:10:29 -04:00
|
|
|
cy.get('.ant-modal')
|
2021-04-20 07:07:08 -04:00
|
|
|
.find('[data-test="filters-config-modal__datasource-input"]')
|
2021-04-12 19:10:29 -04:00
|
|
|
.click()
|
|
|
|
.type('wb_health_population');
|
2021-02-05 01:54:00 -05:00
|
|
|
|
2021-04-20 07:07:08 -04:00
|
|
|
cy.get(
|
|
|
|
'.ant-modal [data-test="filters-config-modal__datasource-input"] .Select__menu',
|
|
|
|
)
|
2021-02-05 01:54:00 -05:00
|
|
|
.contains('wb_health_population')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
// hack for unclickable country_name
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="field-input"]')
|
|
|
|
.type('country_name');
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="field-input"]')
|
|
|
|
.type('{downarrow}{downarrow}{enter}');
|
|
|
|
cy.get('[data-test="apply-changes-instantly-checkbox"]').check();
|
|
|
|
cy.get('.ant-modal-footer')
|
|
|
|
.find('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').first().should('be.visible');
|
|
|
|
cy.get('[data-test=add-filter-button]').first().click();
|
|
|
|
|
|
|
|
cy.get('.ant-modal')
|
2021-04-20 05:24:12 -04:00
|
|
|
.find('[data-test="filters-config-modal__name-input"]')
|
2021-02-05 01:54:00 -05:00
|
|
|
.last()
|
|
|
|
.click()
|
|
|
|
.type('Region Name');
|
|
|
|
|
|
|
|
cy.get('.ant-modal')
|
2021-04-20 07:07:08 -04:00
|
|
|
.find('[data-test="filters-config-modal__datasource-input"]')
|
2021-02-05 01:54:00 -05:00
|
|
|
.last()
|
2021-04-12 19:10:29 -04:00
|
|
|
.click()
|
|
|
|
.type('wb_health_population');
|
2021-02-05 01:54:00 -05:00
|
|
|
|
2021-04-20 07:07:08 -04:00
|
|
|
cy.get(
|
|
|
|
'.ant-modal [data-test="filters-config-modal__datasource-input"] .Select__menu',
|
|
|
|
)
|
2021-02-05 01:54:00 -05:00
|
|
|
.last()
|
|
|
|
.contains('wb_health_population')
|
|
|
|
.click();
|
|
|
|
|
|
|
|
// hack for unclickable country_name
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="field-input"]')
|
|
|
|
.last()
|
|
|
|
.type('region');
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="field-input"]')
|
|
|
|
.last()
|
|
|
|
.type('{downarrow}{downarrow}{downarrow}{downarrow}{enter}');
|
|
|
|
|
|
|
|
cy.get('[data-test="apply-changes-instantly-checkbox"]').last().check();
|
|
|
|
cy.get('.ant-modal')
|
|
|
|
.find('[data-test="parent-filter-input"]')
|
|
|
|
.last()
|
|
|
|
.type('{downarrow}{enter}');
|
|
|
|
|
|
|
|
cy.get('.ant-modal-footer')
|
|
|
|
.find('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.first()
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get('[data-test="filter-icon"]').should('be.visible');
|
|
|
|
});
|
2021-03-11 19:49:01 -05:00
|
|
|
xit('should parent filter be working', () => {
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('SMR').should('be.visible');
|
|
|
|
cy.contains('Europe & Central Asia').should('be.visible');
|
|
|
|
cy.contains('South Asia').should('be.visible');
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get('[data-test="form-item-value"]').should('be.visible').click();
|
|
|
|
cy.get('.ant-popover-inner-content').within(() => {
|
|
|
|
cy.get('[data-test="form-item-value"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.first()
|
|
|
|
.type('San Marino{enter}');
|
|
|
|
cy.get('[data-test="form-item-value"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.last()
|
|
|
|
.type('Europe & Central Asia{enter}');
|
|
|
|
});
|
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('SMR').should('be.visible');
|
|
|
|
cy.contains('Europe & Central Asia').should('be.visible');
|
|
|
|
cy.contains('South Asia').should('not.exist');
|
|
|
|
});
|
|
|
|
});
|
2020-12-18 20:06:37 -05:00
|
|
|
|
2021-02-05 01:54:00 -05:00
|
|
|
it('should stop filtering when parent filter is removed', () => {
|
2021-04-20 05:24:12 -04:00
|
|
|
cy.get('[data-test="filter-bar__create-filter"]').click();
|
2021-02-05 01:54:00 -05:00
|
|
|
cy.get('.ant-modal').should('be.visible');
|
|
|
|
cy.get('.ant-tabs-nav-list').within(() => {
|
|
|
|
cy.get('.ant-tabs-tab-remove').click({ multiple: true });
|
|
|
|
});
|
|
|
|
cy.get('.ant-modal-footer')
|
|
|
|
.find('[data-test="native-filter-modal-save-button"]')
|
|
|
|
.should('be.visible')
|
|
|
|
.click();
|
|
|
|
cy.get('.treemap').within(() => {
|
|
|
|
cy.contains('HKG').should('be.visible');
|
|
|
|
cy.contains('USA').should('be.visible');
|
|
|
|
});
|
|
|
|
});
|
2020-12-18 20:06:37 -05:00
|
|
|
});
|
|
|
|
});
|