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 2021/01/09 21:44:42 UTC

[GitHub] [superset] ktmud commented on a change in pull request #12254: test: added cypress tests for #11864 and #11682

ktmud commented on a change in pull request #12254:
URL: https://github.com/apache/superset/pull/12254#discussion_r554475806



##########
File path: superset-frontend/cypress-base/cypress/integration/explore/control.test.ts
##########
@@ -233,8 +233,158 @@ describe('Time range filter', () => {
       });
     cy.get('[data-test=cancel-button]').click();
   });
-});
+  it('Chosen custom time range parameters are applied after change', () => {
+    const formData = {
+      ...FORM_DATA_DEFAULTS,
+      metrics: [NUM_METRIC],
+      viz_type: 'line',
+      time_range: '100 years ago : now',
+    };
+
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@postJson' });
+
+    cy.get('[data-test=time-range-trigger]')
+      .click()
+      .then($range => {
+        const firstRange = $range.text();
+        cy.get('.ant-popover-inner-content').within(() => {

Review comment:
       Can we use a data-test selector here, too?

##########
File path: superset-frontend/cypress-base/cypress/integration/explore/control.test.ts
##########
@@ -233,8 +233,158 @@ describe('Time range filter', () => {
       });
     cy.get('[data-test=cancel-button]').click();
   });
-});
+  it('Chosen custom time range parameters are applied after change', () => {
+    const formData = {
+      ...FORM_DATA_DEFAULTS,
+      metrics: [NUM_METRIC],
+      viz_type: 'line',
+      time_range: '100 years ago : now',
+    };
+
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@postJson' });
+
+    cy.get('[data-test=time-range-trigger]')
+      .click()
+      .then($range => {
+        const firstRange = $range.text();
+        cy.get('.ant-popover-inner-content').within(() => {
+          cy.contains('Advanced').click();
+          cy.contains('Custom').click();
+          cy.get('.ant-input-number-input').clear().type('30{enter}');
+        });
 
+        cy.get('[data-test=apply-button]').click();
+        cy.get('[data-test=time-range-modal]').should('not.exist');
+        cy.get('[data-test=time-range-trigger]').then($range => {
+          const secondRange = $range.text();
+          expect(secondRange).to.not.equal(firstRange);
+        });
+      });
+  });
+  it('Chosen last time filters are applied after change', () => {
+    const formData = {
+      ...FORM_DATA_DEFAULTS,
+      metrics: [NUM_METRIC],
+      viz_type: 'line',
+      time_range: '100 years ago : now',
+    };
+
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@postJson' });
+
+    cy.get('[data-test=time-range-trigger]')
+      .click()
+      .then($range => {
+        const firstRange = $range.text();
+        cy.get('.ant-popover-inner-content').within(() => {
+          cy.contains('Advanced').click();
+          cy.contains('Last').click();
+          cy.get('.ant-radio-wrapper').within(() => {
+            cy.contains('last week').click();
+          });
+        });
+        cy.get('[data-test=apply-button]').click();
+        cy.get('[data-test=time-range-modal]').should('not.exist');
+        cy.get('[data-test=time-range-trigger]').then($range => {
+          const secondRange = $range.text();
+          expect(secondRange).to.not.equal(firstRange);
+        });
+        cy.get('[data-test=time-range-trigger]')
+          .click()
+          .then($range => {
+            const firstRange = $range.text();
+            cy.get('.ant-popover-inner-content').within(() => {
+              cy.contains('Last').click();
+              cy.get('.ant-radio-wrapper').within(() => {
+                cy.contains('last year').click();
+              });
+            });
+            cy.get('[data-test=apply-button]').click();
+            cy.get('[data-test=time-range-modal]').should('not.exist');
+            cy.get('[data-test=time-range-trigger]').then($range => {
+              const secondRange = $range.text();
+              expect(secondRange).to.not.equal(firstRange);
+            });
+          });
+      });
+  });
+  it('Changes through range types filters are applied after change', () => {
+    const formData = {
+      ...FORM_DATA_DEFAULTS,
+      metrics: [NUM_METRIC],
+      viz_type: 'line',
+      time_range: '100 years ago : now',
+    };
+
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@postJson' });
+    cy.get('[data-test=time-range-trigger]')
+      .click()
+      .then(() => {
+        cy.get('.ant-popover-inner-content').within(() => {
+          cy.contains('Advanced').click({ force: true });
+          cy.contains('Custom').click({ force: true });
+          cy.get('.ant-input-number-input').clear().type('35{enter}');
+        });
+
+        cy.get('[data-test=apply-button]').click();
+        cy.get('[data-test=time-range-modal]').should('not.exist');
+        cy.get('[data-test=time-range-trigger]').then($range => {
+          const customRange = $range.text();
+          cy.get('[data-test=time-range-trigger]')
+            .click()
+            .then(() => {

Review comment:
       Is the then wrapper necessary? I thought a Cypress selector will just keep retrying until it finds the elements or timeout.
   
   You can probably reselect the same trigger element to avoid nesting?

##########
File path: superset-frontend/cypress-base/cypress/integration/explore/control.test.ts
##########
@@ -233,8 +233,158 @@ describe('Time range filter', () => {
       });
     cy.get('[data-test=cancel-button]').click();
   });
-});
+  it('Chosen custom time range parameters are applied after change', () => {
+    const formData = {
+      ...FORM_DATA_DEFAULTS,
+      metrics: [NUM_METRIC],
+      viz_type: 'line',
+      time_range: '100 years ago : now',
+    };
+
+    cy.visitChartByParams(JSON.stringify(formData));
+    cy.verifySliceSuccess({ waitAlias: '@postJson' });
+
+    cy.get('[data-test=time-range-trigger]')
+      .click()
+      .then($range => {
+        const firstRange = $range.text();

Review comment:
       You can probably move this variable out of the `then` wrapper with `let` to avoid nesting.




----------------------------------------------------------------
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:
users@infra.apache.org



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