Skip to content

Commit

Permalink
[Maps] unskip X-Pack Saved Object Tagging Functional Tests.x-pack/tes…
Browse files Browse the repository at this point in the history
…t/saved_object_tagging/functional/tests/maps_integration·ts - saved objects tagging (elastic#149356)

Fixes elastic#89073 and
elastic#106547

Flaky test runner
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/1785

Issue with flaky maps_integration.ts is that there was not await when
filtering maps list by tags. This resulted in list page refreshing after
`const links = await
this.find.allByCssSelector('.euiTableRow-isSelectable .euiLink');` and
then getting an elemented unmounted on future `await
links[i].getVisibleText()` calls.

A [similar fix](elastic#82930) was
implemented for visualize and dashboard listing pages.

elastic#82930 introduced
`listingTable.waitUntilTableIsLoaded` but did not introduce the method
in a consistent way. Other methods that search table were not updated to
use `listingTable.waitUntilTableIsLoaded`, but instead used
`this.header.waitUntilLoadingHasFinished()`. This PR resolved this issue
by updating all listingTable methods that search to use
`listingTable.waitUntilTableIsLoaded` and then updated
`listingTable.waitUntilTableIsLoaded` with a call to
`this.header.waitUntilLoadingHasFinished()`

elastic#82930 did not update
maps_integration tests, only resolving the issue for visualize and
dashboard. To avoid future situations where fixes only resolve a few
usages, this PR moves selectFilterTags into listing_table and replaces
all implementations of selectFilterTags with
listingTable.selectFilterTags.

While investigating dashboard_integrations test, I found
`x-pack/test/functional/apps/dashboard/group2/dashboard_tagging.ts`,
which duplicated most of dashboard_integrations test. This PR removes
x-pack/test/functional/apps/dashboard/group2/dashboard_tagging.ts adds
the unique test case to dashboard_integrations

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
2 people authored and kqualters-elastic committed Feb 6, 2023
1 parent 603ab24 commit 21b3d37
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 203 deletions.
36 changes: 33 additions & 3 deletions test/functional/services/listing_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ export class ListingTableService extends FtrService {
private readonly common = this.ctx.getPageObject('common');
private readonly header = this.ctx.getPageObject('header');

private readonly tagPopoverToggle = this.ctx.getService('menuToggle').create({
name: 'Tag Popover',
menuTestSubject: 'tagSelectableList',
toggleButtonTestSubject: 'tagFilterPopoverButton',
});

private async getSearchFilter() {
return await this.testSubjects.find('tableListSearchBox');
}
Expand Down Expand Up @@ -72,6 +78,7 @@ export class ListingTableService extends FtrService {
} else {
throw new Error('Waiting');
}
await this.header.waitUntilLoadingHasFinished();
});
}

Expand All @@ -92,12 +99,35 @@ export class ListingTableService extends FtrService {
);
if (morePages) {
await this.testSubjects.click('pagerNextButton');
await this.header.waitUntilLoadingHasFinished();
await this.waitUntilTableIsLoaded();
}
}
return visualizationNames;
}

/**
* Select tags in the searchbar's tag filter.
*/
public async selectFilterTags(...tagNames: string[]): Promise<void> {
await this.openTagPopover();
// select the tags
for (const tagName of tagNames) {
await this.testSubjects.click(`tag-searchbar-option-${tagName.replace(' ', '_')}`);
}
await this.closeTagPopover();
await this.waitUntilTableIsLoaded();
}

public async openTagPopover(): Promise<void> {
this.log.debug('ListingTable.openTagPopover');
await this.tagPopoverToggle.open();
}

public async closeTagPopover(): Promise<void> {
this.log.debug('ListingTable.closeTagPopover');
await this.tagPopoverToggle.close();
}

/**
* Navigates through all pages on Landing page and returns array of items names
*/
Expand All @@ -112,7 +142,7 @@ export class ListingTableService extends FtrService {
);
if (morePages) {
await this.testSubjects.click('pagerNextButton');
await this.header.waitUntilLoadingHasFinished();
await this.waitUntilTableIsLoaded();
}
}
return visualizationNames;
Expand Down Expand Up @@ -154,7 +184,7 @@ export class ListingTableService extends FtrService {
await this.common.pressEnterKey();
});

