fix: Most common flaky Cypress tests (#21941)
This commit is contained in:
parent
95b43238a0
commit
7e3e13321b
|
|
@ -88,7 +88,6 @@ describe('Charts list', () => {
|
||||||
saveChartToDashboard('1 - Sample dashboard');
|
saveChartToDashboard('1 - Sample dashboard');
|
||||||
saveChartToDashboard('2 - Sample dashboard');
|
saveChartToDashboard('2 - Sample dashboard');
|
||||||
saveChartToDashboard('3 - Sample dashboard');
|
saveChartToDashboard('3 - Sample dashboard');
|
||||||
saveChartToDashboard('4 - Sample dashboard');
|
|
||||||
visitChartList();
|
visitChartList();
|
||||||
cy.getBySel('count-crosslinks').should('be.visible');
|
cy.getBySel('count-crosslinks').should('be.visible');
|
||||||
cy.getBySel('crosslinks')
|
cy.getBySel('crosslinks')
|
||||||
|
|
@ -96,7 +95,7 @@ describe('Charts list', () => {
|
||||||
.trigger('mouseover')
|
.trigger('mouseover')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.get('.ant-tooltip')
|
cy.get('.ant-tooltip')
|
||||||
.contains('4 - Sample dashboard')
|
.contains('3 - Sample dashboard')
|
||||||
.invoke('removeAttr', 'target')
|
.invoke('removeAttr', 'target')
|
||||||
.click();
|
.click();
|
||||||
cy.wait('@get');
|
cy.wait('@get');
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ function dragComponent(
|
||||||
cy.getBySel('dashboard-charts-filter-search-input').type(component);
|
cy.getBySel('dashboard-charts-filter-search-input').type(component);
|
||||||
cy.wait('@filtering');
|
cy.wait('@filtering');
|
||||||
}
|
}
|
||||||
|
cy.wait(500);
|
||||||
drag(`[data-test="${target}"]`, component).to(
|
drag(`[data-test="${target}"]`, component).to(
|
||||||
'[data-test="grid-content"] [data-test="dragdroppable-object"]',
|
'[data-test="grid-content"] [data-test="dragdroppable-object"]',
|
||||||
);
|
);
|
||||||
|
|
@ -148,16 +149,21 @@ function assertMetadata(text: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function clearMetadata() {
|
function clearMetadata() {
|
||||||
cy.wait(500);
|
|
||||||
cy.get('#json_metadata').then($jsonmetadata => {
|
cy.get('#json_metadata').then($jsonmetadata => {
|
||||||
cy.wrap($jsonmetadata).type('{selectall} {backspace}');
|
cy.wrap($jsonmetadata).find('.ace_content').click();
|
||||||
|
cy.wrap($jsonmetadata)
|
||||||
|
.find('.ace_text-input')
|
||||||
|
.type('{selectall} {backspace}');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeMetadata(metadata: string) {
|
function writeMetadata(metadata: string) {
|
||||||
cy.get('#json_metadata').then($jsonmetadata => {
|
cy.get('#json_metadata').then($jsonmetadata =>
|
||||||
cy.wrap($jsonmetadata).type(metadata, { parseSpecialCharSequences: false });
|
cy
|
||||||
});
|
.wrap($jsonmetadata)
|
||||||
|
.find('.ace_text-input')
|
||||||
|
.type(metadata, { parseSpecialCharSequences: false }),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openExplore(chartName: string) {
|
function openExplore(chartName: string) {
|
||||||
|
|
|
||||||
|
|
@ -593,13 +593,13 @@ describe('Native filters', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('User can cancel changes in native filter', () => {
|
it('User can cancel changes in native filter', () => {
|
||||||
visitDashboard();
|
prepareDashboardFilters([
|
||||||
enterNativeFilterEditModal(false);
|
{ name: 'country_name', column: 'country_name', datasetId: 2 },
|
||||||
fillNativeFilterForm(
|
]);
|
||||||
testItems.filterType.value,
|
enterNativeFilterEditModal();
|
||||||
'suffix',
|
cy.getBySel('filters-config-modal__name-input').type('|EDITED', {
|
||||||
testItems.datasetForNativeFilter,
|
force: true,
|
||||||
);
|
});
|
||||||
cancelNativeFilterSettings();
|
cancelNativeFilterSettings();
|
||||||
enterNativeFilterEditModal();
|
enterNativeFilterEditModal();
|
||||||
cy.get(nativeFilters.filtersList.removeIcon).first().click();
|
cy.get(nativeFilters.filtersList.removeIcon).first().click();
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@ describe('Advanced analytics', () => {
|
||||||
cy.visitChartByName('Num Births Trend');
|
cy.visitChartByName('Num Births Trend');
|
||||||
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
cy.verifySliceSuccess({ waitAlias: '@postJson' });
|
||||||
|
|
||||||
cy.get('.ant-collapse-header').contains('Advanced Analytics').click();
|
cy.get('.ant-collapse-header')
|
||||||
|
.contains('Advanced Analytics')
|
||||||
|
.click({ force: true });
|
||||||
|
|
||||||
cy.get('[data-test=time_compare]').find('.ant-select').click();
|
cy.get('[data-test=time_compare]').find('.ant-select').click();
|
||||||
cy.get('[data-test=time_compare]')
|
cy.get('[data-test=time_compare]')
|
||||||
|
|
@ -43,13 +45,16 @@ describe('Advanced analytics', () => {
|
||||||
cy.get('button[data-test="run-query-button"]').click();
|
cy.get('button[data-test="run-query-button"]').click();
|
||||||
cy.wait('@postJson');
|
cy.wait('@postJson');
|
||||||
cy.wait('@putExplore');
|
cy.wait('@putExplore');
|
||||||
|
|
||||||
cy.reload();
|
cy.reload();
|
||||||
cy.verifySliceSuccess({
|
cy.verifySliceSuccess({
|
||||||
waitAlias: '@postJson',
|
waitAlias: '@postJson',
|
||||||
chartSelector: 'svg',
|
chartSelector: 'svg',
|
||||||
});
|
});
|
||||||
cy.wait('@getExplore');
|
cy.wait('@getExplore');
|
||||||
cy.get('.ant-collapse-header').contains('Advanced Analytics').click();
|
cy.get('.ant-collapse-header')
|
||||||
|
.contains('Advanced Analytics')
|
||||||
|
.click({ force: true });
|
||||||
cy.get('[data-test=time_compare]')
|
cy.get('[data-test=time_compare]')
|
||||||
.find('.ant-select-selector')
|
.find('.ant-select-selector')
|
||||||
.contains('28 days');
|
.contains('28 days');
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,13 @@ import { interceptChart } from 'cypress/utils';
|
||||||
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
|
import { FORM_DATA_DEFAULTS, NUM_METRIC } from './visualizations/shared.helper';
|
||||||
|
|
||||||
describe('Datasource control', () => {
|
describe('Datasource control', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.preserveLogin();
|
||||||
|
});
|
||||||
|
|
||||||
const newMetricName = `abc${Date.now()}`;
|
const newMetricName = `abc${Date.now()}`;
|
||||||
|
|
||||||
it('should allow edit dataset', () => {
|
it('should allow edit dataset', () => {
|
||||||
let numScripts = 0;
|
|
||||||
|
|
||||||
cy.login();
|
|
||||||
interceptChart({ legacy: true }).as('chartData');
|
interceptChart({ legacy: true }).as('chartData');
|
||||||
|
|
||||||
cy.visitChartByName('Num Births Trend');
|
cy.visitChartByName('Num Births Trend');
|
||||||
|
|
@ -36,16 +37,8 @@ describe('Datasource control', () => {
|
||||||
|
|
||||||
cy.get('[data-test="datasource-menu-trigger"]').click();
|
cy.get('[data-test="datasource-menu-trigger"]').click();
|
||||||
|
|
||||||
cy.get('script').then(nodes => {
|
|
||||||
numScripts = nodes.length;
|
|
||||||
});
|
|
||||||
|
|
||||||
cy.get('[data-test="edit-dataset"]').click();
|
cy.get('[data-test="edit-dataset"]').click();
|
||||||
|
|
||||||
// should load additional scripts for the modal
|
|
||||||
cy.get('script').then(nodes => {
|
|
||||||
expect(nodes.length).to.greaterThan(numScripts);
|
|
||||||
});
|
|
||||||
cy.get('[data-test="edit-dataset-tabs"]').within(() => {
|
cy.get('[data-test="edit-dataset-tabs"]').within(() => {
|
||||||
cy.contains('Metrics').click();
|
cy.contains('Metrics').click();
|
||||||
});
|
});
|
||||||
|
|
@ -205,6 +198,7 @@ describe('Time range filter', () => {
|
||||||
cy.get('input[value="now"]');
|
cy.get('input[value="now"]');
|
||||||
});
|
});
|
||||||
cy.get('[data-test=cancel-button]').click();
|
cy.get('[data-test=cancel-button]').click();
|
||||||
|
cy.wait(500);
|
||||||
cy.get('.ant-popover').should('not.be.visible');
|
cy.get('.ant-popover').should('not.be.visible');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { interceptGet as interceptDashboardGet } from '../dashboard/utils';
|
||||||
|
|
||||||
export function interceptFiltering() {
|
export function interceptFiltering() {
|
||||||
cy.intercept('GET', `/api/v1/chart/?q=*`).as('filtering');
|
cy.intercept('GET', `/api/v1/chart/?q=*`).as('filtering');
|
||||||
}
|
}
|
||||||
|
|
@ -41,6 +43,10 @@ export function interceptExploreJson() {
|
||||||
cy.intercept('POST', `/superset/explore_json/**`).as('getJson');
|
cy.intercept('POST', `/superset/explore_json/**`).as('getJson');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function interceptExploreGet() {
|
||||||
|
cy.intercept('GET', `/api/v1/explore/?slice_id=**`).as('getExplore');
|
||||||
|
}
|
||||||
|
|
||||||
export function setFilter(filter: string, option: string) {
|
export function setFilter(filter: string, option: string) {
|
||||||
interceptFiltering();
|
interceptFiltering();
|
||||||
|
|
||||||
|
|
@ -51,6 +57,10 @@ export function setFilter(filter: string, option: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveChartToDashboard(dashboardName: string) {
|
export function saveChartToDashboard(dashboardName: string) {
|
||||||
|
interceptDashboardGet();
|
||||||
|
interceptUpdate();
|
||||||
|
interceptExploreGet();
|
||||||
|
|
||||||
cy.getBySel('query-save-button').click();
|
cy.getBySel('query-save-button').click();
|
||||||
cy.get(
|
cy.get(
|
||||||
'[data-test="save-chart-modal-select-dashboard-form"] [aria-label="Select a dashboard"]',
|
'[data-test="save-chart-modal-select-dashboard-form"] [aria-label="Select a dashboard"]',
|
||||||
|
|
@ -59,13 +69,16 @@ export function saveChartToDashboard(dashboardName: string) {
|
||||||
.click();
|
.click();
|
||||||
cy.get(
|
cy.get(
|
||||||
'.ant-select-selection-search-input[aria-label="Select a dashboard"]',
|
'.ant-select-selection-search-input[aria-label="Select a dashboard"]',
|
||||||
).type(dashboardName);
|
).type(dashboardName.slice(0, 3));
|
||||||
cy.get(`.ant-select-item-option[title="${dashboardName}"]`).click();
|
cy.get(`.ant-select-item-option[title="${dashboardName}"]`).click();
|
||||||
cy.getBySel('btn-modal-save').click();
|
cy.getBySel('btn-modal-save').click();
|
||||||
|
|
||||||
|
cy.wait('@update');
|
||||||
|
cy.wait('@get');
|
||||||
|
cy.wait('@getExplore');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function visitSampleChartFromList(chartName: string) {
|
export function visitSampleChartFromList(chartName: string) {
|
||||||
cy.getBySel('table-row').contains(chartName).click();
|
cy.getBySel('table-row').contains(chartName).click();
|
||||||
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
|
cy.intercept('POST', '/superset/explore_json/**').as('getJson');
|
||||||
cy.wait(500);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@ describe('SqlLab query tabs', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// add two new tabs
|
// add two new tabs
|
||||||
cy.get('[data-test="add-tab-icon"]:visible:last').click();
|
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 1}`);
|
||||||
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
cy.get(tabSelector).should('have.length', initialTabCount + 1);
|
||||||
|
|
||||||
cy.get('[data-test="add-tab-icon"]:visible:last').click();
|
cy.get('[data-test="add-tab-icon"]:visible:last').click({ force: true });
|
||||||
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 2}`);
|
cy.contains('[role="tab"]', `Untitled Query ${initialUntitledCount + 2}`);
|
||||||
cy.get(tabSelector).should('have.length', initialTabCount + 2);
|
cy.get(tabSelector).should('have.length', initialTabCount + 2);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue