kibana/x-pack/test/saved_object_tagging/functional/tests/visualize_integration.ts
Greg Thompson 136d361703
Upgrade EUI to v34.3.0 (#101334)
* eui to v34.1.0

* styled-components types

* src snapshot updates

* x-pack snapshot updates

* eui to v34.2.0

* styled-components todo

* src snapshot updates

* x-pack snapshot updates

* jest test updates

* collapsible_nav

* Hard-code global nav width for bottom bar’s (for now)

* Update to eui v34.3.0

* flyout unmock

* src flyout snapshots

* remove duplicate euioverlaymask

* xpack flyout snapshots

* remove unused import

* sidenavprops

* attr updates

* trial: flyout ownfocus

* remove unused

* graph selector

* jest

* jest

* flyout ownFocus

* saved objects flyout

* console welcome flyout

* timeline flyout

* clean up

* visible

* colorpicker data-test-subj

* selectors

* selector

* ts

* selector

* snapshot

* Fix `use_security_solution_navigation` TS error

* cypress

Co-authored-by: cchaos <caroline.horn@elastic.co>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
2021-06-23 15:10:34 -05:00

189 lines
7 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
// eslint-disable-next-line import/no-default-export
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const listingTable = getService('listingTable');
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['visualize', 'tagManagement', 'visEditor', 'common']);
/**
* Select tags in the searchbar's tag filter.
*/
const selectFilterTags = async (...tagNames: string[]) => {
// open the filter dropdown
const filterButton = await find.byCssSelector('.euiFilterGroup .euiFilterButton');
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('.euiPageBody .euiFieldSearch');
await searchFilter.click();
// wait until the table refreshes
await listingTable.waitUntilTableIsLoaded();
};
const selectSavedObjectTags = async (...tagNames: string[]) => {
await testSubjects.click('savedObjectTagSelector');
for (const tagName of tagNames) {
await testSubjects.click(
`tagSelectorOption-${PageObjects.tagManagement.testSubjFriendly(tagName)}`
);
}
await testSubjects.click('savedObjectTitle');
};
// Failing: See https://github.com/elastic/kibana/issues/89958
describe.skip('visualize integration', () => {
before(async () => {
await esArchiver.load(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize'
);
await esArchiver.loadIfNeeded(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional'
);
});
after(async () => {
await esArchiver.unload(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/visualize'
);
await esArchiver.unload(
'x-pack/test/saved_object_tagging/common/fixtures/es_archiver/logstash_functional'
);
});
describe('listing', () => {
beforeEach(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
});
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();
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();
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();
expect(itemNames).to.eql(['Visualization 2 (tag-2)', 'Visualization 3 (tag-1 + tag-3)']);
});
});
describe('creating', () => {
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 PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
await selectFilterTags('tag-1');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('My new markdown viz');
});
it('allows to create a tag from the tag selector', async () => {
const { tagModal } = PageObjects.tagManagement;
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('vis-with-new-tag');
await testSubjects.click('savedObjectTagSelector');
await testSubjects.click(`tagSelectorOption-action__create`);
expect(await tagModal.isOpened()).to.be(true);
await tagModal.fillForm(
{
name: 'my-new-tag',
color: '#FFCC33',
description: '',
},
{
submit: true,
}
);
expect(await tagModal.isOpened()).to.be(false);
await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
await selectFilterTags('my-new-tag');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('vis-with-new-tag');
});
});
// FLAKY: https://github.com/elastic/kibana/issues/88639
describe.skip('editing', () => {
beforeEach(async () => {
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
});
it('allows to assign tags to an existing visualization', async () => {
await listingTable.clickItemLink('visualize', 'Visualization 1 (tag-1)');
await PageObjects.visualize.ensureSavePanelOpen();
await selectSavedObjectTags('tag-2');
await testSubjects.click('confirmSaveSavedObjectButton');
await PageObjects.common.waitForSaveModalToClose();
await PageObjects.visualize.gotoVisualizationLandingPage();
await listingTable.waitUntilTableIsLoaded();
await selectFilterTags('tag-2');
const itemNames = await listingTable.getAllItemsNames();
expect(itemNames).to.contain('Visualization 1 (tag-1)');
});
});
});
}