Skip to content

Commit

Permalink
try just waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian committed May 6, 2020
1 parent 457f275 commit 10c092e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,9 @@ export default () =>
filterId = dashboard.slices.find(
slice => slice.form_data.viz_type === 'filter_box',
).slice_id;
aliases = sliceIds.map(id => {
const alias = getAlias(id);
const url = `/superset/explore_json/?*{"slice_id":${id}}*`;
cy.route('POST', url).as(alias.slice(1));
return alias;
});

// wait the initial page load requests
cy.wait(aliases);
cy.wait(10000);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { WORLD_HEALTH_DASHBOARD } from './dashboard.helper';

export default () =>
describe('load', () => {
const aliases = [];

beforeEach(() => {
cy.server();
cy.login();
Expand All @@ -33,18 +31,12 @@ export default () =>
const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
const slices = bootstrapData.dashboard_data.slices;
// then define routes and create alias for each requests
slices.forEach(slice => {
const alias = `getJson_${slice.slice_id}`;
const formData = `{"slice_id":${slice.slice_id}}`;
cy.route('POST', `/superset/explore_json/?*${formData}*`).as(alias);
aliases.push(`@${alias}`);
});
});
});

it('should load dashboard', () => {
// wait and verify one-by-one
cy.wait(aliases).then(requests => {
cy.wait(10000).then(requests => {
return Promise.all(
requests.map(async xhr => {
expect(xhr.status).to.eq(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,7 @@ export default () =>
});

it('should apply url params to slice requests', () => {
const aliases = [];
sliceIds.forEach(id => {
const alias = `getJson_${id}`;
aliases.push(`@${alias}`);
cy.route(
'POST',
`/superset/explore_json/?form_data={"slice_id":${id}}&dashboard_id=${dashboardId}`,
).as(alias);
});

cy.wait(aliases).then(requests => {
cy.wait(10000).then(requests => {
requests.forEach(xhr => {
const requestFormData = xhr.request.body;
const requestParams = JSON.parse(requestFormData.get('form_data'));
Expand Down

0 comments on commit 10c092e

Please sign in to comment.