fix dashboard grid test timing issue (#17250)

* add 50 extra pixel to move to ensure panel goes above first panel
This commit is contained in:
Nathan Reese 2018-03-19 20:51:56 -06:00 committed by Tyler Smalley
parent aa586c29ee
commit 4a501cb4d2

View file

@ -5,6 +5,26 @@ export default function ({ getService, getPageObjects }) {
const remote = getService('remote');
const PageObjects = getPageObjects(['dashboard', 'header', 'common']);
const VIS_TITLES = [
PageObjects.dashboard.getTestVisualizationNames()[0],
PageObjects.dashboard.getTestVisualizationNames()[1],
PageObjects.dashboard.getTestVisualizationNames()[2],
];
// Order returned by find.allByCssSelector is not guaranteed and can change based on timing
// Use this function to avoid looking for elements by hard-coded array index.
const getPanelTitleElement = async (title) => {
const panelTitleElements = await find.allByCssSelector('.panel-title');
for (let i = 0; i < panelTitleElements.length; i++) {
const panelText = await panelTitleElements[i].getVisibleText();
if (panelText === title) {
return panelTitleElements[i];
}
}
throw new Error(`Unable to find panel with title: "${title}"`);
};
describe('dashboard grid', () => {
before(async () => {
@ -21,25 +41,21 @@ export default function ({ getService, getPageObjects }) {
// Specific test after https://github.com/elastic/kibana/issues/14764 fix
it('Can move panel from bottom to top row', async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.addVisualizations([
PageObjects.dashboard.getTestVisualizationNames()[0],
PageObjects.dashboard.getTestVisualizationNames()[1],
PageObjects.dashboard.getTestVisualizationNames()[2],
]);
await PageObjects.dashboard.addVisualizations(VIS_TITLES);
const panels = await find.allByCssSelector('.panel-title');
const lastVisTitle = VIS_TITLES[VIS_TITLES.length - 1];
const thirdPanel = panels[2];
const position1 = await thirdPanel.getPosition();
const panelTitleBeforeMove = await getPanelTitleElement(lastVisTitle);
const position1 = await panelTitleBeforeMove.getPosition();
remote
.moveMouseTo(thirdPanel)
.moveMouseTo(panelTitleBeforeMove)
.pressMouseButton()
.moveMouseTo(null, -20, -400)
.moveMouseTo(null, -20, -450)
.releaseMouseButton();
const panelsMoved = await find.allByCssSelector('.panel-title');
const position2 = await panelsMoved[2].getPosition();
const panelTitleAfterMove = await getPanelTitleElement(lastVisTitle);
const position2 = await panelTitleAfterMove.getPosition();
expect(position1.y).to.be.greaterThan(position2.y);
});