villebro commented on a change in pull request #11685:
URL:
https://github.com/apache/incubator-superset/pull/11685#discussion_r522997410
##########
File path: superset-frontend/cypress-base/cypress/utils/vizPlugins.ts
##########
@@ -21,3 +21,26 @@ const V1_PLUGINS = ['box_plot', 'echarts_timeseries',
'word_cloud', 'pie'];
export function isLegacyChart(vizType: string): boolean {
return !V1_PLUGINS.includes(vizType);
}
+
+export function getChartAliases(slices: any[]): string[] {
+ const aliases: string[] = [];
+ console.log(slices);
+ Array.from(slices).forEach(slice => {
+ const vizType = slice.form_data.viz_type;
+ const isLegacy = isLegacyChart(vizType);
+ if (isLegacy) {
+ const alias = `getJson_${slice.slice_id}`;
+ const formData = `{"slice_id":${slice.slice_id}}`;
+ const route = `/superset/explore_json/?*${formData}*`;
+ cy.route('POST', `${route}`).as(alias);
+ aliases.push(`@${alias}`);
+ } else {
+ const alias = `getJson_v1_${slice.slice_id}`;
+ const route = `/api/v1/chart/data?*`;
+ cy.route('POST', `${route}`).as(alias);
+ aliases.push(`@${alias}`);
+ }
+ });
+ console.log(aliases);
+ return aliases;
+}
Review comment:
You can probably simplify this slightly by doing something similar to
this:
```suggestion
export function getChartAliases(slices: any[]): string[] {
return slices.map(slice => {
const vizType = slice.form_data.viz_type;
const isLegacy = isLegacyChart(vizType);
if (isLegacy) {
const alias = `getJson_${slice.slice_id}`;
const formData = `{"slice_id":${slice.slice_id}}`;
const route = `/superset/explore_json/?*${formData}*`;
cy.route('POST', `${route}`).as(alias);
return `@${alias}`;
} else {
const alias = `getJson_v1_${slice.slice_id}`;
const route = `/api/v1/chart/data?*`;
cy.route('POST', `${route}`).as(alias);
return `@${alias}`;
}
});
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]