You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2022/09/02 16:55:14 UTC
[superset] 01/05: Enhance charts filter test
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch chore/cypress-runtime-enhancements
in repository https://gitbox.apache.org/repos/asf/superset.git
commit b429773cb4b9e66a5c4699fe0161b29f41dd6436
Author: geido <di...@gmail.com>
AuthorDate: Thu Sep 1 15:33:05 2022 +0300
Enhance charts filter test
---
.../integration/chart_list/card_view.test.ts | 129 ----------------
.../integration/chart_list/chart_list.helper.ts | 19 ---
.../chart_list/chartlist.applitools.test.ts | 2 +-
.../cypress/integration/chart_list/filter.test.ts | 167 +++++++++------------
.../integration/dashboard/nativeFilters.test.ts | 2 +-
.../integration/dashboard_list/filter.test.ts | 10 +-
.../cypress-base/cypress/utils/index.ts | 4 +
7 files changed, 76 insertions(+), 257 deletions(-)
diff --git a/superset-frontend/cypress-base/cypress/integration/chart_list/card_view.test.ts b/superset-frontend/cypress-base/cypress/integration/chart_list/card_view.test.ts
deleted file mode 100644
index 1335fcb422..0000000000
--- a/superset-frontend/cypress-base/cypress/integration/chart_list/card_view.test.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * 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.
- */
-import { CHART_LIST } from './chart_list.helper';
-
-describe('chart card view', () => {
- beforeEach(() => {
- cy.login();
- cy.visit(CHART_LIST);
- cy.get('[aria-label="card-view"]').click();
- });
-
- it('should load cards', () => {
- cy.get('[data-test="chart-list-view"]');
- cy.get('[data-test="styled-card"]').should('be.visible');
- cy.get('[data-test="styled-card"]').should('have.length', 25);
- });
-
- it('should allow to favorite/unfavorite chart card', () => {
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-selected']")
- .should('not.exist');
- cy.get("[data-test='card-actions']")
- .find("[aria-label='favorite-unselected']")
- .first()
- .click();
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-selected']")
- .should('be.visible');
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-unselected']")
- .should('not.exist');
-
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-unselected']")
- .should('not.exist');
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-selected']")
- .click();
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-unselected']")
- .should('be.visible');
- cy.get("[data-test='card-actions']")
- .first()
- .find("[aria-label='favorite-selected']")
- .should('not.exist');
- });
-
- xit('should sort correctly', () => {
- // sort Alphabetical
- cy.get('.Select__control').last().should('be.visible');
- cy.get('.Select__control').last().click();
- cy.get('.Select__menu').contains('Alphabetical').click();
- cy.get('[data-test="chart-list-view"]').should('be.visible');
- cy.get('[data-test="styled-card"]').first().contains('% Rural');
-
- // sort Recently Modified
- cy.get('.Select__control').last().should('be.visible');
- cy.get('.Select__control').last().click();
- cy.get('.Select__menu').contains('Recently Modified').click();
- cy.get('[data-test="chart-list-view"]').should('be.visible');
- // TODO - next line is/was flaky
- cy.get('[data-test="styled-card"]').first().contains('Unicode Cloud');
- cy.get('[data-test="styled-card"]')
- .last()
- .contains('Life Expectancy VS Rural %');
- });
-
- // flaky
- xit('should delete correctly', () => {
- // show delete modal
- cy.get('[data-test="more-horiz"]').last().trigger('mouseover');
- cy.get('[data-test="chart-list-delete-option"]')
- .last()
- .should('be.visible');
- cy.get('[data-test="chart-list-delete-option"]')
- .last()
- .contains('Delete')
- .click();
- cy.get('[data-test="Please Confirm-modal"]').should('be.visible');
- cy.get('[data-test="modal-confirm-button"]').should(
- 'have.attr',
- 'disabled',
- );
- cy.get('[data-test="Please Confirm-modal"]').should('be.visible');
- cy.get("[data-test='delete-modal-input']").type('DELETE');
- cy.get('[data-test="modal-confirm-button"]').should(
- 'not.have.attr',
- 'disabled',
- );
- cy.get('[data-test="modal-cancel-button"]').click();
- });
-
- // flaky
- xit('should edit correctly', () => {
- // show edit modal
- cy.get('[data-test="more-horiz"]').last().trigger('mouseover');
- cy.get('[data-test="chart-list-edit-option"]').last().should('be.visible');
- cy.get('[data-test="chart-list-edit-option"]').last().click();
- cy.get('[data-test="properties-edit-modal"]').should('be.visible');
- cy.get('[data-test="properties-modal-name-input"]').should(
- 'not.have.value',
- );
- cy.get('[data-test="properties-modal-cancel-button"]')
- .contains('Cancel')
- .click();
- });
-});
diff --git a/superset-frontend/cypress-base/cypress/integration/chart_list/chart_list.helper.ts b/superset-frontend/cypress-base/cypress/integration/chart_list/chart_list.helper.ts
deleted file mode 100644
index 0d66010cf4..0000000000
--- a/superset-frontend/cypress-base/cypress/integration/chart_list/chart_list.helper.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * 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.
- */
-export const CHART_LIST = '/chart/list/';
diff --git a/superset-frontend/cypress-base/cypress/integration/chart_list/chartlist.applitools.test.ts b/superset-frontend/cypress-base/cypress/integration/chart_list/chartlist.applitools.test.ts
index ddbbead4a2..045a8b809a 100644
--- a/superset-frontend/cypress-base/cypress/integration/chart_list/chartlist.applitools.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/chart_list/chartlist.applitools.test.ts
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { CHART_LIST } from './chart_list.helper';
+ import { CHART_LIST } from 'cypress/utils/urls';
describe('charts list view', () => {
beforeEach(() => {
diff --git a/superset-frontend/cypress-base/cypress/integration/chart_list/filter.test.ts b/superset-frontend/cypress-base/cypress/integration/chart_list/filter.test.ts
index 4466cc2ad5..c5308a87f9 100644
--- a/superset-frontend/cypress-base/cypress/integration/chart_list/filter.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/chart_list/filter.test.ts
@@ -16,119 +16,86 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { CHART_LIST } from './chart_list.helper';
+ import { CHART_LIST } from 'cypress/utils/urls';
+ import { setGridMode, clearAllInputs } from 'cypress/utils';
+ import { setFilter } from '../explore/utils';
-describe('chart card view filters', () => {
- beforeEach(() => {
+ describe('Charts filters', () => {
+ before(() => {
cy.login();
cy.visit(CHART_LIST);
- cy.get('[aria-label="card-view"]').click();
});
- it('should filter by owners correctly', () => {
- // filter by owners
- cy.get('[data-test="filters-select"]').first().click();
- cy.get('.rc-virtual-list').contains('alpha user').click();
- cy.get('[data-test="styled-card"]').should('not.exist');
- cy.get('[data-test="filters-select"]').first().click();
- cy.get('.rc-virtual-list').contains('gamma user').click();
- cy.get('[data-test="styled-card"]').should('not.exist');
+ beforeEach(() => {
+ cy.preserveLogin();
+ clearAllInputs();
});
- it('should filter by created by correctly', () => {
- // filter by created by
- cy.get('[data-test="filters-select"]').eq(1).click();
- cy.get('.rc-virtual-list').contains('alpha user').click();
- cy.get('.ant-card').should('not.exist');
- cy.get('[data-test="filters-select"]').eq(1).click();
- cy.get('.rc-virtual-list').contains('gamma user').click();
- cy.get('[data-test="styled-card"]').should('not.exist');
- });
+ describe('card-view', () => {
+ before(() => {
+ setGridMode('card');
+ });
- xit('should filter by viz type correctly', () => {
- // filter by viz type
- cy.get('[data-test="filters-select"]').eq(2).click();
- cy.get('.rc-virtual-list').contains('area').click({ timeout: 5000 });
- cy.get('[data-test="styled-card"]').its('length').should('be.gt', 0);
- cy.get('[data-test="styled-card"]')
- .contains("World's Pop Growth")
- .should('be.visible');
- cy.get('[data-test="filters-select"]').eq(2).click();
- cy.get('[data-test="filters-select"]').eq(2).type('world_map{enter}');
- cy.get('[data-test="styled-card"]').should('have.length', 1);
- cy.get('[data-test="styled-card"]')
- .contains('% Rural')
- .should('be.visible');
- });
+ it('should filter by owners correctly', () => {
+ setFilter('Owner', 'alpha user');
+ cy.getBySel('styled-card').should('not.exist');
+ setFilter('Owner', 'admin user');
+ cy.getBySel('styled-card').should('have.length', 20);
+ });
- it('should filter by datasource correctly', () => {
- // filter by datasource
- cy.get('[data-test="filters-select"]').eq(3).click();
- cy.get('.rc-virtual-list').contains('unicode_test').click();
- cy.get('[data-test="styled-card"]').should('have.length', 1);
- cy.get('[data-test="styled-card"]')
- .contains('Unicode Cloud')
- .should('be.visible');
- cy.get('[data-test="filters-select"]').eq(2).click();
- cy.get('[data-test="filters-select"]')
- .eq(2)
- .type('energy_usage{enter}{enter}');
- cy.get('[data-test="styled-card"]').its('length').should('be.gt', 0);
- });
-});
+ it('should filter by created by correctly', () => {
+ setFilter('Created by', 'alpha user');
+ cy.getBySel('styled-card').should('not.exist');
+ setFilter('Created by', 'admin user');
+ cy.getBySel('styled-card').should('have.length', 20);
+ });
-describe('chart list view filters', () => {
- beforeEach(() => {
- cy.login();
- cy.visit(CHART_LIST);
- cy.get('[aria-label="list-view"]').click();
- });
+ it('should filter by viz type correctly', () => {
+ setFilter('Chart type', 'Area Chart');
+ cy.getBySel('styled-card').should('have.length', 3);
+ setFilter('Chart type', 'Bubble Chart');
+ cy.getBySel('styled-card').should('have.length', 1);
+ });
- it('should filter by owners correctly', () => {
- // filter by owners
- cy.get('[data-test="filters-select"]').first().click();
- cy.get('.rc-virtual-list').contains('alpha user').click();
- cy.get('[data-test="table-row"]').should('not.exist');
- cy.get('[data-test="filters-select"]').first().click();
- cy.get('.rc-virtual-list').contains('gamma user').click();
- cy.get('[data-test="table-row"]').should('not.exist');
+ it('should filter by datasource correctly', () => {
+ setFilter('Dataset', 'energy_usage');
+ cy.getBySel('styled-card').should('have.length', 3);
+ setFilter('Dataset', 'unicode_test');
+ cy.getBySel('styled-card').should('have.length', 1);
+ });
});
- it('should filter by created by correctly', () => {
- // filter by created by
- cy.get('[data-test="filters-select"]').eq(1).click();
- cy.get('.rc-virtual-list').contains('alpha user').click();
- cy.get('[data-test="table-row"]').should('not.exist');
- cy.get('[data-test="filters-select"]').eq(1).click();
- cy.get('.rc-virtual-list').contains('gamma user').click();
- cy.get('[data-test="table-row"]').should('not.exist');
- });
+ describe('list-view', () => {
+ before(() => {
+ setGridMode('list');
+ });
- // this is flaky, but seems to fail along with the card view test of the same name
- xit('should filter by viz type correctly', () => {
- // filter by viz type
- cy.get('[data-test="filters-select"]').eq(2).click();
- cy.get('.rc-virtual-list').contains('area').click({ timeout: 5000 });
- cy.get('[data-test="table-row"]').its('length').should('be.gt', 0);
- cy.get('[data-test="table-row"]')
- .contains("World's Pop Growth")
- .should('exist');
- cy.get('[data-test="filters-select"]').eq(2).click();
- cy.get('[data-test="filters-select"]').eq(2).type('world_map{enter}');
- cy.get('[data-test="table-row"]').should('have.length', 1);
- cy.get('[data-test="table-row"]').contains('% Rural').should('exist');
- });
+ it('should filter by owners correctly', () => {
+ setFilter('Owner', 'alpha user');
+ cy.getBySel('table-row').should('not.exist');
+ setFilter('Owner', 'admin user');
+ cy.getBySel('table-row').should('have.length', 20);
+ });
+
+ it('should filter by created by correctly', () => {
+ setFilter('Created by', 'alpha user');
+ cy.getBySel('table-row').should('not.exist');
+ setFilter('Created by', 'admin user');
+ cy.getBySel('table-row').should('have.length', 20);
+ });
+
+ it('should filter by viz type correctly', () => {
+ setFilter('Chart type', 'Area Chart');
+ cy.getBySel('table-row').should('have.length', 3);
+ setFilter('Chart type', 'Bubble Chart');
+ cy.getBySel('table-row').should('have.length', 1);
+ });
- it('should filter by datasource correctly', () => {
- // filter by datasource
- cy.get('[data-test="filters-select"]').eq(3).click();
- cy.get('.rc-virtual-list').contains('unicode_test').click();
- cy.get('[data-test="table-row"]').should('have.length', 1);
- cy.get('[data-test="table-row"]').contains('Unicode Cloud').should('exist');
- cy.get('[data-test="filters-select"]').eq(3).click();
- cy.get('[data-test="filters-select"]')
- .eq(3)
- .type('energy_usage{enter}{enter}');
- cy.get('[data-test="table-row"]').its('length').should('be.gt', 0);
+ it('should filter by datasource correctly', () => {
+ setFilter('Dataset', 'energy_usage');
+ cy.getBySel('table-row').should('have.length', 3);
+ setFilter('Dataset', 'unicode_test');
+ cy.getBySel('table-row').should('have.length', 1);
+ });
});
-});
+});
\ No newline at end of file
diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts
index b97694ca09..d63478ca6b 100644
--- a/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts
@@ -57,7 +57,7 @@ import {
validateFilterNameOnDashboard,
} from './nativeFilter.helper';
import { DASHBOARD_LIST } from 'cypress/utils/urls';
-import { CHART_LIST } from '../chart_list/chart_list.helper';
+import { CHART_LIST } from 'cypress/utils/urls';
// TODO: fix flaky init logic and re-enable
const milliseconds = new Date().getTime();
diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard_list/filter.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard_list/filter.test.ts
index b2d7cf6e87..c33a8fe948 100644
--- a/superset-frontend/cypress-base/cypress/integration/dashboard_list/filter.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/dashboard_list/filter.test.ts
@@ -17,13 +17,9 @@
* under the License.
*/
import { DASHBOARD_LIST } from 'cypress/utils/urls';
-import { setGridMode } from 'cypress/utils';
+import { setGridMode, clearAllInputs } from 'cypress/utils';
import { setFilter } from '../dashboard/utils';
-function resetFilters() {
- cy.get('[aria-label="close-circle"]').click({ multiple: true, force: true });
-}
-
describe('Dashboards filters', () => {
before(() => {
cy.login();
@@ -32,7 +28,7 @@ describe('Dashboards filters', () => {
beforeEach(() => {
cy.preserveLogin();
- resetFilters();
+ clearAllInputs();
});
describe('card-view', () => {
@@ -58,7 +54,7 @@ describe('Dashboards filters', () => {
setFilter('Status', 'Published');
cy.getBySel('styled-card').should('have.length', 3);
setFilter('Status', 'Draft');
- cy.get('[data-test="styled-card"]').should('have.length', 2);
+ cy.getBySel('styled-card').should('have.length', 2);
});
});
diff --git a/superset-frontend/cypress-base/cypress/utils/index.ts b/superset-frontend/cypress-base/cypress/utils/index.ts
index 6c22829345..796f32a765 100644
--- a/superset-frontend/cypress-base/cypress/utils/index.ts
+++ b/superset-frontend/cypress-base/cypress/utils/index.ts
@@ -26,3 +26,7 @@ export function setGridMode(type: 'card' | 'list') {
export function toggleBulkSelect() {
cy.getBySel('bulk-select').click();
}
+
+export function clearAllInputs() {
+ cy.get('[aria-label="close-circle"]').click({ multiple: true, force: true });
+}
\ No newline at end of file