await this.header.waitUntilLoadingHasFinished();
await this.waitUntilTableIsLoaded();
}

/**
Expand Down
102 changes: 0 additions & 102 deletions x-pack/test/functional/apps/dashboard/group2/dashboard_tagging.ts

This file was deleted.

1 change: 0 additions & 1 deletion x-pack/test/functional/apps/dashboard/group2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
describe('dashboard', function () {
loadTestFile(require.resolve('./sync_colors'));
loadTestFile(require.resolve('./_async_dashboard'));
loadTestFile(require.resolve('./dashboard_tagging'));
loadTestFile(require.resolve('./dashboard_lens_by_value'));
loadTestFile(require.resolve('./dashboard_maps_by_value'));
loadTestFile(require.resolve('./panel_titles'));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,14 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
import { TAGFILTER_DROPDOWN_SELECTOR } from './constants';

// eslint-disable-next-line import/no-default-export
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const listingTable = getService('listingTable');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['dashboard', 'tagManagement', 'common', 'header']);

/**
* Select tags in the searchbar's tag filter.
*/
const selectFilterTags = async (...tagNames: string[]) => {
// open the filter dropdown
const filterButton = await find.byCssSelector(TAGFILTER_DROPDOWN_SELECTOR);
await filterButton.click();
// select the tags
for (const tagName of tagNames) {
await testSubjects.click(
`tag-searchbar-option-${PageObjects.tagManagement.testSubjFriendly(tagName)}`
);
}
// click elsewhere to close the filter dropdown
const searchFilter = await find.byCssSelector('.euiPageTemplate .euiFieldSearch');
await searchFilter.click();
// wait until the table refreshes
await listingTable.waitUntilTableIsLoaded();
};
const PageObjects = getPageObjects(['dashboard', 'tagManagement', 'common']);

describe('dashboard integration', () => {
before(async () => {
Expand Down Expand Up @@ -76,15 +54,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});

it('allows to filter by selecting a tag in the filter menu', async () => {
await selectFilterTags('tag-3');
await listingTable.selectFilterTags('tag-3');

await listingTable.expectItemsCount('dashboard', 2);
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames.sort()).to.eql(['dashboard 2 (tag-3)', 'dashboard 3 (tag-1 and tag-3)']);
});

it('allows to filter by multiple tags', async () => {
await selectFilterTags('tag-2', 'tag-3');
await listingTable.selectFilterTags('tag-2', 'tag-3');

await listingTable.expectItemsCount('dashboard', 3);
const itemNames = await listingTable.getAllItemsNames();
Expand Down Expand Up @@ -113,7 +91,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-1');
await listingTable.selectFilterTags('tag-1');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('my-new-dashboard');
});
Expand Down Expand Up @@ -150,14 +128,13 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('my-new-tag');
await listingTable.selectFilterTags('my-new-tag');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('dashboard-with-new-tag');
});
});

// FLAKY: https://github.com/elastic/kibana/issues/106547
describe.skip('editing', () => {
describe('editing', () => {
beforeEach(async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardLandingPage();
Expand All @@ -176,7 +153,21 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-3');
await listingTable.selectFilterTags('tag-3');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('dashboard 4 with real data (tag-1)');
});

it('retains dashboard saved object tags after quicksave', async () => {
// edit and save dashboard
await PageObjects.dashboard.gotoDashboardEditMode('dashboard 4 with real data (tag-1)');
await PageObjects.dashboard.useMargins(false); // turn margins off to cause quicksave to be enabled
await PageObjects.dashboard.clickQuickSave();

// verify dashboard still has original tags
await PageObjects.dashboard.gotoDashboardLandingPage();
await listingTable.waitUntilTableIsLoaded();
await listingTable.selectFilterTags('tag-3');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('dashboard 4 with real data (tag-1)');
});
Expand Down
Loading

0 comments on commit 21b3d37

Please sign in to comment.