kristw closed pull request #5957: [cypress] Update dashboard test to remove 10s
timeout
URL: https://github.com/apache/incubator-superset/pull/5957
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/cypress/integration/dashboard/dashboard_tests.js
b/superset/assets/cypress/integration/dashboard/dashboard_tests.js
index 31ce704455..ed2ac0851b 100644
--- a/superset/assets/cypress/integration/dashboard/dashboard_tests.js
+++ b/superset/assets/cypress/integration/dashboard/dashboard_tests.js
@@ -2,24 +2,28 @@ describe('Load dashboard', () => {
it('Load birth names dashboard', () => {
cy.server();
cy.login();
-
+ // go to the dashboard and get list of slices first
cy.visit('/superset/dashboard/births');
-
- cy.route('POST', '/superset/explore_json/**').as('getJson');
- cy.wait(10000, ['@getJson']);
-
- let sliceData;
-
- cy.get('@getJson.all').then((xhrs) => {
- sliceData = xhrs;
- xhrs.forEach((data) => {
- expect(data.status).to.eq(200);
- expect(data.response.body).to.have.property('error', null);
- cy.get(`#slice-container-${data.response.body.form_data.slice_id}`);
+ cy.get('#app').then((data) => {
+ const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
+ const slices = bootstrapData.dashboard_data.slices;
+ // then define routes and create alias for each requests
+ const aliases = slices.map((slice) => {
+ const alias = `getJson_${slice.slice_id}`;
+ cy.route('POST',
`/superset/explore_json/?form_data={"slice_id":${slice.slice_id}}`).as(alias);
+ return `@${alias}`;
});
- cy.get('#app').then((data) => {
- const bootstrapData = JSON.parse(data[0].dataset.bootstrap);
-
expect(bootstrapData.dashboard_data.slices.length).to.eq(sliceData.length);
+ // reload the dashboard again with all routes watched.
+ cy.visit('/superset/dashboard/births');
+ // wait for all requests to complete
+ cy.wait(aliases);
+ // verify one-by-one
+ aliases.forEach((alias) => {
+ cy.get(alias).then((xhr) => {
+ expect(xhr.status).to.eq(200);
+ expect(xhr.response.body).to.have.property('error', null);
+ cy.get(`#slice-container-${xhr.response.body.form_data.slice_id}`);
+ });
});
});
});
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]