Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added some sanity test for native filter #17231

Merged
merged 5 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import { getChartAlias, Slice } from 'cypress/utils/vizPlugins';
export const WORLD_HEALTH_DASHBOARD = '/superset/dashboard/world_health/';
export const TABBED_DASHBOARD = '/superset/dashboard/tabbed_dash/';

export const testItems = {
dashboard: 'Cypress Sales Dashboard',
dataset: 'Vehicle Sales',
chart: 'Cypress chart',
defaultNameDashboard: '[ untitled dashboard ]',
};

export const CHECK_DASHBOARD_FAVORITE_ENDPOINT =
'/superset/favstar/Dashboard/*/count';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,124 @@
* specific language governing permissions and limitations
* under the License.
*/
import { CHART_LIST } from '../chart_list/chart_list.helper';
import { dashboardView, nativeFilters } from 'cypress/support/directories';
import { testItems } from './dashboard.helper';
import { DASHBOARD_LIST } from '../dashboard_list/dashboard_list.helper';

const getTestTitle = (
test: Mocha.Suite = (Cypress as any).mocha.getRunner().suite.ctx.test,
): string =>
test.parent?.title
? `${getTestTitle(test.parent)} -- ${test.title}`
: test.title;

// TODO: fix flaky init logic and re-enable
const milliseconds = new Date().getTime();
const dashboard = `Test Dashboard${milliseconds}`;

describe('Nativefilters Sanity test', () => {
before(() => {
cy.login();
cy.intercept('/api/v1/dashboard/?q=**').as('dashboardsList');
cy.intercept('POST', '**/copy_dash/*').as('copy');
cy.intercept('/api/v1/dashboard/*').as('dashboard');
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 worldBankDashboard = dashboards.find(
d => d.dashboard_title === "World Bank's Data",
);
cy.visit(worldBankDashboard.url);
});
cy.get(dashboardView.threeDotsMenuIcon).should('be.visible').click();
cy.get(dashboardView.saveAsMenuOption).should('be.visible').click();
cy.get(dashboardView.saveModal.dashboardNameInput)
.should('be.visible')
.clear()
.type(testItems.dashboard);
cy.get(dashboardView.saveModal.saveButton).click();
cy.wait('@copy', { timeout: 45000 })
.its('response.statusCode')
.should('eq', 200);
});
beforeEach(() => {
cy.login();
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 => d.dashboard_title === testItems.dashboard,
);
cy.visit(testDashboard.url);
});
});
it('User can expand / retract native filter sidebar on a dashboard', () => {
cy.get(nativeFilters.createFilterButton).should('not.exist');
cy.get(nativeFilters.filterFromDashboardView.expand)
.should('be.visible')
.click();
cy.get(nativeFilters.createFilterButton).should('be.visible');
cy.get(nativeFilters.filterFromDashboardView.expand).should(
'not.be.visible',
);
cy.get(nativeFilters.filterFromDashboardView.collapse)
.should('be.visible')
.click();
cy.get(nativeFilters.filterFromDashboardView.collapse).should(
'not.be.visible',
);
});
it('User can enter filter edit pop-up by clicking on pencil icon', () => {
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');
});
it('User can add a new native filter', () => {
cy.get(nativeFilters.filterFromDashboardView.expand)
.should('be.visible')
.click();
cy.get(nativeFilters.createFilterButton).should('be.visible').click();
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.filterName)
.click()
.type('Country name');
cy.get(nativeFilters.modal.container)
.find(nativeFilters.filtersPanel.datasetName)
.click()
.type('wb_health_population{enter}');

// Add following step to avoid flaky enter value in line 177
cy.get(nativeFilters.filtersPanel.inputDropdown)
.should('be.visible', { timeout: 20000 })
.last()
.click();

cy.get('.loading inline-centered css-101mkpk').should('not.exist');
// hack for unclickable country_name
cy.wait(5000);
cy.get(nativeFilters.filtersPanel.filterInfoInput)
.last()
.should('be.visible')
.click({ force: true });
cy.get(nativeFilters.filtersPanel.filterInfoInput)
.last()
.type('country_name');
cy.get(nativeFilters.filtersPanel.inputDropdown)
.should('be.visible', { timeout: 20000 })
.last()
.click();
cy.get(nativeFilters.modal.footer)
.contains('Save')
.should('be.visible')
.click();
cy.get(nativeFilters.modal.container).should('not.exist');
});
});

xdescribe('Nativefilters', () => {
before(() => {
cy.login();
Expand Down
Loading