Skip to content

[Trusted Apps] Fix flaky invalid-hash form test by removing async input - #290719

Merged
kibanamachine merged 3 commits into
mainfrom
fix/flaky-286496-trusted-apps-hash-sync-input-cf20b8f5c047e232
Sep 15, 2026
Merged

kibanamachine merged 3 commits into
mainfrom
fix/flaky-286496-trusted-apps-hash-sync-input-cf20b8f5c047e232

Conversation

@kibanamachine

@kibanamachine kibanamachine commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #286496

Summary

  • should validate invalid Hash value timed out at 5000 ms (and later failed to find [1] Invalid hash value) because it drove the value through slow char-by-char userEvent.type inside an async act, unlike its sibling tests which set values synchronously.
  • Replaces the async input with a synchronous setTextFieldValue edit (which marks the field visited via blur) plus an explicit controlled-item update, then asserts — so there is no async step to exceed the budget.
Runtime vs. 5s budget Passed Avg Max
Before fix 25/25 0.6s 0.7s
After fix 25/25 0.4s 0.5s

Context

  • The investigator's analysis correctly identified the async userEvent.type as the cost, but its proposed drop-in replacement (setTextFieldValue(...); rerenderWithLatestProps();) fails 0/25 locally. rerenderWithLatestProps() reads latestUpdatedItem, and the form's useEffect(() => processChanged(), [processChanged]) re-fires the moment hasFormChanged flips falsetrue on the first edit — calling the test's onChange with the still-empty item prop and clobbering latestUpdatedItem back to empty. userEvent.type masked this only because its 2nd–8th keystrokes fire after hasFormChanged is already true; the sibling should validate multiple errors in form avoids it because its AND-click primes hasFormChanged first. This fix therefore departs from the proposed patch: it supplies the controlled item explicitly (as a real parent would) instead of relying on the clobbered round-trip value.
  • Product validation isn't broken: validateValues still runs on the invalid-hash item via that same useEffect and produces the error; the identical assertion runs synchronously and reliably in the sibling at the bottom of the same describe.
  • Failures were on kibana-on-merge - main (first failure build 107204; reopened on build 109576) — a Jest timeout under CI parallel load.
Verification

Verified locally

  • ✅ Passed: node scripts/eslint <file>
  • ✅ Passed: node scripts/jest <file> -t "should validate invalid Hash value": 25/25 passed before the fix (avg 631ms, max 690ms) and 25/25 after (avg 438ms, max 480ms); the ~30% lower average confirms the char-by-char typing cost was removed rather than the wait merely re-tuned.

Not verified locally

  • The reported flake is a timeout under CI parallel load, which does not reproduce on this runner (the unpatched test passed 25/25 locally), so the loops measure the runtime reduction rather than reproducing the failure.

Note

Share feedback in #kibana-qa. Mention @copilot to make quick changes.

Generated by Flaky Test Fixer for #286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K ·

Replace the char-by-char userEvent.type in an async act with a synchronous
field edit plus an explicit controlled-item update, so there is no async step
to exceed the 5s Jest budget under CI parallel load.

Fixes #286496

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@kibanamachine kibanamachine added the flaky-test-fixer Automated PR created by the flaky test fixer workflow label Sep 12, 2026
@github-actions github-actions Bot added backport:version Backport to applied version labels flaky-fix-check:skipped Flaky fix verifier: runner can't verify this fix (e.g. no Jest support) release_note:skip Skip the PR/issue when compiling release notes v9.4.7 v9.5.4 labels Sep 12, 2026
@kibanamachine

Copy link
Copy Markdown
Contributor Author

⏭️ Flaky-fix verification skipped

The /flaky runner only accepts FTR and Scout configs, and this PR only touches a Jest/RTL test (form.test.tsx), so required CI is the whole verdict — the fixer already verified the fix locally (25/25). Applied release_note:skip and backport:version (v9.5.4, v9.4.7).

Why the flaky test runner wasn't used

The /flaky runner accepts only FTR and Scout configs. This PR only changes the Jest test x-pack/solutions/security/plugins/security_solution/public/management/pages/trusted_apps/view/components/form.test.tsx, replacing an async userEvent.type-inside-act step with a synchronous edit plus an explicit controlled-item update. That removes the async cost deterministically, so there is no timing element left for repeated runs to validate — required CI is sufficient signal.

How release-note and backport labels were chosen

Applied release_note:skip because this is a test-only change with no user-facing effect.

  • v9.5.4 → included; has the identical unpatched flaky async test and every helper the patch uses, so the patch applies without adaptation.
  • v9.4.7 → included; identical to 9.5, patch applies without adaptation.
  • v8.19.22 → excluded; the test is already synchronous there and not flaky, so the async code this patch fixes does not exist on that branch.

Generated by Flaky Fix Verifier for #290719 · claude · opus · 205.3 AIC · ⌖ 61.5 AIC · ⊞ 15.8K ·

