You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2024/09/30 17:50:22 UTC
(superset) branch master updated: fix: battling cypress' dashboard feature (#30441)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new daa4b1dc65 fix: battling cypress' dashboard feature (#30441)
daa4b1dc65 is described below
commit daa4b1dc656d8551ef04d947df9e3f4cb48facb8
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Sep 30 10:50:16 2024 -0700
fix: battling cypress' dashboard feature (#30441)
---
scripts/cypress_run.py | 50 +++--
...s.test.ts => nativeFilters.noInitState.test.ts} | 242 ---------------------
.../cypress/e2e/dashboard/nativeFilters.test.ts | 216 ------------------
3 files changed, 26 insertions(+), 482 deletions(-)
diff --git a/scripts/cypress_run.py b/scripts/cypress_run.py
index 738706d48b..4b9e00febf 100644
--- a/scripts/cypress_run.py
+++ b/scripts/cypress_run.py
@@ -47,31 +47,33 @@ def run_cypress_for_test_file(
browser = os.getenv("CYPRESS_BROWSER", "chrome")
chrome_flags = "--disable-dev-shm-usage"
- # Create Cypress command for a single test file
- if use_dashboard:
- cmd = (
- f"{XVFB_PRE_CMD} "
- f'{cypress_cmd} --spec "{test_file}" --browser {browser} '
- f"--record --group matrix{group}-file{i} --tag {REPO},{GITHUB_EVENT_NAME} "
- f"--ci-build-id {build_id} "
- f"-- {chrome_flags}"
- )
- else:
- os.environ.pop("CYPRESS_RECORD_KEY", None)
- cmd = (
- f"{XVFB_PRE_CMD} "
- f"{cypress_cmd} --browser {browser} "
- f'--spec "{test_file}" '
- f"-- {chrome_flags}"
- )
-
- if dry_run:
- # Print the command instead of executing it
- print(f"DRY RUN: {cmd}")
- return 0
-
for attempt in range(retries):
- print(f"RUN: {cmd} (Attempt {attempt + 1}/{retries})")
+ # Create Cypress command for a single test file
+ cmd: str = ""
+ if use_dashboard:
+ # If/when we want to use cypress' dashboard feature to record the run
+ group_id = f"matrix{group}-file{i}-{attempt}"
+ cmd = (
+ f"{XVFB_PRE_CMD} "
+ f'{cypress_cmd} --spec "{test_file}" --browser {browser} '
+ f"--record --group {group_id} --tag {REPO},{GITHUB_EVENT_NAME} "
+ f"--ci-build-id {build_id} "
+ f"-- {chrome_flags}"
+ )
+ else:
+ os.environ.pop("CYPRESS_RECORD_KEY", None)
+ cmd = (
+ f"{XVFB_PRE_CMD} "
+ f"{cypress_cmd} --browser {browser} "
+ f'--spec "{test_file}" '
+ f"-- {chrome_flags}"
+ )
+ print(f"RUN: {cmd} (Attempt {attempt + 1}/{retries})")
+ if dry_run:
+ # Print the command instead of executing it
+ print(f"DRY RUN: {cmd}")
+ return 0
+
process = subprocess.Popen(
cmd,
shell=True,
diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.noInitState.test.ts
similarity index 52%
copy from superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
copy to superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.noInitState.test.ts
index 8a67841de1..b90c8f6d17 100644
--- a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
+++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.noInitState.test.ts
@@ -69,248 +69,6 @@ function closeFilterModal() {
}
describe('Native filters', () => {
- describe('Nativefilters tests initial state required', () => {
- beforeEach(() => {
- cy.createSampleDashboards([0]);
- });
-
- it('Verify that default value is respected after revisit', () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- inputNativeFilterDefaultValue(testItems.filterDefaultValue);
- saveNativeFilterSettings([SAMPLE_CHART]);
- 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');
- });
-
- // reload dashboard
- cy.reload();
- cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
- cy.contains(testItems.filterDefaultValue).should('be.visible');
- cy.contains(testItems.filterOtherCountry).should('not.exist');
- });
- validateFilterContentOnDashboard(testItems.filterDefaultValue);
- });
-
- it('User can create parent filters using "Values are dependent on other filters"', () => {
- prepareDashboardFilters([
- { name: 'region', column: 'region', datasetId: 2 },
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- selectFilter(1);
- cy.get(nativeFilters.filterConfigurationSections.displayedSection).within(
- () => {
- cy.contains('Values are dependent on other filters')
- .should('be.visible')
- .click();
- },
- );
- addParentFilterWithValue(0, testItems.topTenChart.filterColumnRegion);
- saveNativeFilterSettings([SAMPLE_CHART]);
- [
- testItems.topTenChart.filterColumnRegion,
- testItems.topTenChart.filterColumn,
- ].forEach(it => {
- cy.get(nativeFilters.filterFromDashboardView.filterName)
- .contains(it)
- .should('be.visible');
- });
- getNativeFilterPlaceholderWithIndex(1)
- .invoke('text')
- .should('equal', '214 options', { timeout: 20000 });
- // apply first filter value and validate 2nd filter is depden on 1st filter.
- applyNativeFilterValueWithIndex(0, 'North America');
- getNativeFilterPlaceholderWithIndex(0).should('have.text', '3 options', {
- timeout: 20000,
- });
- });
-
- it('user can delete dependent filter', () => {
- prepareDashboardFilters([
- { name: 'region', column: 'region', datasetId: 2 },
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- selectFilter(1);
- cy.get(nativeFilters.filterConfigurationSections.displayedSection).within(
- () => {
- cy.contains('Values are dependent on other filters')
- .should('be.visible')
- .click();
- },
- );
- addParentFilterWithValue(0, testItems.topTenChart.filterColumnRegion);
- // remove year native filter to cause it disappears from parent filter input in global sales
- cy.get(nativeFilters.modal.tabsList.removeTab)
- .should('be.visible')
- .first()
- .click();
- // make sure you are seeing global sales filter which had parent filter
- cy.get(nativeFilters.modal.tabsList.filterItemsContainer)
- .children()
- .last()
- .click();
- //
- cy.wait(1000);
- cy.get(nativeFilters.filterConfigurationSections.displayedSection).within(
- () => {
- cy.contains('Values are dependent on other filters').should(
- 'not.exist',
- );
- },
- );
- });
-
- it('User can create filter depend on 2 other filters', () => {
- prepareDashboardFilters([
- { name: 'region', column: 'region', datasetId: 2 },
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- { name: 'country_code', column: 'country_code', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- selectFilter(2);
- cy.get(nativeFilters.filterConfigurationSections.displayedSection).within(
- () => {
- cy.contains('Values are dependent on other filters')
- .should('be.visible')
- .click();
- cy.get(exploreView.controlPanel.addFieldValue).click();
- },
- );
- // add value to the first input
- addParentFilterWithValue(0, testItems.topTenChart.filterColumnRegion);
- // add value to the second input
- addParentFilterWithValue(1, testItems.topTenChart.filterColumn);
- saveNativeFilterSettings([SAMPLE_CHART]);
- // filters should be displayed in the left panel
- [
- testItems.topTenChart.filterColumnRegion,
- testItems.topTenChart.filterColumn,
- testItems.topTenChart.filterColumnCountryCode,
- ].forEach(it => {
- validateFilterNameOnDashboard(it);
- });
-
- // initially first filter shows 39 options
- getNativeFilterPlaceholderWithIndex(0).should('have.text', '7 options');
- // initially second filter shows 409 options
- getNativeFilterPlaceholderWithIndex(1).should('have.text', '214 options');
- // verify third filter shows 409 options
- getNativeFilterPlaceholderWithIndex(2).should('have.text', '214 options');
-
- // apply first filter value
- applyNativeFilterValueWithIndex(0, 'North America');
-
- // verify second filter shows 409 options available still
- getNativeFilterPlaceholderWithIndex(0).should('have.text', '214 options');
-
- // verify second filter shows 69 options available still
- getNativeFilterPlaceholderWithIndex(1).should('have.text', '3 options');
-
- // apply second filter value
- applyNativeFilterValueWithIndex(1, 'United States');
-
- // verify number of available options for third filter - should be decreased to only one
- getNativeFilterPlaceholderWithIndex(0).should('have.text', '1 option');
- });
-
- it('User can remove parent filters', () => {
- prepareDashboardFilters([
- { name: 'region', column: 'region', datasetId: 2 },
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- selectFilter(1);
- // Select dependent option and auto use platform for genre
- cy.get(nativeFilters.filterConfigurationSections.displayedSection).within(
- () => {
- cy.contains('Values are dependent on other filters')
- .should('be.visible')
- .click();
- },
- );
- saveNativeFilterSettings([SAMPLE_CHART]);
- enterNativeFilterEditModal(false);
- cy.get(nativeFilters.modal.tabsList.removeTab)
- .should('be.visible')
- .first()
- .click({
- force: true,
- });
- saveNativeFilterSettings([SAMPLE_CHART]);
- cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
- cy.contains(testItems.filterDefaultValue).should('be.visible');
- cy.contains(testItems.filterOtherCountry).should('be.visible');
- });
- });
- });
-
- describe('Nativefilters basic interactions', () => {
- before(() => {
- visitDashboard();
- });
-
- beforeEach(() => {
- cy.createSampleDashboards([0]);
- closeFilterModal();
- });
-
- it('User can expand / retract native filter sidebar on a dashboard', () => {
- cy.get(nativeFilters.addFilterButton.button).should('not.exist');
- expandFilterOnLeftPanel();
- cy.get(nativeFilters.filterFromDashboardView.createFilterButton).should(
- 'be.visible',
- );
- cy.get(nativeFilters.filterFromDashboardView.expand).should(
- 'not.be.visible',
- );
- collapseFilterOnLeftPanel();
- });
-
- it('User can enter filter edit pop-up by clicking on native filter edit icon', () => {
- enterNativeFilterEditModal(false);
- });
-
- it('User can delete a native filter', () => {
- enterNativeFilterEditModal(false);
- cy.get(nativeFilters.filtersList.removeIcon).first().click();
- cy.contains('Restore Filter').should('not.exist', { timeout: 10000 });
- });
-
- it('User can cancel creating a new filter', () => {
- enterNativeFilterEditModal(false);
- cancelNativeFilterSettings();
- });
-
- it('Verify setting options and tooltips for value filter', () => {
- enterNativeFilterEditModal(false);
- cy.contains('Filter value is required').should('be.visible').click();
- checkNativeFilterTooltip(0, nativeFilterTooltips.preFilter);
- checkNativeFilterTooltip(1, nativeFilterTooltips.defaultValue);
- cy.get(nativeFilters.modal.container).should('be.visible');
- valueNativeFilterOptions.forEach(el => {
- cy.contains(el);
- });
- cy.contains('Values are dependent on other filters').should('not.exist');
- cy.get(
- nativeFilters.filterConfigurationSections.checkedCheckbox,
- ).contains('Can select multiple values');
- checkNativeFilterTooltip(2, nativeFilterTooltips.required);
- checkNativeFilterTooltip(3, nativeFilterTooltips.defaultToFirstItem);
- checkNativeFilterTooltip(4, nativeFilterTooltips.searchAllFilterOptions);
- checkNativeFilterTooltip(5, nativeFilterTooltips.inverseSelection);
- clickOnAddFilterInModal();
- cy.contains('Values are dependent on other filters').should('exist');
- });
- });
-
describe('Nativefilters initial state not required', () => {
it("User can check 'Filter has default value'", () => {
prepareDashboardFilters([
diff --git a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
index 8a67841de1..56a302acb7 100644
--- a/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
+++ b/superset-frontend/cypress-base/cypress/e2e/dashboard/nativeFilters.test.ts
@@ -310,220 +310,4 @@ describe('Native filters', () => {
cy.contains('Values are dependent on other filters').should('exist');
});
});
-
- describe('Nativefilters initial state not required', () => {
- it("User can check 'Filter has default value'", () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- inputNativeFilterDefaultValue(testItems.filterDefaultValue);
- });
-
- it('User can add a new native filter', () => {
- prepareDashboardFilters([]);
-
- let filterKey: string;
- const removeFirstChar = (search: string) =>
- search.split('').slice(1, search.length).join('');
-
- cy.location().then(loc => {
- cy.url().should('contain', 'native_filters_key');
- const queryParams = qs.parse(removeFirstChar(loc.search));
- filterKey = queryParams.native_filters_key as string;
- expect(typeof filterKey).eq('string');
- });
- enterNativeFilterEditModal();
- addCountryNameFilter();
- saveNativeFilterSettings([SAMPLE_CHART]);
- cy.location().then(loc => {
- cy.url().should('contain', 'native_filters_key');
- const queryParams = qs.parse(removeFirstChar(loc.search));
- const newfilterKey = queryParams.native_filters_key;
- expect(newfilterKey).eq(filterKey);
- });
- cy.get(nativeFilters.modal.container).should('not.exist');
- });
-
- it('User can restore a deleted native filter', () => {
- prepareDashboardFilters([
- { name: 'country_code', column: 'country_code', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- cy.get(nativeFilters.filtersList.removeIcon).first().click();
- cy.get('[data-test="restore-filter-button"]')
- .should('be.visible')
- .click();
- cy.get(nativeFilters.modal.container)
- .find(nativeFilters.filtersPanel.filterName)
- .should(
- 'have.attr',
- 'value',
- testItems.topTenChart.filterColumnCountryCode,
- );
- });
-
- it('User can create a time grain filter', () => {
- prepareDashboardFilters([]);
- enterNativeFilterEditModal();
- fillNativeFilterForm(
- testItems.filterType.timeGrain,
- testItems.filterType.timeGrain,
- testItems.datasetForNativeFilter,
- );
- saveNativeFilterSettings([SAMPLE_CHART]);
- applyNativeFilterValueWithIndex(0, testItems.filterTimeGrain);
- cy.get(nativeFilters.applyFilter).click();
- cy.url().then(u => {
- const ur = new URL(u);
- expect(ur.search).to.include('native_filters');
- });
- validateFilterNameOnDashboard(testItems.filterType.timeGrain);
- validateFilterContentOnDashboard(testItems.filterTimeGrain);
- });
-
- it.skip('User can create a time range filter', () => {
- enterNativeFilterEditModal();
- fillNativeFilterForm(
- testItems.filterType.timeRange,
- testItems.filterType.timeRange,
- );
- saveNativeFilterSettings(WORLD_HEALTH_CHARTS);
- cy.get(dashboardView.salesDashboardSpecific.vehicleSalesFilterTimeRange)
- .should('be.visible')
- .click();
- applyAdvancedTimeRangeFilterOnDashboard('2005-12-17', '2006-12-17');
- cy.url().then(u => {
- const ur = new URL(u);
- expect(ur.search).to.include('native_filters');
- });
- validateFilterNameOnDashboard(testItems.filterType.timeRange);
- cy.get(nativeFilters.filterFromDashboardView.timeRangeFilterContent)
- .contains('2005-12-17')
- .should('be.visible');
- });
-
- it.skip('User can create a time column filter', () => {
- enterNativeFilterEditModal();
- fillNativeFilterForm(
- testItems.filterType.timeColumn,
- testItems.filterType.timeColumn,
- testItems.datasetForNativeFilter,
- );
- saveNativeFilterSettings(WORLD_HEALTH_CHARTS);
- cy.intercept(`/api/v1/chart/data?form_data=**`).as('chart');
- cy.get(nativeFilters.modal.container).should('not.exist');
- // assert that native filter is created
- validateFilterNameOnDashboard(testItems.filterType.timeColumn);
- applyNativeFilterValueWithIndex(
- 0,
- testItems.topTenChart.filterColumnYear,
- );
- cy.get(nativeFilters.applyFilter).click({ force: true });
- cy.wait('@chart');
- validateFilterContentOnDashboard(testItems.topTenChart.filterColumnYear);
- });
-
- it('User can create a numerical range filter', () => {
- visitDashboard();
- enterNativeFilterEditModal(false);
- fillNativeFilterForm(
- testItems.filterType.numerical,
- testItems.filterNumericalColumn,
- testItems.datasetForNativeFilter,
- testItems.filterNumericalColumn,
- );
- saveNativeFilterSettings([]);
- // assertions
- cy.get(nativeFilters.slider.slider).should('be.visible').click('center');
- cy.get(nativeFilters.applyFilter).click();
- // 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('User can undo deleting a native filter', () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- undoDeleteNativeFilter();
- cy.get(nativeFilters.modal.container)
- .find(nativeFilters.filtersPanel.filterName)
- .should('have.attr', 'value', testItems.topTenChart.filterColumn);
- });
-
- it('User can cancel changes in native filter', () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- cy.getBySel('filters-config-modal__name-input').type('|EDITED', {
- force: true,
- });
- cancelNativeFilterSettings();
- enterNativeFilterEditModal(false);
- cy.get(nativeFilters.filtersList.removeIcon).first().click();
- cy.contains('You have removed this filter.').should('be.visible');
- });
-
- it('User can create a value filter', () => {
- visitDashboard();
- enterNativeFilterEditModal(false);
- addCountryNameFilter();
- cy.get(nativeFilters.filtersPanel.filterTypeInput)
- .find(nativeFilters.filtersPanel.filterTypeItem)
- .should('have.text', testItems.filterType.value);
- saveNativeFilterSettings([]);
- validateFilterNameOnDashboard(testItems.topTenChart.filterColumn);
- });
-
- it('User can apply value filter with selected values', () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- 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 stop filtering when filter is removed', () => {
- prepareDashboardFilters([
- { name: 'country_name', column: 'country_name', datasetId: 2 },
- ]);
- enterNativeFilterEditModal();
- inputNativeFilterDefaultValue(testItems.filterDefaultValue);
- saveNativeFilterSettings([SAMPLE_CHART]);
- 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');
- validateFilterNameOnDashboard(testItems.topTenChart.filterColumn);
- enterNativeFilterEditModal(false);
- deleteNativeFilter();
- saveNativeFilterSettings([SAMPLE_CHART]);
- cy.get(dataTestChartName(testItems.topTenChart.name)).within(() => {
- cy.contains(testItems.filterDefaultValue).should('be.visible');
- cy.contains(testItems.filterOtherCountry).should('be.visible');
- });
- });
- });
});