You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by su...@apache.org on 2021/03/24 19:20:44 UTC

[superset] branch behavior-driven-cypress updated: remove bootstrap usage from the filter test

This is an automated email from the ASF dual-hosted git repository.

suddjian pushed a commit to branch behavior-driven-cypress
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/behavior-driven-cypress by this push:
     new 9f87846  remove bootstrap usage from the filter test
9f87846 is described below

commit 9f87846db7e73a9987b40c9d4570acb5340a3f70
Author: David Aaron Suddjian <aa...@gmail.com>
AuthorDate: Wed Mar 24 12:19:30 2021 -0700

    remove bootstrap usage from the filter test
---
 .../cypress/integration/dashboard/filter.test.ts   | 130 ++++++++-------------
 1 file changed, 50 insertions(+), 80 deletions(-)

diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/filter.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/filter.test.ts
index dd378f1..b84d97d 100644
--- a/superset-frontend/cypress-base/cypress/integration/dashboard/filter.test.ts
+++ b/superset-frontend/cypress-base/cypress/integration/dashboard/filter.test.ts
@@ -16,97 +16,67 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { isLegacyResponse, parsePostForm } from 'cypress/utils';
 import {
+  WORLD_HEALTH_CHARTS,
+  WORLD_HEALTH_DASHBOARD,
   getChartAliases,
-  DASHBOARD_CHART_ALIAS_PREFIX,
-  isLegacyResponse,
-  parsePostForm,
-} from 'cypress/utils';
-import { WORLD_HEALTH_DASHBOARD } from './dashboard.helper';
-
-interface Slice {
-  slice_id: number;
-  form_data: {
-    viz_type: string;
-    [key: string]: JSONValue;
-  };
-}
-
-interface DashboardData {
-  slices: Slice[];
-}
+} from './dashboard.helper';
 
 describe('Dashboard filter', () => {
-  let filterId: number;
-  let aliases: string[];
-
-  const getAlias = (id: number) => `@${DASHBOARD_CHART_ALIAS_PREFIX}${id}`;
-
-  beforeEach(() => {
+  before(() => {
     cy.login();
-
     cy.visit(WORLD_HEALTH_DASHBOARD);
-
-    cy.get('#app').then(app => {
-      const bootstrapData = app.data('bootstrap');
-      const dashboard = bootstrapData.dashboard_data as DashboardData;
-      const { slices } = dashboard;
-      filterId =
-        dashboard.slices.find(
-          slice => slice.form_data.viz_type === 'filter_box',
-        )?.slice_id || 0;
-
-      aliases = getChartAliases(slices);
-
-      // wait the initial page load requests
-      cy.wait(aliases);
-    });
   });
 
   it('should apply filter', () => {
-    cy.get('.Select__placeholder:first').click();
-
-    // should show the filter indicator
-    cy.get('svg[data-test="filter"]:visible').should(nodes => {
-      expect(nodes.length).to.least(9);
-    });
-
-    cy.get('.Select__control:first input[type=text]').type('So', {
-      force: true,
-      delay: 100,
+    getChartAliases(
+      WORLD_HEALTH_CHARTS.filter(({ viz }) => viz !== 'filter_box'),
+    ).then(nonFilterChartAliases => {
+      cy.get('.Select__placeholder:first').click();
+
+      // should show the filter indicator
+      cy.get('svg[data-test="filter"]:visible').should(nodes => {
+        expect(nodes.length).to.least(9);
+      });
+
+      cy.get('.Select__control:first input[type=text]').type('So', {
+        force: true,
+        delay: 100,
+      });
+
+      cy.get('.Select__menu').first().contains('South Asia').click();
+
+      // should still have all filter indicators
+      cy.get('svg[data-test="filter"]:visible').should(nodes => {
+        expect(nodes.length).to.least(9);
+      });
+
+      cy.get('.filter_box button').click({ force: true });
+      cy.wait(nonFilterChartAliases).then(requests =>
+        Promise.all(
+          requests.map(async ({ response, request }) => {
+            const responseBody = response?.body;
+            let requestFilter;
+            if (isLegacyResponse(responseBody)) {
+              const requestFormData = parsePostForm(request.body);
+              const requestParams = JSON.parse(
+                requestFormData.form_data as string,
+              );
+              requestFilter = requestParams.extra_filters[0];
+            } else {
+              requestFilter = request.body.queries[0].filters[0];
+            }
+            expect(requestFilter).deep.eq({
+              col: 'region',
+              op: '==',
+              val: 'South Asia',
+            });
+          }),
+        ),
+      );
     });
 
-    cy.get('.Select__menu').first().contains('South Asia').click();
-
-    // should still have all filter indicators
-    cy.get('svg[data-test="filter"]:visible').should(nodes => {
-      expect(nodes.length).to.least(9);
-    });
-
-    cy.get('.filter_box button').click({ force: true });
-    cy.wait(aliases.filter(x => x !== getAlias(filterId))).then(requests =>
-      Promise.all(
-        requests.map(async ({ response, request }) => {
-          const responseBody = response?.body;
-          let requestFilter;
-          if (isLegacyResponse(responseBody)) {
-            const requestFormData = parsePostForm(request.body);
-            const requestParams = JSON.parse(
-              requestFormData.form_data as string,
-            );
-            requestFilter = requestParams.extra_filters[0];
-          } else {
-            requestFilter = request.body.queries[0].filters[0];
-          }
-          expect(requestFilter).deep.eq({
-            col: 'region',
-            op: '==',
-            val: 'South Asia',
-          });
-        }),
-      ),
-    );
-
     // TODO add test with South Asia{enter} type action to select filter
   });
 });