Skip to content

Commit

Permalink
test: add native filter part2 (#17283)
Browse files Browse the repository at this point in the history
* add native filter part2

* fix lint

* remove unused code

* fix lint after modified
  • Loading branch information
jinghua-qa authored and AAfghahi committed Jan 10, 2022
1 parent 6b7f2d3 commit 5561c88
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/cypress-base/cypress/support/directories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 5561c88

Please sign in to comment.