@kibanamachine
kibanamachine marked this pull request as ready for review September 12, 2026 19:59
@kibanamachine
kibanamachine requested a review from a team as a code owner September 12, 2026 19:59
@kibanamachine
kibanamachine enabled auto-merge (squash) September 12, 2026 19:59
Take the second-to-last onChange call (the idiom already used at lines
738/750/763 of this file) rather than injecting createItem(...), so the
test still proves that typing 'someHASH' is what produces the invalid-hash
item. Stays synchronous, so the flake fix is unaffected.
@szwarckonrad

Copy link
Copy Markdown
Contributor

Reviewed with a local reproduction of every claim in the description. The diagnosis is correct — I verified it rather than taking it on faith:

  • The investigator's proposed drop-in (setTextFieldValue + rerenderWithLatestProps) fails 0/5 locally, with the exact CI signature from the second reported failure (Unable to find an element with the text: [1] Invalid hash value). Root cause confirmed at form.tsx:846-848: useEffect(() => processChanged(), [processChanged]) re-fires when hasFormChanged flips falsetrue, and the no-arg processChanged() falls back to updatedItem = item (the stale prop), clobbering latestUpdatedItem.
  • Not a product bug: ArtifactFlyout.handleFormComponentOnChange (artifact_flyout.tsx:302-319) calls setFormState synchronously on every onChange, batched into the same commit as the child's setHasFormChanged(true), so a real parent never sees the stale window. Correct call to leave the component alone.

One change pushed on top (15964d5). The original patch hand-built the expected outcome:

formProps.item = createItem({ entries: [createEntry(ConditionEntryField.HASH, 'match', 'someHASH')] });

That discards the typed value and asserts against an injected constant, so a regression in handleEntryChange would still go green. Replaced with the idiom this file already uses three times (lines 738/750/763) to skip the known stale trailing emission:

formProps.item = (formProps.onChange as jest.Mock).mock.calls.at(-2)[0].item;

Still synchronous, so the flake fix is unaffected, and the asserted item now comes from the component.

Measured locally, should validate invalid Hash value, 10 runs each:

Version Pass avg max
Pre-fix (userEvent.type in async act) 10/10 366 ms 622 ms
This PR as opened 10/10 283 ms 528 ms
With 15964d5 10/10 215 ms 400 ms

Also green on the amended branch: whole file 61/61 (×3), node scripts/eslint clean, node scripts/type_check --project x-pack/solutions/security/plugins/security_solution/tsconfig.json exited 0.

Note for the backports: setTextFieldValue is load-bearing beyond typing — EuiFormRow isInvalid={visited.entries && ...} (form.tsx:993) gates the error on the blur it fires. Dropping that line makes the assertion fail even with a correct item.

@kibanamachine

Copy link
Copy Markdown
Contributor Author

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

Test Failures

  • [job] [logs] Jest Tests #6 / When using Console component should focus on input area when it gains focus

History

@kibanamachine
kibanamachine merged commit c11efe3 into main Sep 15, 2026
41 checks passed
@kibanamachine
kibanamachine deleted the fix/flaky-286496-trusted-apps-hash-sync-input-cf20b8f5c047e232 branch September 15, 2026 10:36
@kibanamachine

Copy link
Copy Markdown
Contributor Author

Starting backport for target branches: 9.4, 9.5

https://github.com/elastic/kibana/actions/runs/34958884785

@kibanamachine

Copy link
Copy Markdown
Contributor Author

💚 All backports created successfully

