From 1c865b5bcb1eaaf4955332372ba8839192a99bcf Mon Sep 17 00:00:00 2001 From: Steven Vachon Date: Mon, 5 Oct 2020 14:19:53 -0400 Subject: [PATCH] @grafana/e2e: timing improvements (#27861) --- .../grafana-e2e/src/flows/configurePanel.ts | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/grafana-e2e/src/flows/configurePanel.ts b/packages/grafana-e2e/src/flows/configurePanel.ts index ed078c606fb..1067e18a6f8 100644 --- a/packages/grafana-e2e/src/flows/configurePanel.ts +++ b/packages/grafana-e2e/src/flows/configurePanel.ts @@ -127,23 +127,15 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC }); } - // @todo instead wait for '@pluginModule' + // @todo instead wait for '@pluginModule' if not already loaded e2e().wait(2000); - // There is no usable data when the query is empty, - // and Cypress had an issue with some plugins where the request wasn't noticed, despite occuring in manual tests - if (isEdit) { - // Avoid cache flakiness (where @chartData isn't requested) - // @todo this may not be necessary anymore - e2e() - .get('.refresh-picker-buttons .btn') - .first() - .click({ force: true }); - - e2e().wait('@chartData'); - } - if (!isExplore) { + if (!isEdit) { + // Fields could be covered due to an empty query editor + closeRequestErrors(); + } + // `panelTitle` is needed to edit the panel, and unlikely to have its value changed at that point const changeTitle = panelTitle && !isEdit; @@ -164,6 +156,9 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC e2e.components.PluginVisualization.item(visualizationName) .scrollIntoView() .click(); + + // @todo wait for '@pluginModule' if not a core visualization and not already loaded + e2e().wait(2000); } // Consistently closed @@ -245,6 +240,25 @@ const closeOptionsGroup = (name: string): any => } }); +const closeRequestErrors = () => { + e2e().wait(1000); // emulate `cy.get()` for nested errors + e2e() + .get('app-notifications-list') + .then($elm => { + // Avoid failing when none are found + const selector = '[aria-label="Alert error"]:contains("Failed to call resource")'; + const numErrors = $elm.find(selector).length; + + for (let i = 0; i < numErrors; i++) { + e2e() + .get(selector) + .first() + .find('button') + .click(); + } + }); +}; + const getOptionsGroup = (name: string) => e2e().get(`.options-group:has([aria-label="Options group Panel ${name}"])`); // @todo this actually returns type `Cypress.Chainable`