Skip to content

[Synthetics] Fix useSyntheticsRules test#247259

Merged
cesco-f merged 1 commit intoelastic:mainfrom
cesco-f:fix-test-2
Dec 22, 2025
Merged

[Synthetics] Fix useSyntheticsRules test#247259
cesco-f merged 1 commit intoelastic:mainfrom
cesco-f:fix-test-2

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Dec 22, 2025

Summary

Fixes a timing-based flaky test failure in use_synthetics_rules.test.tsx.

Problem

The test assertions were comparing full action objects including meta.dispatchedAt timestamps. Since the timestamp is generated at call time, there's a small time difference between when the hook dispatches the action and when the test generates a new action for comparison, causing intermittent failures:

Solution

Use expect.objectContaining() with expect.any(Number) to validate the action structure without requiring an exact timestamp match.

@cesco-f cesco-f requested a review from a team as a code owner December 22, 2025 13:24
@cesco-f cesco-f added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.3.0 v9.2.4 labels Dec 22, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Dec 22, 2025
@cesco-f cesco-f enabled auto-merge (squash) December 22, 2025 14:14
@cesco-f cesco-f merged commit 8ac629e into elastic:main Dec 22, 2025
28 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.2, 9.3

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

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

@cesco-f cesco-f deleted the fix-test-2 branch December 22, 2025 16:08
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 22, 2025
### Summary
Fixes a timing-based flaky test failure in
`use_synthetics_rules.test.tsx`.

### Problem
The test assertions were comparing full action objects including
`meta.dispatchedAt` timestamps. Since the timestamp is generated at call
time, there's a small time difference between when the hook dispatches
the action and when the test generates a new action for comparison,
causing intermittent failures:

### Solution
Use `expect.objectContaining()` with `expect.any(Number)` to validate
the action structure without requiring an exact timestamp match.

(cherry picked from commit 8ac629e)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 22, 2025
### Summary
Fixes a timing-based flaky test failure in
`use_synthetics_rules.test.tsx`.

### Problem
The test assertions were comparing full action objects including
`meta.dispatchedAt` timestamps. Since the timestamp is generated at call
time, there's a small time difference between when the hook dispatches
the action and when the test generates a new action for comparison,
causing intermittent failures:

### Solution
Use `expect.objectContaining()` with `expect.any(Number)` to validate
the action structure without requiring an exact timestamp match.

(cherry picked from commit 8ac629e)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.2
9.3

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

Questions ?

Please refer to the Backport tool documentation

mbondyra added a commit to mbondyra/kibana that referenced this pull request Dec 22, 2025
…d_step_back

* commit '51756d2722200a991607658d48ecda50aeb04a7d': (76 commits)
  [Synthetics] Fix SyncGlobalParamsSpaces flaky test (elastic#246487)
  [Synthetics] Fix useSyntheticsRules test (elastic#247259)
  [ES|QL] Fix index editor flaky test (elastic#247233)
  [ResponseOps][Reporting] Fix "failed to decrypt apiKey" error while disabling/enabling scheduled reports (elastic#247236)
  [Console] Update console definitions (main) (elastic#247214)
  [ES|QL] Esql indentation shortcut on the editor (elastic#247234)
  [Streams] Use original request for rules client when in default space (elastic#247014)
  Consolidate and improve unflattenObject (elastic#246725)
  [scout] use svl mode to run api-int tests (elastic#247223)
  SIEM Readiness V2 (elastic#245776)
  [ObsPresentation][A11y] Fix asset details flyout header announcement (elastic#246872)
  [Streams] Add abort support and silent mode for stream description generation (elastic#247082)
  [SLO] Add environment context to SLO feedback button (elastic#247221)
  Ignore the reason and retry systematically (elastic#246830)
  Update dependency @types/moment-duration-format to ^2.2.7 (main) (elastic#242221)
  [Streams 🌊 ] Add explicit waits for data grid rows before clicking expand button (elastic#246919)
  [Security Solution][Entity Analytics][Risk Scoring] Handle special characters in ESQL query for risk scoring (elastic#247060)
  [ML] Data frame analytics: Updates page headers (elastic#247097)
  [ES|QL] Build function arguments suggestions from hints (elastic#246736)
  Update dependency @hey-api/openapi-ts to v0.88.1 (main) (elastic#247210)
  ...
kibanamachine added a commit that referenced this pull request Dec 22, 2025
# Backport

This will backport the following commits from `main` to `9.3`:
- [[Synthetics] Fix useSyntheticsRules test
(#247259)](#247259)

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

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-12-22T16:03:32Z","message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.3.0","v9.4.0","author:actionable-obs","Team:obs-ux-management","v9.2.4"],"title":"[Synthetics]
Fix useSyntheticsRules
test","number":247259,"url":"https://github.com/elastic/kibana/pull/247259","mergeCommit":{"message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247259","number":247259,"mergeCommit":{"message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2"}},{"branch":"9.2","label":"v9.2.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
kibanamachine added a commit that referenced this pull request Dec 22, 2025
# Backport

This will backport the following commits from `main` to `9.2`:
- [[Synthetics] Fix useSyntheticsRules test
(#247259)](#247259)

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

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-12-22T16:03:32Z","message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.3.0","v9.4.0","author:actionable-obs","Team:obs-ux-management","v9.2.4"],"title":"[Synthetics]
Fix useSyntheticsRules
test","number":247259,"url":"https://github.com/elastic/kibana/pull/247259","mergeCommit":{"message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247259","number":247259,"mergeCommit":{"message":"[Synthetics]
Fix useSyntheticsRules test (#247259)\n\n### Summary\nFixes a
timing-based flaky test failure
in\n`use_synthetics_rules.test.tsx`.\n\n### Problem\nThe test assertions
were comparing full action objects including\n`meta.dispatchedAt`
timestamps. Since the timestamp is generated at call\ntime, there's a
small time difference between when the hook dispatches\nthe action and
when the test generates a new action for comparison,\ncausing
intermittent failures:\n\n### Solution\nUse `expect.objectContaining()`
with `expect.any(Number)` to validate\nthe action structure without
requiring an exact timestamp
match.","sha":"8ac629e59c686eec1ebc7312e55756c12bd8cbc2"}},{"branch":"9.2","label":"v9.2.4","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Jan 6, 2026
### Summary
Fixes a timing-based flaky test failure in
`use_synthetics_rules.test.tsx`.

### Problem
The test assertions were comparing full action objects including
`meta.dispatchedAt` timestamps. Since the timestamp is generated at call
time, there's a small time difference between when the hook dispatches
the action and when the test generates a new action for comparison,
causing intermittent failures:

### Solution
Use `expect.objectContaining()` with `expect.any(Number)` to validate
the action structure without requiring an exact timestamp match.
dej611 pushed a commit to dej611/kibana that referenced this pull request Jan 8, 2026
### Summary
Fixes a timing-based flaky test failure in
`use_synthetics_rules.test.tsx`.

### Problem
The test assertions were comparing full action objects including
`meta.dispatchedAt` timestamps. Since the timestamp is generated at call
time, there's a small time difference between when the hook dispatches
the action and when the test generates a new action for comparison,
causing intermittent failures:

### Solution
Use `expect.objectContaining()` with `expect.any(Number)` to validate
the action structure without requiring an exact timestamp match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management v9.2.4 v9.3.0 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants