Skip to content

test(cv): wait for the loaded Kalshi Event header before reading its title - #38947

Merged
cursor[bot] merged 1 commit into
mainfrom
fix/cv-predict-entry-kalshi-event-title-remount
Nov 5, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
fix/cv-predict-entry-kalshi-event-title-remount

Conversation

@cursor

@cursor cursor Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Stabilizes Predict entry actions › through the registered Predict root router (Kalshi rollout) › opens the Kalshi Event on the PredictNext Event screen (app/components/UI/PredictNext/navigation/entry/PredictEntryActions.view.test.tsx, Component view tests shard 5). It failed 3 times in 28 completed shard-5 jobs on main since the test landed (2026-11-04 19:00 UTC to 2026-11-05 09:00 UTC, about 11%), and passed on the commits between and after those failures.

Failure signature

  • Unable to find node on an unmounted component. at expect(await view.findByTestId(PredictEventScreenTestIds.TITLE)).toHaveTextContent(KALSHI_EVENT.title).
  • Failed jobs (each shard finished Jest with Tests: 1 failed, 302 passed, 303 total):

Flake proof (classification: probable_flaky)

Root cause (category: stale_element)

PredictEventScreen renders the header title in two different trees:

  • While the Event loads: EventScreenLayout → EventScreenChrome, with title={titleSnapshot}.
  • After the Event loads: a fragment → EventScreenChrome, with title={event.title}.

The root element type changes, so React remounts the whole VIEW / TITLE subtree when useEvent resolves. The intent passes titleSnapshot: KALSHI_EVENT.title, so the loading title already has the expected text. findByTestId(TITLE) can therefore resolve on the loading-phase node. If the Event read lands in the gap before toHaveTextContent runs, that node is detached and the matcher throws Unable to find node on an unmounted component. Whether the load lands in that gap depends on runner timing, which is why the test fails on busy CI shards and passes locally.

The same mechanism also made the old assertion a false green: with configurePredictNextEvent(KALSHI_EVENT) removed, the original test still passed, because the loading title already showed the snapshot.

Fix

The test now awaits PredictEventScreenTestIds.STANDARD_HEADER, which only renders on the loaded branch. It then reads the title with a fresh getByTestId. This matches the existing pattern in PredictEventScreen.view.test.tsx (renders all standard Event header fields from the immutable Event). The assertion now targets the loaded Event's title, so it cannot read a node that is about to unmount. No retries, sleeps, or longer timeouts were added, and the expected title and the Home-absence check are unchanged.

Scope: test-only, one test in one file.

Validation

  • Exact test, 10 consecutive in-band runs: yarn jest -c jest.config.view.js app/components/UI/PredictNext/navigation/entry/PredictEntryActions.view.test.tsx -t "opens the Kalshi Event on the PredictNext Event screen" --runInBand --silent --coverage=false. 10 of 10 passed.
  • Full file: 21 of 21 passed. With --randomize (seed 2048902482): 21 of 21 passed.
  • Assertion-kill 1: I changed the expected title to "Jets at Bills". The test failed with expect(element).toHaveTextContent() at line 334. Reverted, and the re-run passed.
  • Assertion-kill 2: I removed configurePredictNextEvent(KALSHI_EVENT). The test failed with Unable to find an element with testID: predict-next-event-standard-header. The original test passed with the same mutation. Reverted.
  • ESLint: pass. Prettier: pass. yarn lint:tsc: 0 errors.

Test layer placement

Scope: app/components/UI/PredictNext/navigation/entry/PredictEntryActions.view.test.tsx
Mode: Implement (applied)

Inventory

  • Unit: resolvePredictIntent.test.ts covers intent resolution to PredictNext routes.
  • CV: PredictEntryActions.view.test.tsx covers entry actions through route probes and the registered Predict root router.
  • Integration: none for entry actions.
  • E2E: none.

Tasks

  • KEEP CV: PredictEntryActions — opens the Kalshi Event on the PredictNext Event screen
  • Re-run CV for the touched file

App code

  • None

Residual / follow-ups

  • none

Jira: N/A. Report: N/A.

Mobile-testing self-check

  • Skill: mobile-testing @ aa0d897492a82f09eeadf53fae27380029714dd6
  • References: component-view.md; component-view/reference.md (Self-Review Checklist, Golden Rules, Diagnosing Failures)
  • Paths: app/components/UI/PredictNext/navigation/entry/PredictEntryActions.view.test.tsx
  • API mocking: not applicable (no HTTP, fetch, nock, or api-mocking change)
  • Mock isolation / restore: pass (unchanged beforeEach jest.clearAllMocks(); this case changes no mock implementation)
  • Origin+path and single response body: not applicable
  • Other Golden Rules / Self-Review Checklist: pass. The test awaits the assertion subject's owning loaded header (Rules 13 and 16), does not hold a node across a remount (checklist 10), has no nested waiter (Rule 14), and uses test ID constants (Rule 8).

Changelog

CHANGELOG entry: null

Related issues

Refs: N/A. This is a CV flakiness stabilization.

Manual testing steps

This change only affects a component view test. Validate it with yarn jest -c jest.config.view.js app/components/UI/PredictNext/navigation/entry/PredictEntryActions.view.test.tsx --runInBand. The expected result is 21 of 21 passing.

Feature: Predict entry actions

  Scenario: user opens a Kalshi Event from outside Predict
    Given Predict runs the next implementation with Kalshi as the only Venue

    When user opens the Kalshi Event entry action
    Then the PredictNext Event screen shows the loaded Event header and title

Screenshots/Recordings

N/A. This is a non-visual, test-only fix. Failed CI jobs: 126807056810, 126882319418, 126884669621.

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android (N/A: test-only change)
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario (N/A: test-only change)
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics (N/A: test-only change)

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
Open in Web View Automation 

Note

Low Risk
Test-only change to assertion timing; no production or runtime behavior affected.

Overview
Stabilizes the Predict entry actions component view test that opens a Kalshi Event through the registered Predict root router.

The test no longer waits on PredictEventScreenTestIds.VIEW and then findByTestId(TITLE), which could attach to the loading-phase title node that unmounts when PredictEventScreen switches to the loaded header tree. It now awaits STANDARD_HEADER (loaded branch only), then reads the title with a synchronous getByTestId(TITLE), matching the pattern in PredictEventScreen.view.test.tsx. A short comment documents the remount behavior. Test-only; no app code changes.

Reviewed by Cursor Bugbot for commit 11b6ab9. Bugbot is set up for automated code reviews on this repo. Configure here.

…title

Co-authored-by: ramon.acitores <ramon.acitores@consensys.net>
@cursor
cursor Bot marked this pull request as ready for review November 5, 2026 09:25
@cursor
cursor Bot requested a review from a team as a code owner November 5, 2026 09:25
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@cursor
cursor Bot enabled auto-merge November 5, 2026 10:21
@matallui matallui added the team-predict Predict team label Nov 5, 2026
@cursor
cursor Bot added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 97fdae3 Nov 5, 2026
106 of 108 checks passed
@cursor
cursor Bot deleted the fix/cv-predict-entry-kalshi-event-title-remount branch November 5, 2026 13:06
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
@metamask-ci metamask-ci Bot added the release-8.20.0 Issue or pull request that will be included in release 8.20.0 label Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.20.0 Issue or pull request that will be included in release 8.20.0 size-XS team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants