Skip to content

Commit 96980ed

Browse files
authored
Merge branch 'main' into alerting-v2-workflow-trigger-assign-episode
2 parents 938092f + 1c77607 commit 96980ed

3,186 files changed

Lines changed: 136824 additions & 80620 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/buildkite-logs/SKILL.md

Lines changed: 0 additions & 157 deletions
This file was deleted.

.agents/skills/cypress-to-scout-migration/references/migration-best-practices.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,27 @@ spaceTest.afterAll(async ({ apiServices, scoutSpace }) => {
105105

106106
Do not use `esArchiver` to manipulate system indices — use `kbnClient`.
107107

108+
### Suite-wide cleanup with `globalTeardownHook`
109+
110+
For state that's shared **across spec files** (e.g., data ingested in `global.setup.ts`, feature-flag overrides, global `uiSettings`), use the optional `globalTeardownHook` in `parallel_tests/global.teardown.ts`. It runs once after all workers finish, even if tests failed.
111+
112+
```typescript
113+
import { globalTeardownHook } from '@kbn/scout-security'; // or '@kbn/scout' / '@kbn/scout-oblt'
114+
115+
globalTeardownHook('Reset shared state', async ({ kbnClient, apiServices, log }) => {
116+
// Revert global uiSettings or feature flags toggled for the whole suite
117+
await kbnClient.uiSettings.unset('my:setting');
118+
await apiServices.core.settings({ 'feature_flags.overrides': { 'my.flag': 'false' } });
119+
});
120+
```
121+
122+
**Cautions:**
123+
124+
- **`esArchiver` is intentionally not exposed** in `globalTeardownHook`. Scout's `esArchiver` only supports `loadIfNeeded` — archive unloading was never offered because it's slow and unnecessary (leftover indexes in the cluster don't break tests with idempotent `loadIfNeeded`). For state that does need resetting, use `esClient.indices.delete` / `deleteDataStream` / `deleteByQuery`.
125+
- **Don't load new data here** — teardown is for resetting state. Data loading belongs in `globalSetupHook`.
126+
- **Per-test/per-suite cleanup still belongs in `afterEach`/`afterAll`** — the global teardown is for state that other configs (running against the same Kibana/ES) would otherwise inherit.
127+
- Optional and opt-in by file presence: add `parallel_tests/global.teardown.ts` and you're done. `runGlobalSetup: true` already wires the project up.
128+
108129
## test.step() for Execution Time
109130

110131
Each `test()` block creates a new browser context. Use `test.step()` for multi-step flows to reuse context:

.agents/skills/gh-create-issue/SKILL.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,53 @@ For **feature requests**, also probe for these common gaps (even if the field is
6666
- **Target user**: Who would use this — what role or persona? If not stated, ask.
6767
- **Dependencies**: Are there issues, features, or infrastructure changes that must land first? If so, capture them in the "Blocked By" field.
6868

69-
## Step 7 — Show the draft and confirm
69+
## Step 7 — Collect and validate labels
7070

71-
Display the complete proposed issue (title + body) and ask the user to confirm or request changes. **End your response and wait for explicit confirmation before filing.**
71+
Ask the user for a **team label** (e.g. `Team:Visualizations`) and any **additional labels** (e.g. `accessibility`, `performance`). Accept "none" for either. The type label (`bug` or `enhancement`) is added automatically.
7272

73-
## Step 8 — Create the issue
73+
**End your response and wait for the user to reply before proceeding.**
7474

75-
After the user confirms, create the issue:
75+
Once the user provides labels, validate **all of them in parallel** against the repository:
7676

7777
```bash
78-
ISSUE_BODY=$(cat <<'EOF'
78+
gh label list --repo elastic/kibana --search "<label>" --limit 10 --json name,description --jq '.[] | "- `\(.name)` — \(.description // "no description")"'
79+
```
80+
81+
For each label:
82+
83+
- **Exact match** → keep it.
84+
- **Close matches only** → show them as `` `<name>` — <description> `` and ask the user to pick one or skip.
85+
- **No matches** → inform the user and ask to skip or provide an alternative.
86+
87+
If any labels need user input, **wait for the reply**, then re-validate any new labels. Repeat until all labels are resolved.
88+
89+
## Step 8 — Show the draft and confirm
90+
91+
Display the complete issue preview using this format:
92+
93+
> **Title:** `<title>`
94+
> **Labels:** `<label1>`, `<label2>`, ...
95+
>
96+
> ---
97+
> \<issue body\>
98+
> ---
99+
100+
Ask the user to confirm or request changes.
101+
102+
**End your response and wait for explicit confirmation before filing.**
103+
104+
## Step 9 — Create the issue
105+
106+
```bash
107+
gh issue create --repo elastic/kibana \
108+
--title "<TITLE>" \
109+
--label "<label1>" --label "<label2>" --label "<labelN>" \
110+
--body "$(cat <<'EOF'
79111
<formatted body here>
80112
EOF
81-
)
82-
gh issue create --repo elastic/kibana --title "<TITLE>" --body "$ISSUE_BODY" --label "<bug|enhancement>"
113+
)"
83114
```
84115

85-
Use label `bug` for bug reports and `enhancement` for feature requests.
116+
Add one `--label` flag per label.
86117

87-
Report the new issue URL to the user when done.
118+
Always include the type label (`bug` or `enhancement`) plus all validated labels. Report the new issue URL to the user when done.

.agents/skills/scout-best-practices-reviewer/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Important: Do not post GitHub comments unless explicitly stated.
2121
2. Neighboring Scout code in the same plugin/solution (existing specs + `test/scout/**/fixtures/**`) to spot reuse opportunities and avoid duplicating helpers.
2222
3. Removed/previous tests (if this is a migration) to verify behavior parity.
2323
4. Scout docs (open only what you need — best practices are split by test type so you can skip the irrelevant half):
24+
2425
- **General best practices** (always relevant): `docs/extend/scout/best-practices.md`
2526
- **UI-only best practices** (open when reviewing UI tests): `docs/extend/scout/ui-best-practices.md`
2627
- **API-only best practices** (open when reviewing API tests): `docs/extend/scout/api-best-practices.md`
@@ -56,6 +57,7 @@ Open only the docs relevant to the test type(s) under review.
5657
- **[general]** **RBAC / realism**: minimal permissions (avoid `admin` unless required); space-aware behavior covered or explicitly out of scope.
5758
- **[ui]** **Flake traps**: avoid `waitForTimeout()` and time-based assertions/retries; rely on auto-waiting + explicit readiness signals. Some locators are restricted by `@kbn/eslint/scout_no_locators` (e.g. `globalLoadingIndicator`).
5859
- **[general]** **Cost**: avoid repeating expensive setup; consider a global setup hook for shared one-time operations.
60+
- **[general]** **Global teardown** (when `global.teardown.ts` is present): cleanup must use `esClient`/`kbnClient`/`apiServices`. `esArchiver` isn't on the teardown fixture surface — Scout intentionally never exposed archive-unloading (slow and unnecessary; leftover indexes don't break tests with idempotent `loadIfNeeded`). Flag teardowns that try to use `esArchiver` at all, that **load** new data (teardown is for state reset only), or that duplicate work belonging in `afterAll`/per-test cleanup.
5961
- **[general]** **Tags / environment**: validate deployment tags and avoid assumptions that only hold in specific environments.
6062

6163
### Files to skip

.agents/skills/scout-create-scaffold/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Notes:
6262
- `test/<scout-root>/ui/parallel_tests/example_one.spec.ts`
6363
- `test/<scout-root>/ui/parallel_tests/example_two.spec.ts`
6464
- `test/<scout-root>/ui/parallel_tests/global.setup.ts`
65+
- `test/<scout-root>/ui/parallel_tests/global.teardown.ts` is **not** generated; opt in by adding the file with a `globalTeardownHook(...)` call. See `scout-ui-testing/references/scout-ui-parallelism.md`.
6566

6667
The generator **does not** create **`tsconfig.json`** files. Playwright runs without them, but **`node scripts/type_check`** (CI) must still include Scout specs in a TS project—see **TypeScript layout** below.
6768

.agents/skills/scout-migrate-from-ftr/references/execute-plan.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ For general Scout API auth patterns (`requestAuth`, `samlAuth`, common headers,
132132
- Put shared helpers in `test/scout*/ui/fixtures/helpers.ts` (or API helpers in API fixtures).
133133
- Add test-subject constants in `fixtures/constants.ts` for reuse across tests and page objects.
134134
- For `parallel_tests/` ingestion, use `parallel_tests/global.setup.ts` + `globalSetupHook` (no `esArchiver` in spec files).
135+
- For suite-wide Elasticsearch/Kibana state reset (e.g. reverting feature flags or global `uiSettings`, dropping hand-indexed data that affects other Scout configs sharing the cluster), use the **optional** `globalTeardownHook` in `parallel_tests/global.teardown.ts`. Picked up automatically when `runGlobalSetup: true` — no extra config flag. Use `esClient.indices.delete` / `deleteDataStream` / `deleteByQuery`, `kbnClient.uiSettings.unset(...)`, and `apiServices.core.settings(...)` to reset state. Per-test/per-suite cleanup still belongs in `afterEach`/`afterAll`.
135136

136137
#### Synthtrace in Scout **API** tests
137138

@@ -197,6 +198,7 @@ Once the new specs typecheck and run, control returns to the parent skill. Step
197198
- Use `test.step(...)` inside a single `test(...)` when an FTR suite used multiple `it(...)` blocks as one journey.
198199
- Parallel UI: isolate per-space state via `spaceTest` + `scoutSpace`; avoid hardcoded saved object IDs and make names unique (often suffix with `scoutSpace.id`).
199200
- Use `globalSetupHook` in `parallel_tests/global.setup.ts` to ingest shared data once.
201+
- Use the optional `globalTeardownHook` in `parallel_tests/global.teardown.ts` to reset shared state once after the suite (no `esArchiver`; `esClient`/`kbnClient`/`apiServices` only). See step 6 above for the cleanup primitives and cautions.
200202
- Use `page.addInitScript(...)` before navigation to set localStorage/cookies (skip tours/onboarding).
201203
- When FTR used rison-encoded query params, replicate with `@kbn/rison` and add **`@kbn/rison`** to **`kbn_references`** on the `tsconfig.json` that includes the Scout UI files (plugin root under **Pattern A**, or `test/scout/ui/tsconfig.json` under **Pattern B**).
202204
- Add stable `data-test-subj` attributes when selectors are unstable.

.agents/skills/scout-ui-testing/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ description: Use when creating, updating, debugging, or reviewing Scout UI tests
5353
- Use `spaceTest` so you can access `scoutSpace` for worker-isolated saved objects + UI settings.
5454
- Pre-ingest shared ES data in `parallel_tests/global.setup.ts` via `globalSetupHook(...)`.
5555
- Only **worker** fixtures are available there (no `page`, `browserAuth`, `pageObjects`).
56+
- Reset Elasticsearch/Kibana state once after the suite via `globalTeardownHook(...)` in `parallel_tests/global.teardown.ts` (optional, opt-in by file presence). For state that does need resetting, use `esClient`/`kbnClient`/`apiServices`. See `references/scout-ui-parallelism.md`.
5657
- Cleanup space-scoped mutations in `afterAll` (`scoutSpace.savedObjects.cleanStandardList()`, unset UI settings you set).
5758

5859
## Extending fixtures

.agents/skills/scout-ui-testing/references/scout-ui-parallelism.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Use this when working under `.../test/scout*/ui/parallel_tests/` or a `parallel.
1414

1515
- `ui/parallel.playwright.config.ts`: `testDir: './parallel_tests'`, `workers: 2..3`, optional `runGlobalSetup: true`.
1616
- `ui/parallel_tests/global.setup.ts`: define `globalSetupHook(...)` (runs once total).
17+
- `ui/parallel_tests/global.teardown.ts` (optional): define `globalTeardownHook(...)` to reset cluster/Kibana state once after the suite. Picked up automatically when `runGlobalSetup: true`; no extra config flag.
1718

1819
## Minimal pattern
1920

@@ -44,3 +45,38 @@ spaceTest.describe('my feature', { tag: tags.deploymentAgnostic }, () => {
4445
- Global setup runs once total (executed by the first worker); other workers wait for it to finish.
4546
- Only worker-scoped fixtures are available (for example `esArchiver`, `apiServices`, `kbnClient`, `esClient`, `log`).
4647
- No `page`, `browserAuth`, or `pageObjects` in `global.setup.ts`.
48+
49+
## Global teardown hook (optional)
50+
51+
Use `globalTeardownHook` in `parallel_tests/global.teardown.ts` to reset Kibana/cluster state **once** after all workers finish — runs even if tests failed. Same fixture surface as setup, **except `esArchiver` is intentionally not exposed**.
52+
53+
```ts
54+
import { globalTeardownHook } from '@kbn/scout'; // or '@kbn/scout-oblt' / '@kbn/scout-security'
55+
56+
globalTeardownHook('Reset shared Kibana state', async ({ esClient, kbnClient, apiServices, log }) => {
57+
log.info('[teardown] resetting shared state');
58+
59+
// Drop hand-indexed data ingested by global.setup.ts that affects other Scout configs
60+
// sharing this cluster (Scout's esArchiver intentionally has no unload — see cautions)
61+
await esClient.indices.delete({ index: 'apm-8.0.0-*', ignore_unavailable: true });
62+
await esClient.indices.deleteDataStream({ name: 'logs-my_dataset-*' }).catch(() => {});
63+
64+
// Revert any uiSettings / advanced settings the suite set globally
65+
await kbnClient.uiSettings.unset('discover:searchOnPageLoad');
66+
await kbnClient.uiSettings.updateGlobal({ hideAnnouncements: false });
67+
68+
// Revert feature-flag overrides flipped via apiServices.core.settings(...)
69+
await apiServices.core.settings({ 'feature_flags.overrides': { 'discover.isEsqlDefault': 'false' } });
70+
71+
// Saved-object cleanup the suite created cluster-wide (per-space cleanup belongs in afterAll)
72+
await kbnClient.savedObjects.cleanStandardList();
73+
});
74+
```
75+
76+
**Cautions:**
77+
78+
- **No `esArchiver` on the teardown surface — by design.** Scout's `esArchiver` fixture only ever exposed `loadIfNeeded`; archive-driven unloading was never supported because it's slow and adds nothing — leftover indexes in the cluster don't break tests when setup uses idempotent `loadIfNeeded`. For state that **does** need resetting, use `esClient.indices.delete` / `deleteDataStream` / `deleteByQuery` directly.
79+
- **Don't reload data here** — teardown is for resetting state, not for setting up new data. If you need fresh data on every run, do it in `globalSetupHook` (which is idempotent via `esArchiver.loadIfNeeded`).
80+
- **Per-test/per-suite cleanup still belongs in `afterEach`/`afterAll`** — the global teardown is for state shared across the whole suite (or leaked into the cluster from setup) that other configs running in the same Kibana/ES would otherwise inherit.
81+
- **Available fixtures**: `log`, `config`, `kbnUrl`, `esClient`, `kbnClient`, `apiServices` (plus the same lazy `samlAuth`/`isSnapshotBuild` from `coreWorkerFixtures`). No `page`/`browserAuth`/`pageObjects` and no `esArchiver`.
82+
- **Optional, opt-in by file presence**: just add `parallel_tests/global.teardown.ts` calling `globalTeardownHook(...)`. No new config flag — `runGlobalSetup: true` is enough.

0 commit comments

Comments
 (0)