Skip to content

Commit

Permalink
delete through library in functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon committed Jun 12, 2023
1 parent d87ebb5 commit 4259be3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
8 changes: 8 additions & 0 deletions test/functional/page_objects/visualize_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ export class VisualizePageObject extends FtrService {
await this.common.navigateToApp('visualize');
}

public async selectVisualizationsTab() {
await this.listingTable.selectTab(1);
}

public async selectAnnotationsTab() {
await this.listingTable.selectTab(2);
}

public async clickNewVisualization() {
await this.listingTable.clickNewButton();
}
Expand Down
16 changes: 14 additions & 2 deletions test/functional/services/listing_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ export class ListingTableService extends FtrService {
await this.testSubjects.click('deleteSelectedItems');
}

public async selectFirstItemInList() {
await this.find.clickByCssSelector('.euiTableCellContent .euiCheckbox__input');
}

public async clickItemCheckbox(id: string) {
await this.testSubjects.click(`checkboxSelectRow-${id}`);
}
Expand All @@ -213,9 +217,13 @@ export class ListingTableService extends FtrService {
* @param name item name
* @param id row id
*/
public async deleteItem(name: string, id: string) {
public async deleteItem(name: string, id?: string) {
await this.searchForItemWithName(name);
await this.clickItemCheckbox(id);
if (id) {
await this.clickItemCheckbox(id);
} else {
await this.selectFirstItemInList();
}
await this.clickDeleteSelected();
await this.common.clickConfirmOnModal();
}
Expand Down Expand Up @@ -253,4 +261,8 @@ export class ListingTableService extends FtrService {
timeout: 5000,
});
}

public async selectTab(which: number) {
await this.find.clickByCssSelector(`.euiTab:nth-child(${which})`);
}
}
12 changes: 4 additions & 8 deletions x-pack/test/functional/apps/lens/group6/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const toastsService = getService('toasts');
const testSubjects = getService('testSubjects');
const listingTable = getService('listingTable');
const from = 'Sep 19, 2015 @ 06:31:44.000';
const to = 'Sep 23, 2015 @ 18:31:44.000';

Expand Down Expand Up @@ -181,15 +182,10 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});

it('should remove layer for deleted annotation group', async () => {
// TODO - delete from listing page instead

await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaSavedObjects();
await PageObjects.savedObjects.searchForObject(ANNOTATION_GROUP_TITLE);
await PageObjects.savedObjects.clickCheckboxByTitle(ANNOTATION_GROUP_TITLE);
await PageObjects.savedObjects.clickDelete({ confirmDelete: true });

await PageObjects.visualize.gotoVisualizationLandingPage();
await PageObjects.visualize.selectAnnotationsTab();
await listingTable.deleteItem(ANNOTATION_GROUP_TITLE);
await PageObjects.visualize.selectVisualizationsTab();
await PageObjects.visualize.loadSavedVisualization(FIRST_VIS_TITLE, {
navigateToVisualize: false,
});
Expand Down

0 comments on commit 4259be3

Please sign in to comment.