forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[scout] migrate more Discover tests (elastic#201842)
## Summary This PR migrates the following FTR tests to `@kbn/scout`: `x-pack/test/functional/apps/discover/error_handling.ts` => `x-pack/plugins/discover_enhanced/ui_tests/tests/error_handling.spec.ts` `x-pack/test/functional/apps/discover/saved_search_embeddable.ts` => `x-pack/plugins/discover_enhanced/ui_tests/tests/saved_search_embeddable.spec.ts` `x-pack/test/functional/apps/discover/saved_searches.ts` => `x-pack/plugins/discover_enhanced/ui_tests/tests/saved_searches.spec.ts` `x-pack/test/functional/apps/discover/value_suggestions.ts` 2nd describe block => `x-pack/plugins/discover_enhanced/ui_tests/tests/value_suggestions_use_time_range_disabled.spec.ts` Some other changes to mention: **packages/kbn-test-subj-selector**: - support of `^foo` syntax similar to `CSS [attribute^=value] Selector` **packages/kbn-scout**: - new worker fixture `uiSettings` to wrap Advanced Settings set/unset capability - extend `ScoutPage` fixture with `typeWithDelay` method required for many Kibana input fields - extend `PageObjects` fixture with `DashboardApp` & `FilterBar`, also extending existing ones. How to test: ```bash // ESS node scripts/scout_start_servers.js --stateful npx playwright test --config x-pack/plugins/discover_enhanced/ui_tests/playwright.config.ts --grep @ess // Serverless node scripts/scout_start_servers.js --serverless=es npx playwright test --config x-pack/plugins/discover_enhanced/ui_tests/playwright.config.ts --grep @svlSearch ``` --------- Co-authored-by: Robert Oskamp <[email protected]>
- Loading branch information
Showing
28 changed files
with
969 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { test as base } from '@playwright/test'; | ||
|
||
import { LoadActionPerfOptions } from '@kbn/es-archiver'; | ||
import { | ||
createKbnUrl, | ||
createEsArchiver, | ||
createEsClient, | ||
createKbnClient, | ||
createLogger, | ||
createSamlSessionManager, | ||
createScoutConfig, | ||
} from '../../../common/services'; | ||
import { ScoutWorkerFixtures } from '../types/worker_scope'; | ||
import { ScoutTestOptions } from '../../types'; | ||
|
||
export const coreWorkerFixtures = base.extend<{}, ScoutWorkerFixtures>({ | ||
log: [ | ||
({}, use) => { | ||
use(createLogger()); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
config: [ | ||
({ log }, use, testInfo) => { | ||
const configName = 'local'; | ||
const projectUse = testInfo.project.use as ScoutTestOptions; | ||
const serversConfigDir = projectUse.serversConfigDir; | ||
const configInstance = createScoutConfig(serversConfigDir, configName, log); | ||
|
||
use(configInstance); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
kbnUrl: [ | ||
({ config, log }, use) => { | ||
use(createKbnUrl(config, log)); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
esClient: [ | ||
({ config, log }, use) => { | ||
use(createEsClient(config, log)); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
kbnClient: [ | ||
({ log, config }, use) => { | ||
use(createKbnClient(config, log)); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
esArchiver: [ | ||
({ log, esClient, kbnClient }, use) => { | ||
const esArchiverInstance = createEsArchiver(esClient, kbnClient, log); | ||
// to speedup test execution we only allow to ingest the data indexes and only if index doesn't exist | ||
const loadIfNeeded = async (name: string, performance?: LoadActionPerfOptions | undefined) => | ||
esArchiverInstance!.loadIfNeeded(name, performance); | ||
|
||
use({ loadIfNeeded }); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
|
||
samlAuth: [ | ||
({ log, config }, use) => { | ||
use(createSamlSessionManager(config, log)); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/kbn-scout/src/playwright/fixtures/worker/ui_settings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { test as base } from '@playwright/test'; | ||
import { UiSettingValues } from '@kbn/test/src/kbn_client/kbn_client_ui_settings'; | ||
import { ScoutWorkerFixtures } from '../types'; | ||
import { isValidUTCDate, formatTime } from '../../utils'; | ||
|
||
export const uiSettingsFixture = base.extend<{}, ScoutWorkerFixtures>({ | ||
uiSettings: [ | ||
({ kbnClient }, use) => { | ||
const kbnClientUiSettings = { | ||
set: async (values: UiSettingValues) => kbnClient.uiSettings.update(values), | ||
|
||
unset: async (...keys: string[]) => | ||
Promise.all(keys.map((key) => kbnClient.uiSettings.unset(key))), | ||
|
||
setDefaultTime: async ({ from, to }: { from: string; to: string }) => { | ||
const utcFrom = isValidUTCDate(from) ? from : formatTime(from); | ||
const untcTo = isValidUTCDate(to) ? to : formatTime(to); | ||
await kbnClient.uiSettings.update({ | ||
'timepicker:timeDefaults': `{ "from": "${utcFrom}", "to": "${untcTo}"}`, | ||
}); | ||
}, | ||
}; | ||
|
||
use(kbnClientUiSettings); | ||
}, | ||
{ scope: 'worker' }, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.