Skip to content

Commit

Permalink
fix: Flaky E2E tests (#22152)
Browse files Browse the repository at this point in the history
  • Loading branch information
geido committed Nov 18, 2022
1 parent c3f9f0b commit e990690
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function openModalFromChartContext(targetMenuItem: string) {
.first()
.click();
}

cy.getBySel('metadata-bar').should('be.visible');
cy.wait('@samples');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ describe('Native filters', () => {
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');
Expand All @@ -465,6 +466,7 @@ describe('Native filters', () => {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ export function interceptDatasets() {
cy.intercept('GET', `/api/v1/dashboard/*/datasets`).as('getDatasets');
}

export function interceptDashboardasync() {
cy.intercept('GET', `/dashboardasync/api/read*`).as('getDashboardasync');
}

export function setFilter(filter: string, option: string) {
interceptFiltering();

Expand Down Expand Up @@ -346,8 +350,8 @@ export function cancelNativeFilterSettings() {
.should('be.visible')
.click();
cy.get(nativeFilters.modal.alertXUnsavedFilters)
.should('have.text', 'There are unsaved changes.')
.should('be.visible');
.should('be.visible')
.should('have.text', 'There are unsaved changes.');
cy.get(nativeFilters.modal.footer)
.find(nativeFilters.modal.yesCancelButton)
.contains('cancel')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
* under the License.
*/

import { interceptGet as interceptDashboardGet } from '../dashboard/utils';
import {
interceptGet as interceptDashboardGet,
interceptDashboardasync,
} from '../dashboard/utils';

export function interceptFiltering() {
cy.intercept('GET', `/api/v1/chart/?q=*`).as('filtering');
Expand Down Expand Up @@ -58,10 +61,13 @@ export function setFilter(filter: string, option: string) {

export function saveChartToDashboard(dashboardName: string) {
interceptDashboardGet();
interceptDashboardasync();
interceptUpdate();
interceptExploreGet();

cy.getBySel('query-save-button').click();
cy.wait('@getDashboardasync');
cy.getBySelLike('chart-modal').should('be.visible');
cy.get(
'[data-test="save-chart-modal-select-dashboard-form"] [aria-label="Select a dashboard"]',
)
Expand Down

0 comments on commit e990690

Please sign in to comment.