kibana/packages/kbn-test-subj-selector
Dzmitry Lemechko d4094c17be
[scout] migrate more Discover tests (#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 <traeluki@gmail.com>
2024-12-02 20:57:29 +01:00
..
index.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
jest.config.js Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
kibana.jsonc Sustainable Kibana Architecture: Categorise straightforward packages (#199630) 2024-11-22 10:33:25 +01:00
package.json Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
README.mdx
test_subj_selector.test.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
test_subj_selector.ts [scout] migrate more Discover tests (#201842) 2024-12-02 20:57:29 +01:00
tsconfig.json

---
id: kibDevDocsOpsTestSubjSelector
slug: /kibana-dev-docs/ops/test-subj-selector
title: "@kbn/test-subj-selector"
description: An utility package to quickly get css selectors from strings
date: 2022-05-19
tags: ['kibana', 'dev', 'contributor', 'operations', 'test', 'subj', 'selector']
---

Converts a testSubject selector into a CSS selector.

testSubject selector syntax rules:

  - `data-test-subj` values can include spaces

  - prefixing a value with `~` will allow matching a single word in a `data-test-subj` that uses several space delimited list words
    - example: `~foo`
    - css equivalent: `[data-test-subj~="foo"]`

  - the `>` character is used between two values to indicate that the value on the right must match an element inside an element matched by the value on the left
    - example: `foo > bar`
    - css equivalent: `[data-test-subj=foo] [data-test-subj=bar]`

  - the `&` character is used between two values to indicate that the value on both sides must both match the element
    - example: `foo & bar`
    - css equivalent: `[data-test-subj=foo][data-test-subj=bar]`