You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/04/26 03:56:14 UTC

[GitHub] [superset] jinghua-qa commented on a diff in pull request #19821: test(native filter): refactor and add new test

jinghua-qa commented on code in PR #19821:
URL: https://github.com/apache/superset/pull/19821#discussion_r858245519


##########
superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts:
##########
@@ -602,12 +332,314 @@ describe('Nativefilters Sanity test', () => {
       .invoke('text')
       .should('equal', '214 options', { timeout: 20000 });
     // apply first filter value and validate 2nd filter is depden on 1st filter.
-    applyNativeFilterValueWithIndex(0, 'East Asia & Pacific');
-
-    getNativeFilterPlaceholderWithIndex(0).should('have.text', '36 options', {
+    applyNativeFilterValueWithIndex(0, 'North America');
+    getNativeFilterPlaceholderWithIndex(0).should('have.text', '3 options', {
       timeout: 20000,
     });
   });
+
+  it('User can apply value filter with selected values', () => {
+    expandFilterOnLeftPanel();
+    enterNativeFilterEditModal();
+    fillNativeFilterForm(
+      testItems.filterType.value,
+      testItems.topTenChart.filterColumn,
+      testItems.datasetForNativeFilter,
+      testItems.topTenChart.filterColumn,
+    );
+    saveNativeFilterSettings();
+    WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
+    applyNativeFilterValueWithIndex(0, testItems.filterDefaultValue);
+    cy.get(nativeFilters.applyFilter).click();
+    cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
+      cy.contains(testItems.filterDefaultValue).should('be.visible');
+      cy.contains(testItems.filterOtherCountry).should('not.exist');
+    });
+  });
+
+  it('User can create a numerical range filter', () => {
+    expandFilterOnLeftPanel();
+    enterNativeFilterEditModal();
+    fillNativeFilterForm(
+      testItems.filterType.numerical,
+      testItems.filterNumericalColumn,
+      testItems.datasetForNativeFilter,
+      testItems.filterNumericalColumn,
+    );
+    saveNativeFilterSettings();
+    // assertions
+    cy.get(nativeFilters.slider.slider).should('be.visible').click('center');
+    // cy.get(sqlLabView.tooltip).should('be.visible');
+    cy.intercept(`/superset/explore_json/*`).as('slices');
+    cy.get(nativeFilters.applyFilter).click();
+    cy.wait('@slices');
+    // assert that the url contains 'native_filters' in the url
+    cy.url().then(u => {
+      const ur = new URL(u);
+      expect(ur.search).to.include('native_filters');
+      // assert that the start handle has a value
+      cy.get(nativeFilters.slider.startHandle)
+        .invoke('attr', 'aria-valuenow')
+        .should('exist');
+      // assert that the end handle has a value
+      cy.get(nativeFilters.slider.endHandle)
+        .invoke('attr', 'aria-valuenow')
+        .should('exist');
+      // assert slider text matches what we should have
+      cy.get(nativeFilters.slider.sliderText).should('have.text', '49');
+    });
+  });
+
+  it('Verify that default value is respected after revisit', () => {
+    expandFilterOnLeftPanel();
+    enterNativeFilterEditModal();
+    fillNativeFilterForm(
+      testItems.filterType.value,
+      testItems.topTenChart.filterColumn,
+      testItems.datasetForNativeFilter,
+      testItems.topTenChart.filterColumn,
+    );
+    inputNativeFilterDefaultValue(testItems.filterDefaultValue);
+    saveNativeFilterSettings();
+    WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
+    cy.get(nativeFilters.filterItem)
+      .contains(testItems.filterDefaultValue)
+      .should('be.visible');
+    cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
+      cy.contains(testItems.filterDefaultValue).should('be.visible');
+      cy.contains(testItems.filterOtherCountry).should('not.exist');
+    });
+    cy.request(
+      'api/v1/dashboard/?q=(order_column:changed_on_delta_humanized,order_direction:desc,page:0,page_size:100)',
+    ).then(xhr => {
+      const dashboards = xhr.body.result;
+      const testDashboard = dashboards.find(
+        (d: { dashboard_title: string }) =>
+          d.dashboard_title === testItems.dashboard,
+      );
+      cy.visit(testDashboard.url);
+    });
+    WORLD_HEALTH_CHARTS.forEach(waitForChartLoad);
+    cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
+      cy.contains(testItems.filterDefaultValue).should('be.visible');
+      cy.contains(testItems.filterOtherCountry).should('not.exist');
+    });
+    cy.get(nativeFilters.filterItem)
+      .contains(testItems.filterDefaultValue)
+      .should('be.visible');
+  });
+
+  it('Verify that allow for deleted filter restore', () => {
+    expandFilterOnLeftPanel();
+    enterNativeFilterEditModal();

Review Comment:
   done



##########
superset-frontend/cypress-base/cypress/integration/dashboard/dashboard.helper.ts:
##########
@@ -177,38 +301,54 @@ export function clickOnAddFilterInModal() {
 
 /** ************************************************************************
  * Fills value native filter form with basic information
+ * @param {string} type type for filter: Value, Numerical range,Time column,Time grain,Time range
  * @param {string} name name for filter
  * @param {string} dataset which dataset should be used
  * @param {string} filterColumn which column should be used
  * @returns {None}
  * @summary helper for filling value native filter form
  ************************************************************************* */
-export function fillValueNativeFilterForm(
+export function fillNativeFilterForm(

Review Comment:
   done



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org