mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
## Summary This PR copies the Data Discovery functional tests to `test_serverless` and adds support for running them against each of the project types. Part of #162347. Flaky test runs: - x300: https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3977 ### Checklist - [ ] ~Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)~ - [ ] ~[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 - [ ] ~Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/))~ - [ ] ~Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))~ - [ ] ~If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~ - [ ] ~This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))~ - [ ] ~This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers)~ ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
58 lines
2.2 KiB
TypeScript
58 lines
2.2 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 FlyoutService 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');
|
|
|
|
public async close(dataTestSubj: string): Promise<void> {
|
|
this.log.debug('Closing flyout', dataTestSubj);
|
|
const flyoutElement = await this.testSubjects.find(dataTestSubj);
|
|
await this.retry.try(async () => {
|
|
const closeBtn = await flyoutElement.findByCssSelector('[aria-label*="Close"]');
|
|
await closeBtn.click();
|
|
await this.testSubjects.missingOrFail(dataTestSubj);
|
|
});
|
|
}
|
|
|
|
public async ensureClosed(dataTestSubj: string): Promise<void> {
|
|
if (await this.testSubjects.exists(dataTestSubj, { timeout: 1000 })) {
|
|
await this.close(dataTestSubj);
|
|
}
|
|
}
|
|
|
|
public async ensureAllClosed(): Promise<void> {
|
|
await this.retry.waitFor('all flyouts to be closed', async () => {
|
|
let flyoutElements = await this.find.allByCssSelector('.euiFlyout', 2500);
|
|
if (!flyoutElements.length) {
|
|
return true;
|
|
}
|
|
let expectedFlyoutCount = 0;
|
|
for (let i = 0; i < flyoutElements.length; i++) {
|
|
const closeBtnExists = await this.find.descendantExistsByCssSelector(
|
|
'[aria-label*="Close"]',
|
|
flyoutElements[i]
|
|
);
|
|
if (closeBtnExists) {
|
|
const closeBtn = await flyoutElements[i].findByCssSelector('[aria-label*="Close"]');
|
|
await closeBtn.click();
|
|
} else {
|
|
// If it doesn't have a close button, it can't
|
|
// be closed, so ignore it in the count check
|
|
expectedFlyoutCount++;
|
|
}
|
|
}
|
|
flyoutElements = await this.find.allByCssSelector('.euiFlyout', 500);
|
|
return flyoutElements.length === expectedFlyoutCount;
|
|
});
|
|
}
|
|
}
|