From ee1fef617a5613b22b755692eccae89d0dfd49ed Mon Sep 17 00:00:00 2001 From: dej611 Date: Thu, 31 Aug 2023 13:02:01 +0200 Subject: [PATCH] :white_check_mark: Add edit metadata tests in visualize list page --- .../dashboard/group4/dashboard_listing.ts | 12 +++---- .../visualize/group3/_visualize_listing.ts | 17 ++++++++++ test/functional/services/listing_table.ts | 29 +++++++++++++++++ .../apps/lens/group1/smokescreen.ts | 12 +++++++ .../apps/maps/group4/visualize_create_menu.js | 31 ++++++++++++++++++- 5 files changed, 92 insertions(+), 9 deletions(-) diff --git a/test/functional/apps/dashboard/group4/dashboard_listing.ts b/test/functional/apps/dashboard/group4/dashboard_listing.ts index d3cde4e185b9f..ed8cc60cb5884 100644 --- a/test/functional/apps/dashboard/group4/dashboard_listing.ts +++ b/test/functional/apps/dashboard/group4/dashboard_listing.ts @@ -14,8 +14,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const PageObjects = getPageObjects(['dashboard', 'header', 'common']); const browser = getService('browser'); const listingTable = getService('listingTable'); - const testSubjects = getService('testSubjects'); - const retry = getService('retry'); const dashboardAddPanel = getService('dashboardAddPanel'); describe('dashboard listing page', function describeIndexTests() { @@ -217,12 +215,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.dashboard.gotoDashboardLandingPage(); await listingTable.searchForItemWithName(`${dashboardName}-editMetaData`); - await testSubjects.click('inspect-action'); - await testSubjects.setValue('nameInput', 'new title'); - await testSubjects.setValue('descriptionInput', 'new description'); - await retry.try(async () => { - await testSubjects.click('saveButton'); - await testSubjects.missingOrFail('flyoutTitle'); + await listingTable.inspectVisualization(); + await listingTable.editVisualizationDetails({ + title: 'new title', + description: 'new description', }); await listingTable.searchAndExpectItemsCount('dashboard', 'new title', 1); diff --git a/test/functional/apps/visualize/group3/_visualize_listing.ts b/test/functional/apps/visualize/group3/_visualize_listing.ts index ad370939f2260..7adc5e088ce7c 100644 --- a/test/functional/apps/visualize/group3/_visualize_listing.ts +++ b/test/functional/apps/visualize/group3/_visualize_listing.ts @@ -84,5 +84,22 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await listingTable.expectItemsCount('visualize', 0); }); }); + + describe('Edit', () => { + before(async () => { + await PageObjects.visualize.gotoVisualizationLandingPage(); + }); + + it('should edit the title and description of a visualization', async () => { + await listingTable.searchForItemWithName('Hello'); + await listingTable.inspectVisualization(); + await listingTable.editVisualizationDetails({ + title: 'new title', + description: 'new description', + }); + await listingTable.searchForItemWithName('new title'); + await listingTable.expectItemsCount('visualize', 1); + }); + }); }); } diff --git a/test/functional/services/listing_table.ts b/test/functional/services/listing_table.ts index 7c2ecbbda89fa..71d71a157ceb9 100644 --- a/test/functional/services/listing_table.ts +++ b/test/functional/services/listing_table.ts @@ -154,6 +154,35 @@ export class ListingTableService extends FtrService { return visualizationNames; } + /** + * Open the inspect flyout + */ + public async inspectVisualization(index: number = 0) { + const inspectButtons = await this.testSubjects.findAll('inspect-action'); + await inspectButtons[index].click(); + } + + /** + * Edit Visualization title and description in the flyout + */ + public async editVisualizationDetails( + { title, description }: { title?: string; description?: string } = {}, + shouldSave: boolean = true + ) { + if (title) { + await this.testSubjects.setValue('nameInput', title); + } + if (description) { + await this.testSubjects.setValue('descriptionInput', description); + } + if (shouldSave) { + await this.retry.try(async () => { + await this.testSubjects.click('saveButton'); + await this.testSubjects.missingOrFail('flyoutTitle'); + }); + } + } + /** * Returns items count on landing page */ diff --git a/x-pack/test/functional/apps/lens/group1/smokescreen.ts b/x-pack/test/functional/apps/lens/group1/smokescreen.ts index dbd734348ba7d..324135ca05a6e 100644 --- a/x-pack/test/functional/apps/lens/group1/smokescreen.ts +++ b/x-pack/test/functional/apps/lens/group1/smokescreen.ts @@ -761,5 +761,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const hasVisualOptionsButton = await PageObjects.lens.hasVisualOptionsButton(); expect(hasVisualOptionsButton).to.be(false); }); + + it('should allow edit meta-data for Lens chart on listing page', async () => { + await PageObjects.visualize.gotoVisualizationLandingPage(); + await listingTable.searchForItemWithName('Afancilenstest'); + await listingTable.inspectVisualization(); + await listingTable.editVisualizationDetails({ + title: 'Anewfancilenstest', + description: 'new description', + }); + await listingTable.searchForItemWithName('Anewfancilenstest'); + await listingTable.expectItemsCount('visualize', 1); + }); }); } diff --git a/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js b/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js index f91bd55452fa6..cbcbe7b20868d 100644 --- a/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js +++ b/x-pack/test/functional/apps/maps/group4/visualize_create_menu.js @@ -9,7 +9,7 @@ import expect from '@kbn/expect'; export default function ({ getService, getPageObjects }) { const PageObjects = getPageObjects(['visualize', 'header', 'maps']); - + const listingTable = getService('listingTable'); const security = getService('security'); describe('visualize create menu', () => { @@ -85,5 +85,34 @@ export default function ({ getService, getPageObjects }) { expect(hasLegecyViz).to.equal(false); }); }); + describe('edit meta-data', () => { + before(async () => { + await security.testUser.setRoles(['global_visualize_all', 'test_logstash_reader'], { + skipBrowserRefresh: true, + }); + + await PageObjects.visualize.navigateToNewAggBasedVisualization(); + }); + + after(async () => { + await security.testUser.restoreDefaults(); + }); + + it('should allow to change meta-data on a map visualization', async () => { + await PageObjects.visualize.navigateToNewVisualization(); + await PageObjects.visualize.clickMapsApp(); + await PageObjects.maps.waitForLayersToLoad(); + await PageObjects.maps.saveMap('myTestMap'); + await PageObjects.visualize.gotoVisualizationLandingPage(); + await listingTable.searchForItemWithName('myTestMap'); + await listingTable.inspectVisualization(); + await listingTable.editVisualizationDetails({ + title: 'AnotherTestMap', + description: 'new description', + }); + await listingTable.searchForItemWithName('AnotherTestMap'); + await listingTable.expectItemsCount('visualize', 1); + }); + }); }); }