Status Branch Result
9.4
9.5

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 15, 2026
…nc input (#290719) (#291084)

# Backport

This will backport the following commits from `main` to `9.4`:
- [[Trusted Apps] Fix flaky invalid-hash form test by removing async
input (#290719)](#290719)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kibana
Machine","email":"42973632+kibanamachine@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-09-15T10:36:47Z","message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","flaky-test-fixer","flaky-fix-check:skipped","v9.6.0","v9.4.7","v9.5.4"],"title":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async
input","number":290719,"url":"https://github.com/elastic/kibana/pull/290719","mergeCommit":{"message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9"}},"sourceBranch":"main","suggestedTargetBranches":["9.4","9.5"],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290719","number":290719,"mergeCommit":{"message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9"}},{"branch":"9.4","label":"v9.4.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.5","label":"v9.5.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
Co-authored-by: konrad.szwarc <konrad.szwarc@elastic.co>
Co-authored-by: Gergő Ábrahám <gergo.abraham@elastic.co>
kibanamachine added a commit that referenced this pull request Sep 15, 2026
…nc input (#290719) (#291085)

# Backport

This will backport the following commits from `main` to `9.5`:
- [[Trusted Apps] Fix flaky invalid-hash form test by removing async
input (#290719)](#290719)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kibana
Machine","email":"42973632+kibanamachine@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-09-15T10:36:47Z","message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9","branchLabelMapping":{"^v9.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","flaky-test-fixer","flaky-fix-check:skipped","v9.6.0","v9.4.7","v9.5.4"],"title":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async
input","number":290719,"url":"https://github.com/elastic/kibana/pull/290719","mergeCommit":{"message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9"}},"sourceBranch":"main","suggestedTargetBranches":["9.4","9.5"],"targetPullRequestStates":[{"branch":"main","label":"v9.6.0","branchLabelMappingKey":"^v9.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/290719","number":290719,"mergeCommit":{"message":"[Trusted
Apps] Fix flaky invalid-hash form test by removing async input
(#290719)\n\nFixes #286496\n\n### Summary\n\n- `should validate invalid
Hash value` timed out at 5000 ms (and later\nfailed to find `[1] Invalid
hash value`) because it drove the value\nthrough slow char-by-char
`userEvent.type` inside an async `act`, unlike\nits sibling tests which
set values synchronously.\n- Replaces the async input with a synchronous
`setTextFieldValue` edit\n(which marks the field visited via blur) plus
an explicit\ncontrolled-`item` update, then asserts — so there is no
async step to\nexceed the budget.\n\n| Runtime vs. 5s budget | Passed |
Avg | Max |\n| --- | --- | --- | --- |\n| Before fix | 25/25 | 0.6s |
0.7s |\n| After fix | 25/25 | 0.4s | 0.5s |\n\n### Context\n\n- The
[investigator's\nanalysis](https://github.com/elastic/kibana/issues/286496#issuecomment-5648020729)\ncorrectly
identified the async `userEvent.type` as the cost, but its\nproposed
drop-in replacement
(`setTextFieldValue(...);\nrerenderWithLatestProps();`) fails **0/25**
locally.\n`rerenderWithLatestProps()` reads `latestUpdatedItem`, and the
form's\n`useEffect(() => processChanged(), [processChanged])` re-fires
the\nmoment `hasFormChanged` flips `false`→`true` on the first edit —
calling\nthe test's `onChange` with the still-empty `item` prop and
clobbering\n`latestUpdatedItem` back to empty. `userEvent.type` masked
this only\nbecause its 2nd–8th keystrokes fire *after* `hasFormChanged`
is already\n`true`; the sibling `should validate multiple errors in
form` avoids it\nbecause its AND-click primes `hasFormChanged` first.
This fix therefore\ndeparts from the proposed patch: it supplies the
controlled `item`\nexplicitly (as a real parent would) instead of
relying on the clobbered\nround-trip value.\n- Product validation isn't
broken: `validateValues` still runs on the\ninvalid-hash item via that
same `useEffect` and produces the error; the\nidentical assertion runs
synchronously and reliably in the sibling at\nthe bottom of the same
`describe`.\n- Failures were on `kibana-on-merge - main` (first failure
build 107204;\nreopened on build 109576) — a Jest timeout under CI
parallel load.\n\n<details>\n<summary>Verification</summary>\n\n####
Verified locally\n\n- ✅ Passed: `node scripts/eslint <file>`\n- ✅
Passed: `node scripts/jest <file> -t \"should validate invalid
Hash\nvalue\"`: 25/25 passed before the fix (avg 631ms, max 690ms) and
25/25\nafter (avg 438ms, max 480ms); the ~30% lower average confirms
the\nchar-by-char typing cost was removed rather than the wait
merely\nre-tuned.\n\n#### Not verified locally\n\n- The reported flake
is a timeout under CI parallel load, which does not\nreproduce on this
runner (the unpatched test passed 25/25 locally), so\nthe loops measure
the runtime reduction rather than reproducing
the\nfailure.\n\n</details>\n\n> [!NOTE]\n> Share feedback in
#kibana-qa. Mention `@copilot` to make quick\nchanges.\n\n> Generated by
[Flaky
Test\nFixer](https://github.com/elastic/kibana/actions/runs/34712900863)
for\n#286496 · claude · opus · 801.7 AIC · ⌖ 60.4 AIC · ⊞ 14.5K
·\n[◷](https://github.com/search?q=repo%3Aelastic%2Fkibana+%22gh-aw-workflow-id%3A+flaky-test-fixer%22&type=pullrequests)\n\n\n\n\n\n\n---------\n\nCo-authored-by:
Claude Opus 4 (1M context) <noreply@anthropic.com>\nCo-authored-by:
konrad.szwarc <konrad.szwarc@elastic.co>\nCo-authored-by: Gergő Ábrahám
<gergo.abraham@elastic.co>","sha":"c11efe3da7161011d8020631a396e2408a4b2ed9"}},{"branch":"9.4","label":"v9.4.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.5","label":"v9.5.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Claude Opus 4 (1M context) <noreply@anthropic.com>
Co-authored-by: konrad.szwarc <konrad.szwarc@elastic.co>
Co-authored-by: Gergő Ábrahám <gergo.abraham@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels flaky-fix-check:skipped Flaky fix verifier: runner can't verify this fix (e.g. no Jest support) flaky-test-fixer Automated PR created by the flaky test fixer workflow release_note:skip Skip the PR/issue when compiling release notes v9.4.7 v9.5.4 v9.6.0

Projects

None yet

3 participants