Skip to content

test(scientific): make heatmap selection-clear test deterministic - #38

Merged
dsk-dev-ai merged 1 commit into
mainfrom
fix/useheatmap-selection-test-flake
Aug 17, 2026
Merged

test(scientific): make heatmap selection-clear test deterministic#38
dsk-dev-ai merged 1 commit into
mainfrom
fix/useheatmap-selection-test-flake

Conversation

@dsk-dev-ai

@dsk-dev-ai dsk-dev-ai commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Fixes the flaky CI test useHeatmap > clears the selection when a new dataset loads (failed on run #105 of the #37 merge).

Root cause: useHeatmap clears the selection in a useEffect whenever a new dataset id loads. After the initial success render, that effect runs asynchronously and could clear the selection after the test's manual selectCell, racing the intermediate assertion.

Fix: flush pending effects with await act(async () => {}) right after waiting for success, before selecting a cell — the same pattern already used in the equivalent useNetworkViewer / useProteinViewer tests — and assert the exact selected key.

Verification: 15/15 full-file runs + 725/725 web suite, lint, typecheck, build all green.

Summary by Sourcery

Tests:

  • Make the useHeatmap selection-clear test deterministic by flushing effects before selecting a cell and asserting the specific selected key.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@sourcery-ai

sourcery-ai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Makes the flaky useHeatmap selection-clear test deterministic by flushing effects before selecting a cell and asserting on the exact selected key rather than non-null state.

Sequence diagram for deterministic useHeatmap selection-clear test

sequenceDiagram
  participant Test as useHeatmap_test
  participant Hook as useHeatmap
  participant React as ReactEffects

  Test->>Hook: renderHook(loader)
  React->>Hook: run_effects_on_dataset_load
  Test->>Hook: waitFor(status === success)
  Test->>React: act(async {})
  React->>Hook: flush_pending_effects
  Test->>Hook: selectCell(key)
  Test->>Hook: waitFor(selectedKey === key)
  Test->>Hook: refetch()
  React->>Hook: run_effects_on_dataset_load
  Test->>Hook: waitFor(selectedKey === null)
Loading

File-Level Changes

Change Details Files
Stabilized the useHeatmap selection-clear test by synchronizing effect execution before selection and tightening the selection assertion.
  • Insert an await act(async () => {}) immediately after waiting for the status to become success to flush pending effects before interacting with the model.
  • Store the heatmap cell key in a key constant and use it for selection via captured.model.selectCell(key).
  • Change the intermediate assertion from checking that selectedKey is non-null to asserting it equals the expected key.
apps/web/src/lib/scientific/useHeatmap.test.tsx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fc0aad0b-284b-4bf3-8de6-cdcf4408eec9


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dsk-dev-ai
dsk-dev-ai merged commit 02854cb into main Aug 17, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant