[Scout] Migrate Data Views API tests from FTR - Part5#264088
Conversation
Catch flakiness early (recommended)Recommended before merge: run the flaky test runner against this PR to catch flakiness early. Trigger a run with the Flaky Test Runner UI or post this comment on the PR: This check is experimental. Share your feedback in the #appex-qa channel. Posted via Macroscope — Flaky Test Runner nudge |
| await apiClient.post(`${DATA_VIEW_PATH}/${sharedDataViewId}/fields`, { | ||
| headers: { ...COMMON_HEADERS, ...adminApiCredentials.apiKeyHeader }, | ||
| responseType: 'json', | ||
| body: { fields: { foo: { customLabel: 'baz' } } }, | ||
| }); | ||
|
|
||
| const getResponse = await apiClient.get(`${DATA_VIEW_PATH}/${sharedDataViewId}`, { | ||
| headers: { ...COMMON_HEADERS, ...adminApiCredentials.apiKeyHeader }, | ||
| responseType: 'json', | ||
| }); | ||
|
|
||
| expect(getResponse).toHaveStatusCode(200); | ||
| expect(getResponse.body[SERVICE_KEY].fields.foo.customLabel).toBe('baz'); | ||
| }); |
There was a problem hiding this comment.
🟢 Low data_views/fields_api_update_main.spec.ts:212
The test at line 212 does not verify the status code of the POST response, unlike every other test in the file. If the POST fails silently (e.g., 400 or 500), the subsequent GET assertion on fields.foo.customLabel would fail with an unclear message instead of reporting the actual API error. Consider adding expect(updateResponse).toHaveStatusCode(200) after the POST request.
await apiClient.post(`${DATA_VIEW_PATH}/${sharedDataViewId}/fields`, {
headers: { ...COMMON_HEADERS, ...adminApiCredentials.apiKeyHeader },
responseType: 'json',
body: { fields: { foo: { customLabel: 'baz' } } },
- });
+ });
+
+ expect(updateResponse).toHaveStatusCode(200);
const getResponse = await apiClient.get(`${DATA_VIEW_PATH}/${sharedDataViewId}`, {🤖 Copy this AI Prompt to have your agent fix this:
In file src/platform/plugins/shared/data_views/test/scout/api/tests/data_views/fields_api_update_main.spec.ts around lines 212-225:
The test at line 212 does not verify the status code of the POST response, unlike every other test in the file. If the POST fails silently (e.g., 400 or 500), the subsequent GET assertion on `fields.foo.customLabel` would fail with an unclear message instead of reporting the actual API error. Consider adding `expect(updateResponse).toHaveStatusCode(200)` after the POST request.
Evidence trail:
src/platform/plugins/shared/data_views/test/scout/api/tests/data_views/fields_api_update_main.spec.ts lines 211-225 (test without status check), lines 69-70, 95-96, 125, 152, 172, 201, 244, 266, 305 (all other tests with status checks)
| }); | ||
|
|
||
| expect(getResponse).toHaveStatusCode(200); | ||
| expect(getResponse.body[SERVICE_KEY].fields.foo.customLabel).toBe('baz'); |
There was a problem hiding this comment.
🟢 Low data_views/fields_api_update_main.spec.ts:224
The test at line 224 accesses getResponse.body[SERVICE_KEY].fields.foo.customLabel instead of fieldAttrs.foo.customLabel. This mismatches the API response structure and the pattern used in all other tests (lines 175, 181, 202, 208, 244, 250), causing the assertion to check the wrong property.
🤖 Copy this AI Prompt to have your agent fix this:
In file src/platform/plugins/shared/data_views/test/scout/api/tests/data_views/fields_api_update_main.spec.ts around line 224:
The test at line 224 accesses `getResponse.body[SERVICE_KEY].fields.foo.customLabel` instead of `fieldAttrs.foo.customLabel`. This mismatches the API response structure and the pattern used in all other tests (lines 175, 181, 202, 208, 244, 250), causing the assertion to check the wrong property.
Evidence trail:
src/platform/plugins/shared/data_views/test/scout/api/tests/data_views/fields_api_update_main.spec.ts lines 165-260 at REVIEWED_COMMIT. Line 224 shows `expect(getResponse.body[SERVICE_KEY].fields.foo.customLabel).toBe('baz');` while lines 175, 181, ~202, ~208, ~244, ~250 all use the pattern `fieldAttrs.foo.customLabel` for the same type of data.
|
Pinging @elastic/appex-qa (Team:QA) |
There was a problem hiding this comment.
Scout Test Review
Overall, this is a well-executed migration — the new Scout tests follow key best practices: every suite has deploymentAgnostic tags, constants are centralized, cleanup consistently uses afterEach/afterAll hooks with the createdIds pattern, esArchiver.loadIfNeeded() is used for idempotent setup, assertions validate both status codes and response bodies, and apiClient vs apiServices are used for the right purposes. apiTest.step is also nicely used in runtime_fields_update_main.spec.ts.
I have a handful of findings below grouped by severity.
Posted via Macroscope — Scout Test Review
| export const SERVICE_KEY_LEGACY = 'index_pattern'; | ||
| export const SERVICE_KEY = 'data_view'; | ||
| export const HAS_USER_DATA_VIEW_PATH = 'api/data_views/has_user_data_view'; | ||
| export const HAS_USER_INDEX_PATTERN_PATH = 'api/index_patterns/has_user_index_pattern'; |
There was a problem hiding this comment.
🔵 Minor — Use constants for shared test values / Dead code
HAS_USER_INDEX_PATTERN_PATH, FIELDS_ROUTE_PATH, and RESOLVE_INDEX_PATH are exported here but never imported by any test file. If they're placeholders for future work, consider adding a // TODO comment. Otherwise, removing them keeps the constants file tidy and avoids confusion about what's covered.
Posted via Macroscope — Scout Test Review
davismcphee
left a comment
There was a problem hiding this comment.
Thanks for working on this, the code changes look good overall! I left a few comments (and looks like a couple of the bot's might make sense too), but the only main blocker imo is the dropped index_patterns coverage.
| // Remaining FTR coverage. The rest of this suite has been migrated to Scout under | ||
| // `src/platform/plugins/shared/data_views/test/scout/api/tests/`. |
There was a problem hiding this comment.
These tests are pretty weird, and I agree should largely be unit tests. The only ones that actually need to be integration tests are the ones referencing indexNotFoundError and docNotFoundError. They guard against unexpected ES error changes that our detection mechanisms are sensitive to, which has happened before unfortunately (and was missed by unit tests).
I'd be ok carrying only those ones over to Scout and leaving the remainder as unit tests, but also ok if that's left as a followup.
There was a problem hiding this comment.
Scout Test Review
Good progress since last review — the fields_for_wildcard_route tests now correctly use viewer credentials, and the integration test comparison was strengthened with omit/toStrictEqual. 👍
Found 2 issues in newly added files (2 major). These mirror patterns already flagged on equivalent data_views/ files in the prior run — those prior findings still apply too. See inline comments for details.
Posted via Macroscope — Scout Test Review
Scout Test ReviewAll issues resolved ✅ Share feedback in the #appex-qa channel. Posted via Macroscope — Scout Test Review |
There was a problem hiding this comment.
Scout Test Review — 2 findings on newly added index_patterns/ files.
Posted via Macroscope — Scout Test Review
💚 Build Succeeded
Metrics [docs]
History
cc @fake-haris |
davismcphee
left a comment
There was a problem hiding this comment.
Thank you kindly! Data Discovery changes LGTM 👍
|
Starting backport for target branches: 8.19, 9.2, 9.3, 9.4 https://github.com/elastic/kibana/actions/runs/24765234565 |
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…#264905) # Backport This will backport the following commits from `main` to `9.4`: - [[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)](#264088) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Charis Kalpakis","email":"39087493+fake-haris@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-22T07:09:29Z","message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","release_note:skip","backport:all-open","v9.5.0"],"title":"[Scout] Migrate Data Views API tests from FTR - Part5","number":264088,"url":"https://github.com/elastic/kibana/pull/264088","mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/264088","number":264088,"mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}}]}] BACKPORT--> Co-authored-by: Charis Kalpakis <39087493+fake-haris@users.noreply.github.com>
…#264904) # Backport This will backport the following commits from `main` to `9.3`: - [[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)](#264088) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Charis Kalpakis","email":"39087493+fake-haris@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-22T07:09:29Z","message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","release_note:skip","backport:all-open","v9.5.0"],"title":"[Scout] Migrate Data Views API tests from FTR - Part5","number":264088,"url":"https://github.com/elastic/kibana/pull/264088","mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/264088","number":264088,"mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}}]}] BACKPORT--> Co-authored-by: Charis Kalpakis <39087493+fake-haris@users.noreply.github.com>
…sationChanges23 * commit '9a7b717c662d1c904052bc59f0e5a81daab87c7f': (145 commits) Upgrade EUI to v114.2.0 (elastic#264550) [Entity Analytics] Add missing OpenAPI descriptions and examples to p… (elastic#264778) [Entity Resolution] Clarify CSV upload result for already-linked entities (elastic#264689) [AI Infra] Fix failing GenAI Settings Scout tests (elastic#260496) [Agent Builder] [Bug Bash] OAuth connector settings mention fields that are not there (elastic#264756) [performance] process-wide cache for advanced settings lookup (elastic#262618) [CI] Update limits.yml for securitySolution (elastic#264946) [SLO] Fix APM embeddable ids (elastic#264750) [EDR Workflows] Unify artifacts empty state buttons (elastic#264389) [Alert Triage workflow] Adds security.buildAlertEntityGraph and security.renderAlertNarrative… (elastic#259159) [SigEvents] Add KI feature identification endpoints and refactor task to use shared service (elastic#263528) [Scout] Migrate Data Views API tests from FTR - Part5 (elastic#264088) [Cases] Apply shared extended_fields path util server side (elastic#264706) [Lens as code] Fix metric trendline (elastic#264777) [api-docs] 2026-04-22 Daily api_docs build (elastic#264882) [Scout] Update test config manifests (elastic#264575) [workflows_management] Lazy-load Zod connector schemas to cut idle memory (elastic#264283) [ES|QL] Fix ES|QL columns reset race during active fetch (elastic#263947) [Content List] Column layout props, sticky actions, and title click handlers (elastic#264203) [Lens as code] Validate `id` in route for new vis types (elastic#264480) ...
#264936) # Backport This will backport the following commits from `main` to `8.19`: - [[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)](#264088) <!--- Backport version: 11.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Charis Kalpakis","email":"39087493+fake-haris@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-22T07:09:29Z","message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","release_note:skip","backport:all-open","v9.5.0"],"title":"[Scout] Migrate Data Views API tests from FTR - Part5","number":264088,"url":"https://github.com/elastic/kibana/pull/264088","mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/264088","number":264088,"mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},{"url":"https://github.com/elastic/kibana/pull/264904","number":264904,"branch":"9.3","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/264905","number":264905,"branch":"9.4","state":"OPEN"}]}] BACKPORT-->
…#264934) # Backport This will backport the following commits from `main` to `9.2`: - [[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)](#264088) <!--- Backport version: 11.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Charis Kalpakis","email":"39087493+fake-haris@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-22T07:09:29Z","message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:QA","release_note:skip","backport:all-open","v9.5.0"],"title":"[Scout] Migrate Data Views API tests from FTR - Part5","number":264088,"url":"https://github.com/elastic/kibana/pull/264088","mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/264088","number":264088,"mergeCommit":{"message":"[Scout] Migrate Data Views API tests from FTR - Part5 (#264088)","sha":"af013dba662e6e0a31427eabb9744e29c581078f"}},{"url":"https://github.com/elastic/kibana/pull/264904","number":264904,"branch":"9.3","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/264905","number":264905,"branch":"9.4","state":"OPEN"}]}] BACKPORT-->
Summary
Final pass of the
data_viewsplugin FTR → Scout migration. Migrates the remaining serverlessx-pack/platform/test/serverless/api_integration/test_suites/data_views/*suites to Scout APItests colocated with the plugin at
src/platform/plugins/shared/data_views/test/scout/api/tests/, and removes the migrated FTRsources +
loadTestFilewiring.Part of the ongoing FTR → Scout migration effort.
Continues the work from earlier parts (crud_*, default_data_view, runtime_fields_{create,get_errors}, etc.).
What moved
Each migrated FTR suite is ported to two Scout specs — one targeting the data view API
(
api/data_views/*, undertests/data_views/) and a parallel one targeting the legacy indexpattern API (
api/index_patterns/*, undertests/index_patterns/) — mirroring how the FTRsuites iterated over both config variants. Routes that are only available on
api/data_views/*(
swap_references,_existing_indices,_fields_for_wildcard) are ported once.New Scout API specs under
src/platform/plugins/shared/data_views/test/scout/api/tests/:data_views/fields_api_update_{errors,main}.spec.ts+index_patterns/fields_api_update_{errors,main}.spec.tsdata_views/runtime_fields_{delete_errors,delete_main,get_main,put_errors,put_main,update_errors,update_main}.spec.ts+ matchingindex_patterns/runtime_fields_*.spec.tsdata_views/swap_references_{errors,main,limit}.spec.ts(the FTR nestedlimit affected saved objectsdescribe is split into its own spec per Scout's one-suite-per-file guideline)data_views/has_user_data_view.spec.ts+index_patterns/has_user_index_pattern.spec.tsdata_views/integration.spec.ts+index_patterns/integration.spec.tsexisting_indices_route/{params,response}.spec.tsfields_for_wildcard_route/{conflicts,filter,params,response}.spec.ts(use theviewerrole since the route is read-only)Jest unit test (colocated with library code, replaces the FTR
es_errors/errors.jsintegration test):src/platform/plugins/shared/data_views/server/fetcher/lib/errors.test.tsSmall additions to
test/scout/api/fixtures/constants.ts:ES_ARCHIVE_CONFLICTS,KBN_ARCHIVE_SAVED_OBJECTS_{BASIC,RELATIONSHIPS},HAS_USER_DATA_VIEW_PATH,HAS_USER_INDEX_PATTERN_PATH,EXISTING_INDICES_PATH,FIELDS_ROUTE_PATH,RESOLVE_INDEX_PATH,SWAP_REFERENCES_{PATH,PREVIEW_PATH}.What was removed
From
x-pack/platform/test/serverless/api_integration/test_suites/data_views/:data_views_crud/,existing_indices_route/,fields_api/,fields_for_wildcard_route/,has_user_index_pattern/,integration/,runtime_fields_crud/,swap_references/constants.ts(only consumed by the deleted specs)index.tsupdated — now only loads./es_errors(kept, see note below).The three parent configs (
configs/{search,security,observability}/config.group1.ts) stillrequire.resolve('.../test_suites/data_views'), and the trimmedindex.tskeeps that working.Notes / follow-ups
es_errorsis the last serverless FTR suite remaining underdata_views. The newerrors.test.tscovers the same helpers as Jest; a follow-up can carry over theindexNotFoundError/docNotFoundErrorintegration-level checks (which guard againstunexpected ES error shape changes) into Scout and then drop
es_errors/and theloadTestFile('./es_errors')entry entirely. Left in place in this PR to keep the changescoped.
src/platform/test/api_integration/apis/data_views/is untouched in this PR.