diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts index cc544a6a81632..c365f66b4a463 100644 --- a/superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts +++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/drillby.test.ts @@ -20,19 +20,16 @@ import { Interception } from 'cypress/types/net-stubbing'; import { waitForChartLoad } from 'cypress/utils'; import { SUPPORTED_CHARTS_DASHBOARD } from 'cypress/utils/urls'; -import { SUPPORTED_TIER1_CHARTS, SUPPORTED_TIER2_CHARTS } from './utils'; - -const interceptV1ChartData = (alias = 'v1Data') => { - cy.intercept('/api/v1/chart/data*').as(alias); -}; - -const interceptLegacyChartData = () => { - cy.intercept('/superset/explore_json*').as('legacyData'); -}; - -const interceptFormDataKey = () => { - cy.intercept('/api/v1/explore/form_data').as('formDataKey'); -}; +import { + openTopLevelTab, + SUPPORTED_TIER1_CHARTS, + SUPPORTED_TIER2_CHARTS, +} from './utils'; +import { + interceptExploreJson, + interceptV1ChartData, + interceptFormDataKey, +} from '../explore/utils'; const closeModal = () => { cy.get('body').then($body => { @@ -42,10 +39,6 @@ const closeModal = () => { }); }; -const setTopLevelTab = (tabName: string) => { - cy.get("div#TABS-TOP div[role='tab']").contains(tabName).click(); -}; - const openTableContextMenu = ( cellContent: string, tableSelector = "[data-test-viz-type='table']", @@ -59,7 +52,7 @@ const openTableContextMenu = ( const drillBy = (targetDrillByColumn: string, isLegacy = false) => { if (isLegacy) { - interceptLegacyChartData(); + interceptExploreJson('legacyData'); } else { interceptV1ChartData(); } @@ -236,7 +229,7 @@ describe('Drill by modal', () => { describe('Modal actions + Table', () => { before(() => { closeModal(); - setTopLevelTab('Tier 1'); + openTopLevelTab('Tier 1'); SUPPORTED_TIER1_CHARTS.forEach(waitForChartLoad); }); @@ -384,7 +377,7 @@ describe('Drill by modal', () => { describe('Tier 1 charts', () => { before(() => { closeModal(); - setTopLevelTab('Tier 1'); + openTopLevelTab('Tier 1'); SUPPORTED_TIER1_CHARTS.forEach(waitForChartLoad); }); @@ -547,7 +540,7 @@ describe('Drill by modal', () => { describe('Tier 2 charts', () => { before(() => { closeModal(); - setTopLevelTab('Tier 2'); + openTopLevelTab('Tier 2'); SUPPORTED_TIER2_CHARTS.forEach(waitForChartLoad); }); @@ -612,7 +605,7 @@ describe('Drill by modal', () => { ]); }); - it.only('Mixed Chart', () => { + it('Mixed Chart', () => { cy.get('[data-test-viz-type="mixed_timeseries"] canvas').then($canvas => { // click 'boy' cy.wrap($canvas) diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts index 2ab4966d57d08..ff1872333bc87 100644 --- a/superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts +++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/drilltodetail.test.ts @@ -18,7 +18,11 @@ */ import { waitForChartLoad } from 'cypress/utils'; import { SUPPORTED_CHARTS_DASHBOARD } from 'cypress/utils/urls'; -import { SUPPORTED_TIER1_CHARTS, SUPPORTED_TIER2_CHARTS } from './utils'; +import { + openTopLevelTab, + SUPPORTED_TIER1_CHARTS, + SUPPORTED_TIER2_CHARTS, +} from './utils'; function interceptSamples() { cy.intercept(`/datasource/samples*`).as('samples'); @@ -77,10 +81,6 @@ function closeModal() { }); } -function setTopLevelTab(tabName: string) { - cy.get("div#TABS-TOP div[role='tab']").contains(tabName).click(); -} - function testTimeChart(vizType: string) { interceptSamples(); @@ -139,7 +139,7 @@ describe('Drill to detail modal', () => { describe('Tier 1 charts', () => { before(() => { cy.visit(SUPPORTED_CHARTS_DASHBOARD); - setTopLevelTab('Tier 1'); + openTopLevelTab('Tier 1'); SUPPORTED_TIER1_CHARTS.forEach(waitForChartLoad); }); @@ -438,7 +438,7 @@ describe('Drill to detail modal', () => { describe('Tier 2 charts', () => { before(() => { cy.visit(SUPPORTED_CHARTS_DASHBOARD); - setTopLevelTab('Tier 2'); + openTopLevelTab('Tier 2'); SUPPORTED_TIER2_CHARTS.forEach(waitForChartLoad); }); diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/utils.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/utils.ts index 05c9c154b46d2..159e9368eccba 100644 --- a/superset-frontend/cypress-base/cypress/e2e/dashboard/utils.ts +++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/utils.ts @@ -529,3 +529,7 @@ export function openTab(tabComponentIndex: number, tabIndex: number) { .eq(tabIndex) .click(); } + +export const openTopLevelTab = (tabName: string) => { + cy.get("div#TABS-TOP div[role='tab']").contains(tabName).click(); +}; diff --git a/superset-frontend/cypress-base/cypress/e2e/explore/utils.ts b/superset-frontend/cypress-base/cypress/e2e/explore/utils.ts index 0a1dc50faa036..95af89db5fb51 100644 --- a/superset-frontend/cypress-base/cypress/e2e/explore/utils.ts +++ b/superset-frontend/cypress-base/cypress/e2e/explore/utils.ts @@ -35,14 +35,18 @@ export function interceptUpdate() { cy.intercept('PUT', `/api/v1/chart/*`).as('update'); } -export function interceptPost() { - cy.intercept('POST', `/api/v1/chart/`).as('post'); -} +export const interceptV1ChartData = (alias = 'v1Data') => { + cy.intercept('/api/v1/chart/data*').as(alias); +}; -export function interceptExploreJson() { - cy.intercept('POST', `/superset/explore_json/**`).as('getJson'); +export function interceptExploreJson(alias = 'getJson') { + cy.intercept('POST', `/superset/explore_json/**`).as(alias); } +export const interceptFormDataKey = () => { + cy.intercept('POST', '/api/v1/explore/form_data').as('formDataKey'); +}; + export function interceptExploreGet() { cy.intercept({ method: 'GET',