[Trusted Apps] Fix flaky invalid-hash form test by removing async input - #290719
kibanamachine merged 3 commits into
Conversation
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>
⏭️ Flaky-fix verification skippedThe Why the flaky test runner wasn't usedThe How release-note and backport labels were chosenApplied
|
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.
|
Reviewed with a local reproduction of every claim in the description. The diagnosis is correct — I verified it rather than taking it on faith:
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 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,
Also green on the amended branch: whole file Note for the backports: |
…t-cf20b8f5c047e232
💛 Build succeeded, but was flaky
Failed CI Steps
Metrics [docs]
Test Failures
History
|
|
Starting backport for target branches: 9.4, 9.5 |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…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>
…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>
Fixes #286496
Summary
should validate invalid Hash valuetimed out at 5000 ms (and later failed to find[1] Invalid hash value) because it drove the value through slow char-by-charuserEvent.typeinside an asyncact, unlike its sibling tests which set values synchronously.setTextFieldValueedit (which marks the field visited via blur) plus an explicit controlled-itemupdate, then asserts — so there is no async step to exceed the budget.Context
userEvent.typeas the cost, but its proposed drop-in replacement (setTextFieldValue(...); rerenderWithLatestProps();) fails 0/25 locally.rerenderWithLatestProps()readslatestUpdatedItem, and the form'suseEffect(() => processChanged(), [processChanged])re-fires the momenthasFormChangedflipsfalse→trueon the first edit — calling the test'sonChangewith the still-emptyitemprop and clobberinglatestUpdatedItemback to empty.userEvent.typemasked this only because its 2nd–8th keystrokes fire afterhasFormChangedis alreadytrue; the siblingshould validate multiple errors in formavoids it because its AND-click primeshasFormChangedfirst. This fix therefore departs from the proposed patch: it supplies the controlleditemexplicitly (as a real parent would) instead of relying on the clobbered round-trip value.validateValuesstill runs on the invalid-hash item via that sameuseEffectand produces the error; the identical assertion runs synchronously and reliably in the sibling at the bottom of the samedescribe.kibana-on-merge - main(first failure build 107204; reopened on build 109576) — a Jest timeout under CI parallel load.Verification
Verified locally
node scripts/eslint <file>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
Note
Share feedback in #kibana-qa. Mention
@copilotto make quick changes.