Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky functional test in saved objects managements -> delete SO #115291

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,22 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const focusAndClickButton = async (buttonSubject: string) => {
const button = await testSubjects.find(buttonSubject);
await button.scrollIntoViewIfNecessary();
await delay(10);
await delay(100);
await button.focus();
await delay(10);
await delay(100);
await button.click();
// Allow some time for the transition/animations to occur before assuming the click is done
await delay(10);
await delay(100);
};

const textIncludesAll = (text: string, items: string[]) => {
const bools = items.map((item) => !!text.includes(item));
return bools.every((currBool) => currBool === true);
};

// FLAKY: https://github.com/elastic/kibana/issues/68400
TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
describe.skip('saved objects edition page', () => {
// describe.skip('saved objects inspect page', () => {
TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
describe('saved objects inspect page', () => {
beforeEach(async () => {
await esArchiver.load(
'test/functional/fixtures/es_archiver/saved_objects_management/edit_saved_object'
Expand All @@ -48,9 +50,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('allows to view the saved object', async () => {
await PageObjects.settings.navigateTo();

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
await PageObjects.settings.clickKibanaSavedObjects();

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
const objects = await PageObjects.savedObjects.getRowTitles();
expect(objects.includes('A Dashboard')).to.be(true);

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
await PageObjects.common.navigateToUrl('management', 'kibana/objects/dashboard/i-exist', {
shouldUseHashForSubUrl: false,
});
Expand All @@ -71,9 +76,12 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {

it('allows to delete a saved object', async () => {
await PageObjects.settings.navigateTo();

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
await PageObjects.settings.clickKibanaSavedObjects();

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
let objects = await PageObjects.savedObjects.getRowTitles();
expect(objects.includes('A Dashboard')).to.be(true);

TinaHeiligers marked this conversation as resolved.
Show resolved Hide resolved
await PageObjects.savedObjects.clickInspectByTitle('A Dashboard');
await PageObjects.common.navigateToUrl('management', 'kibana/objects/dashboard/i-exist', {
shouldUseHashForSubUrl: false,
Expand Down
36 changes: 27 additions & 9 deletions test/functional/page_objects/management/saved_objects_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { keyBy } from 'lodash';
import { map as mapAsync } from 'bluebird';
import { delay, map as mapAsync } from 'bluebird';
import { FtrService } from '../../ftr_provider_context';

export class SavedObjectsPageObject extends FtrService {
Expand All @@ -18,6 +18,8 @@ export class SavedObjectsPageObject extends FtrService {
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly common = this.ctx.getPageObject('common');
private readonly header = this.ctx.getPageObject('header');
private readonly config = this.ctx.getService('config');
private readonly defaultTryTimeout = this.config.get('timeouts.try');

async searchForObject(objectName: string) {
const searchBox = await this.testSubjects.find('savedObjectSearchBar');
Expand Down Expand Up @@ -98,15 +100,22 @@ export class SavedObjectsPageObject extends FtrService {
await this.testSubjects.click('importSavedObjectsConfirmBtn');
}

async sleep(sleepMilliseconds: number) {
this.log.debug(`... sleep(${sleepMilliseconds}) start`);
await delay(sleepMilliseconds);
this.log.debug(`... sleep(${sleepMilliseconds}) end`);
}

async waitTableIsLoaded() {
return this.retry.try(async () => {
await this.sleep(501);
return await this.retry.tryForTime(this.defaultTryTimeout * 2, async () => {
const isLoaded = await this.find.existsByDisplayedByCssSelector(
'*[data-test-subj="savedObjectsTable"] :not(.euiBasicTable-loading)'
);

if (isLoaded) {
return true;
} else {
this.log.debug(`still waiting for the table to load ${isLoaded}`);
throw new Error('Waiting');
}
});
Expand Down Expand Up @@ -157,15 +166,20 @@ export class SavedObjectsPageObject extends FtrService {
}

async clickInspectByTitle(title: string) {
this.log.debug(`inspecting ${title} object through the context menu`);
const table = keyBy(await this.getElementsInTable(), 'title');
if (table[title].menuElement) {
this.log.debug(`${title} has a menuElement`);
await table[title].menuElement?.click();
// Wait for context menu to render
const menuPanel = await this.find.byCssSelector('.euiContextMenuPanel');
const panelButton = await menuPanel.findByTestSubject('savedObjectsTableAction-inspect');
await panelButton.click();
} else {
// or the action elements are on the row without the menu
this.log.debug(
`${title} doesn't have a menu element, trying to copy the object instead using`
);
await table[title].copySaveObjectsElement?.click();
}
}
Expand Down Expand Up @@ -232,12 +246,16 @@ export class SavedObjectsPageObject extends FtrService {
}

async getRowTitles() {
await this.waitTableIsLoaded();
const table = await this.testSubjects.find('savedObjectsTable');
const $ = await table.parseDomContent();
return $.findTestSubjects('savedObjectsTableRowTitle')
.toArray()
.map((cell) => $(cell).find('.euiTableCellContent').text());
const isLoaded = await this.waitTableIsLoaded();
if (isLoaded) {
const table = await this.testSubjects.find('savedObjectsTable');
const $ = await table.parseDomContent();
return $.findTestSubjects('savedObjectsTableRowTitle')
.toArray()
.map((cell) => $(cell).find('.euiTableCellContent').text());
} else {
return ['Nothing Found'];
}
}

async getRelationshipFlyout() {
Expand Down