From 5561c88ac565895de9de6cbfe6ce06be13071622 Mon Sep 17 00:00:00 2001 From: jinghua-qa <81597121+jinghua-qa@users.noreply.github.com> Date: Mon, 1 Nov 2021 07:36:47 -0700 Subject: [PATCH] test: add native filter part2 (#17283) * add native filter part2 * fix lint * remove unused code * fix lint after modified --- .../dashboard/nativeFilters.test.ts | 63 +++++++++++++++++++ .../cypress/support/directories.ts | 6 +- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts index 21d1be4c6eda9..35e3f013c9f58 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/nativeFilters.test.ts @@ -132,6 +132,69 @@ describe('Nativefilters Sanity test', () => { .click(); cy.get(nativeFilters.modal.container).should('not.exist'); }); + it('User can delete a native filter', () => { + cy.get(nativeFilters.createFilterButton).click({ force: true }); + cy.get(nativeFilters.modal.container).should('be.visible'); + + cy.get(nativeFilters.filtersList.removeIcon).first().click(); + cy.contains('Restore Filter').should('not.exist', { timeout: 10000 }); + + cy.get(nativeFilters.modal.footer) + .contains('Save') + .should('be.visible') + .click(); + }); + it('User can cancel changes in native filter', () => { + cy.get(nativeFilters.createFilterButton).click({ force: true }); + cy.get(nativeFilters.modal.container) + .find(nativeFilters.filtersPanel.filterName) + .click() + .type('suffix'); + cy.get(nativeFilters.modal.container) + .find(nativeFilters.filtersPanel.datasetName) + .should('be.visible'); + cy.get(nativeFilters.modal.footer) + .find(nativeFilters.modal.cancelButton) + .should('be.visible') + .click(); + cy.get(nativeFilters.modal.alertXUnsavedFilters).should('be.visible'); + // remove native filter + cy.get(nativeFilters.modal.footer) + .find(nativeFilters.modal.yesCancelButton) + .contains('cancel') + .should('be.visible') + .click({ force: true }); + + cy.get(nativeFilters.createFilterButton).click({ force: true }); + cy.get(nativeFilters.filtersList.removeIcon).first().click(); + cy.contains('You have removed this filter.').should('be.visible'); + cy.get(nativeFilters.modal.footer) + .find(nativeFilters.modal.saveButton) + .should('be.visible') + .click(); + cy.get(nativeFilters.filtersPanel.filterName).should('not.exist'); + }); + it('User can cancel creating a new filter', () => { + cy.get(nativeFilters.filterFromDashboardView.expand) + .should('be.visible') + .click(); + cy.get(nativeFilters.createFilterButton).should('be.visible').click(); + cy.get(nativeFilters.modal.container).should('be.visible'); + + cy.get(nativeFilters.modal.footer) + .find(nativeFilters.modal.cancelButton) + .should('be.visible') + .click(); + cy.get(nativeFilters.modal.alertXUnsavedFilters) + .should('have.text', 'There are unsaved changes.') + .should('be.visible'); + cy.get(nativeFilters.modal.footer) + .find(nativeFilters.modal.yesCancelButton) + .contains('cancel') + .should('be.visible') + .click(); + cy.get(nativeFilters.modal.container).should('not.exist'); + }); }); xdescribe('Nativefilters', () => { diff --git a/superset-frontend/cypress-base/cypress/support/directories.ts b/superset-frontend/cypress-base/cypress/support/directories.ts index 2507b009d2609..62871d7f1d102 100644 --- a/superset-frontend/cypress-base/cypress/support/directories.ts +++ b/superset-frontend/cypress-base/cypress/support/directories.ts @@ -317,12 +317,12 @@ export const nativeFilters = { footer: '.ant-modal-footer', saveButton: dataTestLocator('native-filter-modal-save-button'), cancelButton: dataTestLocator('native-filter-modal-cancel-button'), - yesCancelButton: '.css-1mljg09', + yesCancelButton: '[type="button"]', alertXUnsavedFilters: '.ant-alert-message', tabsList: { tabsContainer: '[class="ant-tabs-nav-list"]', tab: '.ant-tabs-tab', - removeTab: '.ant-tabs-tab-remove', + removeTab: '[aria-label="trash"]', }, addFilter: dataTestLocator('add-filter-button'), }, @@ -353,7 +353,7 @@ export const nativeFilters = { listItemNotActive: '[class="ant-tabs-tab ant-tabs-tab-with-remove"]', listItemActive: '[class="ant-tabs-tab ant-tabs-tab-with-remove ant-tabs-tab-active"]', - removeIcon: '[aria-label="remove"]', + removeIcon: '[aria-label="trash"]', }, filterItem: dataTestLocator('form-item-value'), filterItemDropdown: '.ant-select-selection-search',