This is an automated email from the ASF dual-hosted git repository. diegopucci pushed a commit to branch chore/e2e-cross-references in repository https://gitbox.apache.org/repos/asf/superset.git
commit b65ec846dca549b5aee31929da7f75eff8b7eb40 Author: geido <[email protected]> AuthorDate: Thu Oct 13 18:07:19 2022 +0300 Enhance samples --- .../cypress-base/cypress/fixtures/charts.json | 15 +++--- .../cypress/integration/chart_list/list.test.ts | 2 +- .../cypress/integration/dashboard/actions.test.js | 2 +- .../cypress/integration/dashboard/editmode.test.ts | 8 ++-- .../integration/dashboard/nativeFilters.test.ts | 6 +-- .../integration/dashboard_list/list.test.ts | 2 +- .../cypress/integration/explore/chart.test.js | 55 +++++++++++++++++++++- 7 files changed, 73 insertions(+), 17 deletions(-) diff --git a/superset-frontend/cypress-base/cypress/fixtures/charts.json b/superset-frontend/cypress-base/cypress/fixtures/charts.json index 600e081024..5781fce81e 100644 --- a/superset-frontend/cypress-base/cypress/fixtures/charts.json +++ b/superset-frontend/cypress-base/cypress/fixtures/charts.json @@ -5,8 +5,9 @@ "owners": [1], "viz_type": "line", "cache_timeout": 1000, - "datasource_id": 1, - "datasource_type": "table" + "datasource_id": 2, + "datasource_type": "table", + "params": "{\"viz_type\":\"line\",\"metrics\":[\"count\"]}" }, { "slice_name": "2 - Sample chart", @@ -14,8 +15,9 @@ "owners": [1], "viz_type": "line", "cache_timeout": 1000, - "datasource_id": 1, - "datasource_type": "table" + "datasource_id": 2, + "datasource_type": "table", + "params": "{\"viz_type\":\"line\",\"metrics\":[\"count\"]}" }, { "slice_name": "3 - Sample chart", @@ -23,8 +25,9 @@ "owners": [1], "viz_type": "line", "cache_timeout": 1000, - "datasource_id": 1, - "datasource_type": "table" + "datasource_id": 2, + "datasource_type": "table", + "params": "{\"viz_type\":\"line\",\"metrics\":[\"count\"]}" }, { "slice_name": "4 - Sample chart", diff --git a/superset-frontend/cypress-base/cypress/integration/chart_list/list.test.ts b/superset-frontend/cypress-base/cypress/integration/chart_list/list.test.ts index e3837445d9..41d043a988 100644 --- a/superset-frontend/cypress-base/cypress/integration/chart_list/list.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/chart_list/list.test.ts @@ -125,7 +125,7 @@ describe('Charts list', () => { describe('common actions', () => { beforeEach(() => { - cy.createSampleCharts(); + cy.createSampleCharts([0, 1, 2, 3]); cy.visit(CHART_LIST); }); diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/actions.test.js b/superset-frontend/cypress-base/cypress/integration/dashboard/actions.test.js index de7c412934..8d520d9729 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/actions.test.js +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/actions.test.js @@ -21,7 +21,7 @@ import { interceptFav, interceptUnfav } from './utils'; describe('Dashboard actions', () => { beforeEach(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); cy.visit(SAMPLE_DASHBOARD_1); }); diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/editmode.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/editmode.test.ts index f072bc8f54..97baa521f1 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/editmode.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/editmode.test.ts @@ -129,7 +129,7 @@ describe('Dashboard edit', () => { describe('Edit properties', () => { before(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); visitEdit(); }); @@ -181,7 +181,7 @@ describe('Dashboard edit', () => { describe('Edit mode', () => { before(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); visitEdit(); }); @@ -218,7 +218,7 @@ describe('Dashboard edit', () => { describe('Components', () => { before(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); }); beforeEach(() => { @@ -268,7 +268,7 @@ describe('Dashboard edit', () => { describe('Color schemes', () => { beforeEach(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); visitEdit(); }); 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 184ac86139..3f643cc32e 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts @@ -196,7 +196,7 @@ describe('Native filters', () => { describe('Nativefilters tests initial state required', () => { beforeEach(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); }); it('Verify that default value is respected after revisit', () => { @@ -379,7 +379,7 @@ describe('Native filters', () => { describe('Nativefilters basic interactions', () => { before(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); visitDashboard(); }); @@ -437,7 +437,7 @@ describe('Native filters', () => { describe('Nativefilters initial state not required', () => { beforeEach(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0]); }); it("User can check 'Filter has default value'", () => { diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard_list/list.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard_list/list.test.ts index c25b11e7b3..aeee9ba499 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard_list/list.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard_list/list.test.ts @@ -127,7 +127,7 @@ describe('Dashboards list', () => { describe('common actions', () => { beforeEach(() => { - cy.createSampleDashboards(); + cy.createSampleDashboards([0, 1, 2, 3]); cy.visit(DASHBOARD_LIST); }); diff --git a/superset-frontend/cypress-base/cypress/integration/explore/chart.test.js b/superset-frontend/cypress-base/cypress/integration/explore/chart.test.js index ac3f3ddcb0..dc185b790d 100644 --- a/superset-frontend/cypress-base/cypress/integration/explore/chart.test.js +++ b/superset-frontend/cypress-base/cypress/integration/explore/chart.test.js @@ -25,6 +25,34 @@ function visitSampleChart(id) { cy.intercept('POST', '/superset/explore_json/**').as('getJson'); } +function selectDashboard(dashboardName) { + cy.get( + '[data-test="save-chart-modal-select-dashboard-form"] [aria-label="Select a dashboard"]', + ) + .first() + .click(); + cy.get(`.ant-select-item-option[title="${dashboardName}"]`).click(); +} + +function saveToDashboard(dashboardName) { + cy.getBySel("query-save-button").click(); + selectDashboard(dashboardName); + cy.getBySel("btn-modal-save").click(); +} + +function openDashboardsAddedTo() { + cy.getBySel("actions-trigger").click(); + cy.get(".ant-dropdown-menu-submenu-title").first().trigger("mouseover"); +} + +function verifySubmenuItem(itemName) { + cy.get(".ant-dropdown-menu-submenu-popup").contains(itemName).trigger("mouseout"); +} + +function verifyMetabar(text) { + cy.getBySel("metadata-bar").contains(text); +} + describe('Cross-referenced dashboards', () => { beforeEach(() => { interceptFiltering(); @@ -35,12 +63,37 @@ describe('Cross-referenced dashboards', () => { }); before(() => { + cy.createSampleDashboards(); cy.createSampleCharts(); }); - it('Shows the "Added to {x} dashboard(s)', () => { + it('Shows the cross referenced dashboards', () => { visitSampleChart(4); + cy.getBySel("metadata-bar").contains("Not added to any dashboard"); + openDashboardsAddedTo(); + verifySubmenuItem("None"); + + saveToDashboard("1 - Sample dashboard"); + verifyMetabar("Added to 1 dashboard(s)"); + openDashboardsAddedTo(); + verifySubmenuItem("1 - Sample dashboard"); + + saveToDashboard("2 - Sample dashboard"); + verifyMetabar("Added to 2 dashboard(s)"); + openDashboardsAddedTo(); + verifySubmenuItem("2 - Sample dashboard"); + + saveToDashboard("3 - Sample dashboard"); + verifyMetabar("Added to 3 dashboard(s)"); + openDashboardsAddedTo(); + verifySubmenuItem("3 - Sample dashboard"); + + saveToDashboard("4 - Sample dashboard"); + verifyMetabar("Added to 4 dashboard(s)"); + openDashboardsAddedTo(); + verifySubmenuItem("4 - Sample dashboard"); + }); });
