[Flaky test fix] Turn back on data_shared_attributes test (#25156)

* Turn back on data_shared_attributes test and run 20x

* Add some clean up

* Be more determinism, less refactoring.

* Go back to a single test run
This commit is contained in:
Stacey Gammon 2018-11-12 14:47:24 -05:00 committed by GitHub
parent a6818b392d
commit 1eaca25472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 89 additions and 128 deletions

View file

@ -22,6 +22,7 @@ exports[`DashboardPanel matches snapshot 1`] = `
>
<div
class="euiPopover euiPopover--anchorDownRight euiPopover--withTitle dshPanel_optionsMenuPopover"
data-test-subj="dashboardPanelContextMenuClosed"
id="dashboardPanelContextMenu"
>
<div

View file

@ -61,6 +61,9 @@ export function PanelOptionsMenu({
closePopover={closeContextMenu}
panelPaddingSize="none"
anchorPosition="downRight"
data-test-subj={
isPopoverOpen ? 'dashboardPanelContextMenuOpen' : 'dashboardPanelContextMenuClosed'
}
withTitle
>
<EuiContextMenu initialPanelId="mainMenu" panels={panels} />

View file

@ -240,6 +240,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.waitForRenderComplete();
await dashboardExpect.pieSliceCount(5);
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await queryBar.setQuery('weightLbs:>50');
await queryBar.submitQuery();
@ -259,6 +260,7 @@ export default function ({ getService, getPageObjects }) {
});
it('Nested visualization filter pills filters data as expected', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();
@ -273,6 +275,7 @@ export default function ({ getService, getPageObjects }) {
});
it('Removing filter pills and query unfiters data as expected', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.header.waitUntilLoadingHasFinished();
await renderable.waitForRender();

View file

@ -50,7 +50,8 @@ export default function ({ getService, getPageObjects, updateBaselines }) {
await PageObjects.common.closeToast();
await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
await PageObjects.dashboard.waitForRenderComplete();
const percentSimilar = await screenshot.compareAgainstBaseline('tsvb_dashboard', updateBaselines);
@ -70,7 +71,8 @@ export default function ({ getService, getPageObjects, updateBaselines }) {
await PageObjects.common.closeToast();
await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
await PageObjects.dashboard.waitForRenderComplete();
const percentSimilar = await screenshot.compareAgainstBaseline('area_chart', updateBaselines);

View file

@ -130,6 +130,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.visualize.closeInspector();
await PageObjects.dashboard.switchToEditMode();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.visualize.clickMapZoomIn();

View file

@ -89,8 +89,7 @@ export default function ({ getService, getPageObjects }) {
});
});
// TODO: flaky https://github.com/elastic/kibana/issues/24287
it.skip('data-shared-item title should update a saved search when using a custom panel title', async () => {
it('data-shared-item title should update a saved search when using a custom panel title', async () => {
const CUSTOM_SEARCH_TITLE = 'ima custom title for a search!';
await dashboardPanelActions.setCustomPanelTitle(CUSTOM_SEARCH_TITLE, 'Rendering Test: saved search');
await retry.try(async () => {

View file

@ -60,7 +60,8 @@ export default function ({ getService, getPageObjects }) {
});
it('displays exit full screen logo button when panel is expanded', async () => {
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
const exists = await PageObjects.dashboard.exitFullScreenTextButtonExists();
expect(exists).to.be(true);

View file

@ -61,11 +61,8 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.saveDashboard(dashboardName);
await dashboardPanelActions.openContextMenu();
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
const removeExists = await dashboardPanelActions.removePanelActionExists();
expect(editLinkExists).to.equal(false);
expect(removeExists).to.equal(false);
await dashboardPanelActions.expectMissingEditPanelAction();
await dashboardPanelActions.expectMissingRemovePanelAction();
});
it('are shown in edit mode', async function () {
@ -75,11 +72,8 @@ export default function ({ getService, getPageObjects }) {
expect(isContextMenuIconVisible).to.equal(true);
await dashboardPanelActions.openContextMenu();
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
const removeExists = await dashboardPanelActions.removePanelActionExists();
expect(editLinkExists).to.equal(true);
expect(removeExists).to.equal(true);
await dashboardPanelActions.expectExistsEditPanelAction();
await dashboardPanelActions.expectExistsRemovePanelAction();
});
// Based off an actual bug encountered in a PR where a hard refresh in edit mode did not show the edit mode
@ -91,11 +85,8 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.waitUntilLoadingHasFinished();
await dashboardPanelActions.openContextMenu();
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
expect(editLinkExists).to.equal(true);
const removeExists = await dashboardPanelActions.removePanelActionExists();
expect(removeExists).to.equal(true);
await dashboardPanelActions.expectExistsEditPanelAction();
await dashboardPanelActions.expectExistsRemovePanelAction();
// Get rid of the timestamp in the url.
await remote.get(currentUrl.toString(), false);
@ -104,26 +95,19 @@ export default function ({ getService, getPageObjects }) {
describe('on an expanded panel', function () {
it('are hidden in view mode', async function () {
await PageObjects.dashboard.saveDashboard(dashboardName);
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
const removeExists = await dashboardPanelActions.removePanelActionExists();
expect(editLinkExists).to.equal(false);
expect(removeExists).to.equal(false);
await dashboardPanelActions.clickExpandPanelToggle();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.expectMissingEditPanelAction();
await dashboardPanelActions.expectMissingRemovePanelAction();
});
it('in edit mode hides remove icons ', async function () {
await PageObjects.dashboard.switchToEditMode();
await dashboardPanelActions.openContextMenu();
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
const removeExists = await dashboardPanelActions.removePanelActionExists();
expect(editLinkExists).to.equal(true);
expect(removeExists).to.equal(false);
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.expectExistsEditPanelAction();
await dashboardPanelActions.expectMissingRemovePanelAction();
await dashboardPanelActions.clickExpandPanelToggle();
});
});
@ -160,6 +144,7 @@ export default function ({ getService, getPageObjects }) {
});
it('opens a saved search when edit link is clicked', async () => {
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickEdit();
await PageObjects.header.waitUntilLoadingHasFinished();
const queryName = await PageObjects.discover.getCurrentQueryName();
@ -182,8 +167,7 @@ export default function ({ getService, getPageObjects }) {
it('shown in edit mode', async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
await dashboardPanelActions.openContextMenu();
const expandExists = await dashboardPanelActions.toggleExpandActionExists();
expect(expandExists).to.equal(true);
await dashboardPanelActions.expectExistsToggleExpandAction();
});
});
});

View file

@ -30,7 +30,8 @@ export default function ({ getService, getPageObjects }) {
});
it('hides other panels', async () => {
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
await retry.try(async () => {
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.eql(1);
@ -40,8 +41,10 @@ export default function ({ getService, getPageObjects }) {
it('shows other panels after being minimized', async () => {
const panelCount = await PageObjects.dashboard.getPanelCount();
// Panels are all minimized on a fresh open of a dashboard, so we need to re-expand in order to then minimize.
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.toggleExpandPanel();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
await dashboardPanelActions.openContextMenu();
await dashboardPanelActions.clickExpandPanelToggle();
// Add a retry to fix https://github.com/elastic/kibana/issues/14574. Perhaps the recent changes to this

View file

@ -125,24 +125,25 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
*/
async onDashboardLandingPage() {
log.debug(`onDashboardLandingPage`);
const exists = await testSubjects.exists('dashboardLandingPage');
return exists;
return await testSubjects.exists('dashboardLandingPage', 5000);
}
async expectExistsDashboardLandingPage() {
log.debug(`expectExistsDashboardLandingPage`);
await testSubjects.existOrFail('dashboardLandingPage');
}
async clickDashboardBreadcrumbLink() {
log.debug('clickDashboardBreadcrumbLink');
await find.clickByCssSelector(`a[href="#${DashboardConstants.LANDING_PAGE_PATH}"]`);
await this.expectExistsDashboardLandingPage();
}
async gotoDashboardLandingPage() {
log.debug('gotoDashboardLandingPage');
const onPage = await this.onDashboardLandingPage();
if (!onPage) {
await retry.try(async () => {
await this.clickDashboardBreadcrumbLink();
const onDashboardLandingPage = await this.onDashboardLandingPage();
if (!onDashboardLandingPage) throw new Error('Not on the landing page.');
});
await this.clickDashboardBreadcrumbLink();
}
}
@ -432,16 +433,10 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
await this.gotoDashboardLandingPage();
await retry.try(async () => {
await this.searchForDashboardWithName(dashName);
await this.selectDashboard(dashName);
await PageObjects.header.waitUntilLoadingHasFinished();
await this.searchForDashboardWithName(dashName);
await this.selectDashboard(dashName);
await PageObjects.header.waitUntilLoadingHasFinished();
const onDashboardLandingPage = await this.onDashboardLandingPage();
if (onDashboardLandingPage) {
throw new Error('Failed to open the dashboard up');
}
});
}
async getPanelTitles() {

View file

@ -26,19 +26,12 @@ const OPEN_INSPECTOR_TEST_SUBJ = 'dashboardPanelAction-openInspector';
export function DashboardPanelActionsProvider({ getService, getPageObjects }) {
const log = getService('log');
const retry = getService('retry');
const remote = getService('remote');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['header', 'common']);
return new class DashboardPanelActions {
async isContextMenuOpen(parent) {
log.debug('isContextMenuOpen');
// Full screen toggle was chosen because it's available in both view and edit mode.
return this.toggleExpandActionExists(parent);
}
async findContextMenu(parent) {
return parent ?
await testSubjects.findDescendant(OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ, parent) :
@ -50,52 +43,31 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) {
return await testSubjects.exists(OPEN_CONTEXT_MENU_ICON_DATA_TEST_SUBJ);
}
async openContextMenu(parent) {
log.debug(`openContextMenu(${parent}`);
const panelOpen = await this.isContextMenuOpen(parent);
if (!panelOpen) {
await retry.try(async () => {
await (parent ? remote.moveMouseTo(parent) : testSubjects.moveMouseTo('dashboardPanelTitle'));
const toggleMenuItem = await this.findContextMenu(parent);
await toggleMenuItem.click();
const panelOpen = await this.isContextMenuOpen(parent);
if (!panelOpen) { throw new Error('Context menu still not open'); }
});
}
async toggleContextMenu(parent) {
log.debug('toggleContextMenu');
await (parent ? remote.moveMouseTo(parent) : testSubjects.moveMouseTo('dashboardPanelTitle'));
const toggleMenuItem = await this.findContextMenu(parent);
await toggleMenuItem.click();
}
async toggleExpandPanel(parent) {
log.debug('toggleExpandPanel');
await (parent ? remote.moveMouseTo(parent) : testSubjects.moveMouseTo('dashboardPanelTitle'));
const expandShown = await this.toggleExpandActionExists();
if (!expandShown) {
await this.openContextMenu(parent);
}
await this.toggleExpandPanel();
async expectContextMenuToBeOpen() {
await testSubjects.existOrFail('dashboardPanelContextMenuOpen');
}
async openContextMenu(parent) {
log.debug(`openContextMenu(${parent}`);
await this.toggleContextMenu(parent);
await this.expectContextMenuToBeOpen();
}
async clickEdit() {
log.debug('clickEdit');
await this.openContextMenu();
// Edit link may sometimes be disabled if the embeddable isn't rendered yet.
await retry.try(async () => {
const editExists = await this.editPanelActionExists();
if (editExists) {
await testSubjects.click(EDIT_PANEL_DATA_TEST_SUBJ);
}
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.waitForTopNavToBeVisible();
const current = await remote.getCurrentUrl();
if (current.indexOf('dashboard') >= 0) {
throw new Error('Still on dashboard');
}
});
await testSubjects.clickWhenNotDisabled(EDIT_PANEL_DATA_TEST_SUBJ);
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.common.waitForTopNavToBeVisible();
}
async toggleExpandPanel() {
log.debug('toggleExpandPanel');
await this.openContextMenu();
async clickExpandPanelToggle() {
await testSubjects.click(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
}
@ -121,25 +93,29 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) {
await testSubjects.click(OPEN_INSPECTOR_TEST_SUBJ);
}
async removePanelActionExists() {
log.debug('removePanelActionExists');
return await testSubjects.exists(REMOVE_PANEL_DATA_TEST_SUBJ);
async expectExistsRemovePanelAction() {
log.debug('expectExistsRemovePanelAction');
await testSubjects.existOrFail(REMOVE_PANEL_DATA_TEST_SUBJ);
}
async editPanelActionExists() {
log.debug('editPanelActionExists');
return await testSubjects.exists(EDIT_PANEL_DATA_TEST_SUBJ);
async expectMissingRemovePanelAction() {
log.debug('expectMissingRemovePanelAction');
await testSubjects.missingOrFail(REMOVE_PANEL_DATA_TEST_SUBJ);
}
async toggleExpandActionExists() {
log.debug('toggleExpandActionExists');
return await testSubjects.exists(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
async expectExistsEditPanelAction() {
log.debug('expectExistsEditPanelAction');
await testSubjects.existOrFail(EDIT_PANEL_DATA_TEST_SUBJ);
}
async customizePanelActionExists(parent) {
return parent ?
await testSubjects.descendantExists(CUSTOMIZE_PANEL_DATA_TEST_SUBJ, parent) :
await testSubjects.exists(CUSTOMIZE_PANEL_DATA_TEST_SUBJ);
async expectMissingEditPanelAction() {
log.debug('expectMissingEditPanelAction');
await testSubjects.missingOrFail(EDIT_PANEL_DATA_TEST_SUBJ);
}
async expectExistsToggleExpandAction() {
log.debug('expectExistsToggleExpandAction');
await testSubjects.existOrFail(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
}
async getPanelHeading(title) {
@ -160,12 +136,14 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }) {
}
await this.customizePanel(panelOptions);
await testSubjects.setValue('customDashboardPanelTitleInput', customTitle);
await this.toggleContextMenu(panelOptions);
}
async resetCustomPanelTitle(panel) {
log.debug('resetCustomPanelTitle');
await this.customizePanel(panel);
await testSubjects.click('resetCustomDashboardPanelTitle');
await this.toggleContextMenu(panel);
}
};
}

View file

@ -17,8 +17,6 @@
* under the License.
*/
import expect from 'expect.js';
export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const testSubjects = getService('testSubjects');
@ -31,24 +29,19 @@ export default function ({ getService, getPageObjects }) {
it('Sample action appears in context menu in view mode', async () => {
await dashboardPanelActions.openContextMenu();
const newPanelActionExists = await testSubjects.exists(
await testSubjects.existOrFail(
'dashboardPanelAction-samplePanelAction'
);
expect(newPanelActionExists).to.be(true);
});
it('Clicking sample action shows a flyout', async () => {
await dashboardPanelActions.openContextMenu();
await testSubjects.click('dashboardPanelAction-samplePanelAction');
const flyoutExists = await testSubjects.exists('samplePanelActionFlyout');
expect(flyoutExists).to.be(true);
await testSubjects.existOrFail('samplePanelActionFlyout');
});
it('flyout shows the correct contents', async () => {
const titleExists = await testSubjects.exists('samplePanelActionTitle');
expect(titleExists).to.be(true);
const bodyExists = await testSubjects.exists('samplePanelActionBody');
expect(bodyExists).to.be(true);
await testSubjects.existOrFail('samplePanelActionTitle');
await testSubjects.existOrFail('samplePanelActionBody');
});
});
}

View file

@ -163,13 +163,11 @@ export default function ({ getService, getPageObjects }) {
});
it('does not show the visualization edit icon', async () => {
const editLinkExists = await dashboardPanelActions.editPanelActionExists();
expect(editLinkExists).to.be(false);
await dashboardPanelActions.expectMissingEditPanelAction();
});
it('does not show the visualization delete icon', async () => {
const deleteIconExists = await dashboardPanelActions.removePanelActionExists();
expect(deleteIconExists).to.be(false);
await dashboardPanelActions.expectMissingRemovePanelAction();
});
it('shows the timepicker', async () => {