Skip to content

Commit

Permalink
chore(explore): Get Explore data from endpoint instead of bootstrap_d…
Browse files Browse the repository at this point in the history
…ata (#20519)

* feat(explore): Use v1/explore endpoint data instead of bootstrapData

* Add tests

* Fix ci

* Remove redundant dependency

* Use form_data_key in cypress tests

* Add auth headers to for data request

* Address comments

* Remove displaying danger toast

* Conditionally add auth headers

* Address comments

* Fix typing bug

* fix

* Fix opening dataset

* Fix sqllab chart create

* Run queries in parallel

* Fix dashboard id autofill

* Fix lint

* Fix test
  • Loading branch information
kgabryje authored Jun 30, 2022
1 parent f2af81b commit b30f6a5
Show file tree
Hide file tree
Showing 55 changed files with 845 additions and 327 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('No Results', () => {
],
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.wait('@getJson').its('response.statusCode').should('eq', 200);
cy.get('div.chart-container').contains(
'No results were returned for this query',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Time range filter', () => {
metrics: [NUM_METRIC],
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@chartData' });

cy.get('[data-test=time-range-trigger]')
Expand All @@ -172,7 +172,7 @@ describe('Time range filter', () => {
time_range: 'Last year',
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@chartData' });

cy.get('[data-test=time-range-trigger]')
Expand All @@ -192,7 +192,7 @@ describe('Time range filter', () => {
time_range: 'previous calendar month',
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@chartData' });

cy.get('[data-test=time-range-trigger]')
Expand All @@ -212,7 +212,7 @@ describe('Time range filter', () => {
time_range: 'DATEADD(DATETIME("today"), -7, day) : today',
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@chartData' });

cy.get('[data-test=time-range-trigger]')
Expand All @@ -235,7 +235,7 @@ describe('Time range filter', () => {
time_range: 'No filter',
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@chartData' });

cy.get('[data-test=time-range-trigger]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('explore view', () => {
it('should load Explore', () => {
const LINE_CHART_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'line' };
const formData = { ...LINE_CHART_DEFAULTS, metrics: [NUM_METRIC] };
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
cy.eyesOpen({
testName: 'Explore page',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Edit FilterBox Chart', () => {
const VIZ_DEFAULTS = { ...FORM_DATA_DEFAULTS, viz_type: 'filter_box' };

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Test explore links', () => {
};
const newChartName = `Test chart [${shortid.generate()}]`;

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@tableChartData' });
cy.url().then(() => {
cy.get('[data-test="query-save-button"]').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Visualization > Area', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
}

Expand All @@ -75,23 +75,21 @@ describe('Visualization > Area', () => {
});

it('should work with groupby and filter', () => {
cy.visitChartByParams(
JSON.stringify({
...AREA_FORM_DATA,
groupby: ['region'],
adhoc_filters: [
{
expressionType: 'SIMPLE',
subject: 'region',
operator: 'IN',
comparator: ['South Asia', 'North America'],
clause: 'WHERE',
sqlExpression: null,
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
},
],
}),
);
cy.visitChartByParams({
...AREA_FORM_DATA,
groupby: ['region'],
adhoc_filters: [
{
expressionType: 'SIMPLE',
subject: 'region',
operator: 'IN',
comparator: ['South Asia', 'North America'],
clause: 'WHERE',
sqlExpression: null,
filterOptionName: 'filter_txje2ikiv6_wxmn0qwd1xo',
},
],
});

cy.wait('@getJson').then(async ({ response }) => {
const responseBody = response?.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ describe('Visualization > Big Number with Trendline', () => {
slice_id: 42,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '2000+:+2014-01-02',
time_range: '2000 : 2014-01-02',
metric: 'sum__SP_POP_TOTL',
adhoc_filters: [],
compare_lag: '10',
compare_suffix: 'over+10Y',
compare_suffix: 'over 10Y',
y_axis_format: '.3s',
show_trend_line: true,
start_y_axis_at_zero: true,
Expand All @@ -42,7 +42,7 @@ describe('Visualization > Big Number with Trendline', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({
waitAlias: '@chartData',
chartSelector: '.superset-legacy-chart-big-number',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Visualization > Box Plot', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Visualization > Bubble', () => {
slice_id: 46,
granularity_sqla: 'year',
time_grain_sqla: 'P1D',
time_range: '2011-01-01+:+2011-01-02',
time_range: '2011-01-01 : 2011-01-02',
series: 'region',
entity: 'country_name',
x: 'sum__SP_RUR_TOTL_ZS',
Expand All @@ -47,7 +47,7 @@ describe('Visualization > Bubble', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
}

Expand All @@ -60,7 +60,7 @@ describe('Visualization > Bubble', () => {
// Since main functionality is already covered in filter test below,
// skip this test until we find a solution.
it.skip('should work', () => {
cy.visitChartByParams(JSON.stringify(BUBBLE_FORM_DATA)).then(() => {
cy.visitChartByParams(BUBBLE_FORM_DATA).then(() => {
cy.wait('@getJson').then(xhr => {
let expectedBubblesNumber = 0;
xhr.responseBody.data.forEach(element => {
Expand All @@ -86,7 +86,7 @@ describe('Visualization > Bubble', () => {
expressionType: 'SIMPLE',
subject: 'region',
operator: '==',
comparator: 'South+Asia',
comparator: 'South Asia',
clause: 'WHERE',
sqlExpression: null,
filterOptionName: 'filter_b2tfg1rs8y_8kmrcyxvsqd',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Visualization > Compare', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Visualization > Distribution bar chart', () => {
groupby: ['state'],
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({
waitAlias: '@getJson',
querySubstring: NUM_METRIC.label,
Expand All @@ -49,7 +49,7 @@ describe('Visualization > Distribution bar chart', () => {
columns: ['gender'],
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
});

Expand All @@ -61,7 +61,7 @@ describe('Visualization > Distribution bar chart', () => {
row_limit: 10,
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
});

Expand All @@ -74,7 +74,7 @@ describe('Visualization > Distribution bar chart', () => {
contribution: true,
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Download Chart > Distribution bar chart', () => {
groupby: ['state'],
};

cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.get('.header-with-actions .ant-dropdown-trigger').click();
cy.get(':nth-child(1) > .ant-dropdown-menu-submenu-title').click();
cy.get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Visualization > Dual Line', () => {
slice_id: 58,
granularity_sqla: 'ds',
time_grain_sqla: 'P1D',
time_range: '100+years+ago+:+now',
time_range: '100 years ago : now',
color_scheme: 'bnbColors',
x_axis_format: 'smart_date',
metric: 'sum__num',
Expand All @@ -35,7 +35,7 @@ describe('Visualization > Dual Line', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Visualization > Gauge', () => {
};

function verify(formData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Visualization > Graph', () => {
function verify(formData: {
[name: string]: string | boolean | number | Array<adhocFilter>;
}): void {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson' });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Visualization > Histogram', () => {
};

function verify(formData: QueryFormData) {
cy.visitChartByParams(JSON.stringify(formData));
cy.visitChartByParams(formData);
cy.verifySliceSuccess({ waitAlias: '@getJson', chartSelector: 'svg' });
}

Expand Down
Loading

0 comments on commit b30f6a5

Please sign in to comment.