mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
E2E: Fixed so openPanelMenuItem flow works with new/old panel chrome without breaking changes (#66118)
Fixed so the openPanelMenuItem works with both angular and react panels.
This commit is contained in:
@@ -17,7 +17,7 @@ e2e.scenario({
|
|||||||
e2e.flows.openDashboard({ uid: 'TkZXxlNG3' });
|
e2e.flows.openDashboard({ uid: 'TkZXxlNG3' });
|
||||||
e2e().wait('@query');
|
e2e().wait('@query');
|
||||||
|
|
||||||
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST, true);
|
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST);
|
||||||
|
|
||||||
// New panel editor opens when navigating from Panel menu
|
// New panel editor opens when navigating from Panel menu
|
||||||
e2e.components.PanelEditor.General.content().should('be.visible');
|
e2e.components.PanelEditor.General.content().should('be.visible');
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ e2e.scenario({
|
|||||||
e2e.flows.openDashboard({ uid: 'wfTJJL5Wz' });
|
e2e.flows.openDashboard({ uid: 'wfTJJL5Wz' });
|
||||||
|
|
||||||
// testing opening inspect drawer directly by clicking on Inspect in header menu
|
// testing opening inspect drawer directly by clicking on Inspect in header menu
|
||||||
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Inspect, PANEL_UNDER_TEST, true);
|
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Inspect, PANEL_UNDER_TEST);
|
||||||
|
|
||||||
expectDrawerTabsAndContent();
|
expectDrawerTabsAndContent();
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ e2e.scenario({
|
|||||||
expectSubMenuScenario('Query');
|
expectSubMenuScenario('Query');
|
||||||
expectSubMenuScenario('Panel JSON', 'JSON');
|
expectSubMenuScenario('Panel JSON', 'JSON');
|
||||||
|
|
||||||
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST, true);
|
e2e.flows.openPanelMenuItem(e2e.flows.PanelMenuItems.Edit, PANEL_UNDER_TEST);
|
||||||
|
|
||||||
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
|
e2e.components.QueryTab.queryInspectorButton().should('be.visible').click();
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,51 @@ export enum PanelMenuItems {
|
|||||||
Extensions = 'Extensions',
|
Extensions = 'Extensions',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const openPanelMenuItem = (menu: PanelMenuItems, panelTitle = 'Panel Title', isReactPanel = false) => {
|
export const openPanelMenuItem = (menu: PanelMenuItems, panelTitle = 'Panel Title') => {
|
||||||
// we changed the way we open the panel menu in react panels with the new panel header
|
// we changed the way we open the panel menu in react panels with the new panel header
|
||||||
if (isReactPanel) {
|
detectPanelType(panelTitle, (isAngularPanel) => {
|
||||||
e2e.components.Panels.Panel.menu(panelTitle).click({ force: true }); // force click because menu is hidden and show on hover
|
if (isAngularPanel) {
|
||||||
e2e.components.Panels.Panel.menuItems(menu).should('be.visible').click();
|
e2e.components.Panels.Panel.title(panelTitle).should('be.visible').click();
|
||||||
} else {
|
e2e.components.Panels.Panel.headerItems(menu).should('be.visible').click();
|
||||||
// this is the old way of opening the panel menu from the title
|
} else {
|
||||||
e2e.components.Panels.Panel.title(panelTitle).should('be.visible').click();
|
e2e.components.Panels.Panel.menu(panelTitle).click({ force: true }); // force click because menu is hidden and show on hover
|
||||||
e2e.components.Panels.Panel.headerItems(menu).should('be.visible').click();
|
e2e.components.Panels.Panel.menuItems(menu).should('be.visible').click();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openPanelMenuExtension = (extensionTitle: string, panelTitle = 'Panel Title') => {
|
export const openPanelMenuExtension = (extensionTitle: string, panelTitle = 'Panel Title') => {
|
||||||
e2e.components.Panels.Panel.title(panelTitle).should('be.visible').click();
|
const menuItem = PanelMenuItems.Extensions;
|
||||||
|
// we changed the way we open the panel menu in react panels with the new panel header
|
||||||
e2e.components.Panels.Panel.headerItems(PanelMenuItems.Extensions)
|
detectPanelType(panelTitle, (isAngularPanel) => {
|
||||||
.should('be.visible')
|
if (isAngularPanel) {
|
||||||
.parent()
|
e2e.components.Panels.Panel.title(panelTitle).should('be.visible').click();
|
||||||
.parent()
|
e2e.components.Panels.Panel.headerItems(menuItem)
|
||||||
.invoke('addClass', 'open');
|
.should('be.visible')
|
||||||
|
.parent()
|
||||||
e2e.components.Panels.Panel.headerItems(extensionTitle).should('be.visible').click();
|
.parent()
|
||||||
|
.invoke('addClass', 'open');
|
||||||
|
e2e.components.Panels.Panel.headerItems(extensionTitle).should('be.visible').click();
|
||||||
|
} else {
|
||||||
|
e2e.components.Panels.Panel.menu(panelTitle).click({ force: true }); // force click because menu is hidden and show on hover
|
||||||
|
e2e.components.Panels.Panel.menuItems(menuItem).trigger('mouseover', { force: true });
|
||||||
|
e2e.components.Panels.Panel.menuItems(extensionTitle).click({ force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function detectPanelType(panelTitle: string, detected: (isAngularPanel: boolean) => void) {
|
||||||
|
e2e.components.Panels.Panel.title(panelTitle).then((el) => {
|
||||||
|
const isAngularPanel = el.find('plugin-component.ng-scope').length > 0;
|
||||||
|
|
||||||
|
if (isAngularPanel) {
|
||||||
|
Cypress.log({
|
||||||
|
name: 'detectPanelType',
|
||||||
|
displayName: 'detector',
|
||||||
|
message: 'Angular panel detected, will use legacy selectors.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
detected(isAngularPanel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -197,7 +197,11 @@ export class PanelChromeAngularUnconnected extends PureComponent<Props, State> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={containerClassNames} aria-label={selectors.components.Panels.Panel.containerByTitle(panel.title)}>
|
<div
|
||||||
|
className={containerClassNames}
|
||||||
|
data-testid={selectors.components.Panels.Panel.title(panel.title)}
|
||||||
|
aria-label={selectors.components.Panels.Panel.containerByTitle(panel.title)}
|
||||||
|
>
|
||||||
<PanelHeader
|
<PanelHeader
|
||||||
panel={panel}
|
panel={panel}
|
||||||
dashboard={dashboard}
|
dashboard={dashboard}
|
||||||
|
|||||||
Reference in New Issue
Block a user