kibana/test/functional/page_objects/share_page.ts
Rachel Shen dc1fd5a533
[Tests] Share Modal Redesign clean up and tests (#180406)
## Summary

This PR makes the share redesign modal work the primary share context
paradigm (excluding Canvas) by removing the share plugin config that had
share.new_version.enabled for testing and implementation.
This PR cleans up the FTRs. 

Closes [#151523](https://github.com/elastic/kibana/issues/151523)
As a result of defaulting to short urls, some tests were removed since
they are now obsolete.
One fix in this PR to avoid customer known issues is to allow reporting
(if license is permitted) for watcher users. Refer to
https://github.com/elastic/sdh-kibana/issues/4481#issuecomment-2012969470.

I've opened a separate issue to track any skipped or deleted tests as a
result of short urls by default here
https://github.com/elastic/kibana/issues/181066

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))


### Release Note

The share menu is updated for a more streamlined user experience. Users
can navigate through a tabbed modal to copy links for discover,
dashboard, and lens.

---------

Co-authored-by: Eyo Okon Eyo <eyo.eyo@elastic.co>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
2024-05-15 11:49:35 -07:00

98 lines
3.4 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrService } from '../ftr_provider_context';
export class SharePageObject extends FtrService {
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly find = this.ctx.getService('find');
private readonly log = this.ctx.getService('log');
private readonly retry = this.ctx.getService('retry');
/**
* @description attempt to close the share modal, if it's open
*/
async closeShareModal() {
if (await this.isShareModalOpen()) {
await this.find.clickByCssSelector(
'[data-test-subj="shareContextModal"] button[aria-label*="Close"]'
);
}
}
async clickTab(content: string) {
if (!(await this.isShareModalOpen())) {
await this.clickShareTopNavButton();
}
await (await this.find.byButtonText(content)).click();
}
async isShareMenuOpen() {
return await this.testSubjects.exists('shareContextMenu');
}
async isShareModalOpen() {
return await this.testSubjects.exists('shareContextModal');
}
async clickShareTopNavButton() {
return this.testSubjects.click('shareTopNavButton');
}
async openShareModalItem(itemTitle: 'link' | 'export' | 'embed') {
this.log.debug(`openShareModalItem title: ${itemTitle}`);
const isShareModalOpen = await this.isShareModalOpen();
if (!isShareModalOpen) {
await this.clickShareTopNavButton();
}
await this.testSubjects.click(itemTitle);
}
async openShareMenuItem(itemTitle: string) {
this.log.debug(`openShareMenuItem title:${itemTitle}`);
const isShareMenuOpen = await this.isShareMenuOpen();
if (!isShareMenuOpen) {
await this.clickShareTopNavButton();
} else {
// there is no easy way to ensure the menu is at the top level
// so just close the existing menu
await this.clickShareTopNavButton();
// and then re-open the menu
await this.clickShareTopNavButton();
}
const menuPanel = await this.find.byCssSelector('div.euiContextMenuPanel');
await this.testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
await this.testSubjects.waitForDeleted(menuPanel);
}
/**
* if there are more entries in the share menu, the permalinks entry has to be clicked first
* else the selection isn't displayed. this happens if you're testing against an instance
* with xpack features enabled, where there's also a csv sharing option
* in a pure OSS environment, the permalinks sharing panel is displayed initially
*/
async checkOldVersion() {
await this.clickShareTopNavButton();
if (await this.testSubjects.find('shareContextModal')) {
this.log.debug('This is the new share context modal');
await this.closeShareModal();
return false;
}
return true;
}
async getSharedUrl(): Promise<string> {
await this.retry.waitFor('wait for share url creation', async () => {
await this.testSubjects.click('copyShareUrlButton');
return Boolean(await this.testSubjects.getAttribute('copyShareUrlButton', 'data-share-url'));
});
return (await this.testSubjects.getAttribute('copyShareUrlButton', 'data-share-url'))!;
}
}