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

[8.5] Unskips visualize integration tests (#142917) #143375

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export class CommonPageObject extends FtrService {
async waitForSaveModalToClose() {
this.log.debug('Waiting for save modal to close');
await this.retry.try(async () => {
if (await this.testSubjects.exists('savedObjectSaveModal')) {
if (await this.testSubjects.exists('savedObjectSaveModal', { timeout: 5000 })) {
throw new Error('save modal still open');
}
});
Expand Down
33 changes: 33 additions & 0 deletions test/functional/services/listing_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export class ListingTableService extends FtrService {
return visualizationNames;
}

private async getAllSelectableItemsNamesOnCurrentPage(): Promise<string[]> {
const visualizationNames = [];
const links = await this.find.allByCssSelector('.euiTableRow-isSelectable .euiLink');
for (let i = 0; i < links.length; i++) {
visualizationNames.push(await links[i].getVisibleText());
}
this.log.debug(`Found ${visualizationNames.length} selectable visualizations on current page`);
return visualizationNames;
}

public async waitUntilTableIsLoaded() {
return this.retry.try(async () => {
const isLoaded = await this.find.existsByDisplayedByCssSelector(
Expand All @@ -65,6 +75,29 @@ export class ListingTableService extends FtrService {
});
}

/**
* Navigates through all pages on Landing page and returns array of items names that are selectable
* Added for visualize_integration saved object tagging tests
*/
public async getAllSelectableItemsNames(): Promise<string[]> {
this.log.debug('ListingTable.getAllItemsNames');
let morePages = true;
let visualizationNames: string[] = [];
while (morePages) {
visualizationNames = visualizationNames.concat(
await this.getAllSelectableItemsNamesOnCurrentPage()
);
morePages = !(
(await this.testSubjects.getAttribute('pagination-button-next', 'disabled')) === 'true'
);
if (morePages) {
await this.testSubjects.click('pagerNextButton');
await this.header.waitUntilLoadingHasFinished();
}
}
return visualizationNames;
}

/**
* Navigates through all pages on Landing page and returns array of items names
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
[{
"id": "tag-1",
"type": "tag",
"attributes": {
Expand All @@ -8,8 +8,7 @@
},
"references": [],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "tag-2",
"type": "tag",
Expand All @@ -20,8 +19,7 @@
},
"references": [],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "tag-3",
"type": "tag",
Expand All @@ -32,8 +30,18 @@
},
"references": [],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "myextratag",
"type": "tag",
"attributes": {
"name": "myextratag",
"description": "We need one more",
"color": "#000000"
},
"references": [],
"updated_at": "2021-06-17T18:57:58.076Z"
},
{
"id": "logstash-*",
"type": "index-pattern",
Expand All @@ -45,8 +53,7 @@
},
"references": [],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "vis-area-1",
"type": "visualization",
Expand All @@ -67,8 +74,7 @@
}
],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "vis-area-2",
"type": "visualization",
Expand All @@ -89,8 +95,7 @@
}
],
"updated_at": "2021-06-17T18:57:58.076Z"
}

},
{
"id": "vis-area-3",
"type": "visualization",
Expand All @@ -115,4 +120,4 @@
}
],
"updated_at": "2021-06-17T18:57:58.076Z"
}
}]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const listingTable = getService('listingTable');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['visualize', 'tagManagement', 'visEditor', 'common']);
const retry = getService('retry');
const PageObjects = getPageObjects([
'visualize',
'tagManagement',
'visEditor',
'common',
'header',
]);

/**
* Select tags in the searchbar's tag filter.
Expand Down Expand Up @@ -46,10 +53,40 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
}
await testSubjects.click('savedObjectTitle');
};
// creates a simple markdown vis with a tag provided.
const createSimpleMarkdownVis = async (opts: Record<string, string>) => {
const { visName, visText, tagName } = opts;
await PageObjects.visualize.navigateToNewVisualization();

await PageObjects.visualize.clickMarkdownWidget();
await PageObjects.visEditor.setMarkdownTxt(visText);
await PageObjects.visEditor.clickGo();

await PageObjects.visualize.ensureSavePanelOpen();
await PageObjects.visualize.setSaveModalValues(visName, {
saveAsNew: false,
redirectToOrigin: true,
});
if (tagName) {
await selectSavedObjectTags(tagName);
}

// Failing: See https://github.com/elastic/kibana/issues/89958
describe.skip('visualize integration', () => {
await testSubjects.click('confirmSaveSavedObjectButton');
await retry.waitForWithTimeout('Save modal to disappear', 5000, () =>
testSubjects
.missingOrFail('confirmSaveSavedObjectButton')
.then(() => true)
.catch(() => false)
);

await PageObjects.header.waitUntilLoadingHasFinished();
};

describe('visualize integration', () => {
before(async () => {
// clean up any left-over visualizations and tags from tests that didn't clean up after themselves
await kibanaServer.savedObjects.clean({ types: ['tag', 'visualization'] });

await kibanaServer.importExport.load(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize/data.json'
);
Expand All @@ -61,7 +98,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await kibanaServer.importExport.unload(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize/data.json'
);
await kibanaServer.savedObjects.clean({ types: ['tag'] });
// clean up after test suite
await kibanaServer.savedObjects.clean({ types: ['tag', 'visualization'] });
await esArchiver.unload(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional'
);
Expand All @@ -76,48 +114,46 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
it('allows to manually type tag filter query', async () => {
await listingTable.searchForItemWithName('tag:(tag-1)', { escape: false });
await listingTable.expectItemsCount('visualize', 2);
const itemNames = await listingTable.getAllItemsNames();
const itemNames = await listingTable.getAllSelectableItemsNames();
expect(itemNames).to.eql(['Visualization 1 (tag-1)', 'Visualization 3 (tag-1 + tag-3)']);
});

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

await listingTable.expectItemsCount('visualize', 2);
const itemNames = await listingTable.getAllItemsNames();
const itemNames = await listingTable.getAllSelectableItemsNames();
expect(itemNames).to.eql(['Visualization 1 (tag-1)', 'Visualization 3 (tag-1 + tag-3)']);
});

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

await listingTable.expectItemsCount('visualize', 2);
const itemNames = await listingTable.getAllItemsNames();
const itemNames = await listingTable.getAllSelectableItemsNames();
expect(itemNames).to.eql(['Visualization 2 (tag-2)', 'Visualization 3 (tag-1 + tag-3)']);
});
});

describe('creating', () => {
before(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
// delete all visualizations to create new ones explicitly
await PageObjects.visualize.deleteAllVisualizations();
});
it('allows to assign tags to the new visualization', async () => {
await PageObjects.visualize.navigateToNewVisualization();

await PageObjects.visualize.clickMarkdownWidget();
await PageObjects.visEditor.setMarkdownTxt('Just some markdown');
await PageObjects.visEditor.clickGo();

await PageObjects.visualize.ensureSavePanelOpen();
await PageObjects.visualize.setSaveModalValues('My new markdown viz');

await selectSavedObjectTags('tag-1');

await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();
await createSimpleMarkdownVis({
visText: 'Just some markdown',
visName: 'My new markdown viz',
tagName: 'myextratag',
});

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-1');
const itemNames = await listingTable.getAllItemsNames();
await selectFilterTags('myextratag');
const itemNames = await listingTable.getAllSelectableItemsNames();
expect(itemNames).to.contain('My new markdown viz');
});

Expand All @@ -131,7 +167,10 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.visEditor.clickGo();

await PageObjects.visualize.ensureSavePanelOpen();
await PageObjects.visualize.setSaveModalValues('vis-with-new-tag');
await PageObjects.visualize.setSaveModalValues('vis-with-new-tag', {
saveAsNew: false,
redirectToOrigin: true,
});

await testSubjects.click('savedObjectTagSelector');
await testSubjects.click(`tagSelectorOption-action__create`);
Expand All @@ -158,33 +197,43 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await listingTable.waitUntilTableIsLoaded();

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

// FLAKY: https://github.com/elastic/kibana/issues/88639
describe.skip('editing', () => {
beforeEach(async () => {
describe('editing', () => {
before(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
await PageObjects.visualize.deleteAllVisualizations();
// create a vis to add a tag to during edit
await PageObjects.visualize.navigateToNewVisualization();
await createSimpleMarkdownVis({
visText: 'Edit me!',
visName: 'MarkdownViz',
});
});

it('allows to assign tags to an existing visualization', async () => {
await listingTable.clickItemLink('visualize', 'Visualization 1 (tag-1)');

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
await listingTable.clickItemLink('visualize', 'MarkdownViz');
await PageObjects.visualize.ensureSavePanelOpen();
await selectSavedObjectTags('tag-2');

await selectSavedObjectTags(...['myextratag']);
await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();
await retry.waitForWithTimeout('Save modal to disappear', 5000, () =>
testSubjects
.missingOrFail('confirmSaveSavedObjectButton')
.then(() => true)
.catch(() => false)
);

await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();

await selectFilterTags('tag-2');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('Visualization 1 (tag-1)');
await selectFilterTags('myextratag');
const itemNames = await listingTable.getAllSelectableItemsNames();
expect(itemNames).to.contain('MarkdownViz');
});
});
});
Expand Down