Commit 1c865b5b by Steven Vachon Committed by GitHub

@grafana/e2e: timing improvements (#27861)

parent 7c299970
...@@ -127,23 +127,15 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC ...@@ -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); 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 (!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 // `panelTitle` is needed to edit the panel, and unlikely to have its value changed at that point
const changeTitle = panelTitle && !isEdit; const changeTitle = panelTitle && !isEdit;
...@@ -164,6 +156,9 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC ...@@ -164,6 +156,9 @@ export const configurePanel = (config: PartialAddPanelConfig | PartialEditPanelC
e2e.components.PluginVisualization.item(visualizationName) e2e.components.PluginVisualization.item(visualizationName)
.scrollIntoView() .scrollIntoView()
.click(); .click();
// @todo wait for '@pluginModule' if not a core visualization and not already loaded
e2e().wait(2000);
} }
// Consistently closed // Consistently closed
...@@ -245,6 +240,25 @@ const closeOptionsGroup = (name: string): any => ...@@ -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}"])`); const getOptionsGroup = (name: string) => e2e().get(`.options-group:has([aria-label="Options group Panel ${name}"])`);
// @todo this actually returns type `Cypress.Chainable` // @todo this actually returns type `Cypress.Chainable`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment