Skip to content

Commit

Permalink
Move util functions to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed Apr 28, 2023
1 parent e5d64ce commit 4fb0643
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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']",
Expand All @@ -59,7 +52,7 @@ const openTableContextMenu = (

const drillBy = (targetDrillByColumn: string, isLegacy = false) => {
if (isLegacy) {
interceptLegacyChartData();
interceptExploreJson('legacyData');
} else {
interceptV1ChartData();
}
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/cypress-base/cypress/e2e/dashboard/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
14 changes: 9 additions & 5 deletions superset-frontend/cypress-base/cypress/e2e/explore/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 4fb0643

Please sign in to comment.