Skip to content

[map-layers] Fix flaky drag-and-drop test setup and re-enable skipped test - #1834

Open
hl662 wants to merge 2 commits into
masterfrom
nam/map-layers-dnd-flake
Open

hl662 wants to merge 2 commits into
masterfrom
nam/map-layers-dnd-flake

Conversation

@hl662

@hl662 hl662 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

TL;DR

MapLayerManagerDragDrop.test.tsx fails intermittently in CI under load. The cause is in the test's mock: React's dev build calls component functions with no props when it builds component stacks for warnings, and the DragDropProvider mock saved those undefined props over the real ones. The mock now ignores those calls, and the test skipped for #1796 is re-enabled.

Fixes #1796

Why

The setup helper renderMapLayerManager checks that the mocked DragDropProvider received its props (line 84). That check failed at random in CI: in both runs linked from #1796, and in four CI runs on #1826/#1828 this week. #1797 skipped the first test, but the failure just moved to whichever test ran first, because the problem was in the shared setup, not in the drag behavior.

The failure sequence:

  1. render() mounts MapLayerManager, and the mock saves the provider's props.
  2. During the one-tick flush that follows, an async state update in MapLayerManager lands outside act(), so React logs the "not wrapped in act(...)" warning. The package's vitest config hides that warning from the console.
  3. To build the warning's component stack, React's dev build (describeNativeComponentFrame) calls each component in the tree with no arguments. The mock runs again and saves props === undefined.

Step 2 depends on timing, which is why the test failed under CI load but passed locally.

What

Change Why
The DragDropProvider mock only saves props when it receives them Calls React makes only to build component stacks no longer overwrite the saved props
Re-enable restores the drag-start layer order when the pointer leaves all droppables It failed the same way at the same setup line, so this fix covers it too

Testing

Reproduction and validation

To make the flake show up reliably, I ran 30 copies of the test file in one vitest run with coverage, --maxWorkers=8, and every CPU core saturated by yes processes.

Scenario Result
Before the fix 1–2 of 30 files failed per run, all at line 84
With temporary logging on the mock Showed the third provider call coming from describeNativeComponentFrame, setting undefined
With the fix and the re-enabled test, 10 runs (300 files, 900 tests) 0 failures
Fix removed, re-enabled test kept, 4 runs Failed again (2 of 120 files)
vitest --run --coverage for map-layers 11 files, 83 passed, 1 skipped (unrelated)
pnpm lint for map-layers No problems

This is a test-only change, so there's no changeset.

Nambot 🤖 (powered by claude-opus-5.5)

hl662 added 2 commits October 15, 2026 13:26
… test

React DEV invokes function components without props when building component
stacks for warnings. Under load, an async state update lands outside act(),
React logs the act warning, and the DragDropProvider mock captured undefined
props, failing the renderMapLayerManager setup assertion.

Fixes #1796
@hl662
hl662 marked this pull request as ready for review October 16, 2026 15:15
@hl662
hl662 requested review from a team, eringram and mdastous-bentley as code owners October 16, 2026 15:15
Copilot AI balanced review requested due to automatic review settings October 16, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow, test-only fix addresses the reported failure with no unresolved findings.

0 open findings

What changed in this PR

Fixes the map-layers test setup flake behind #1796 without changing production behavior.

Changes:

  • Preserves captured provider props during React’s diagnostic calls without props.
  • Re-enables the skipped drag-order restoration test.
File Description
packages/​map-layers/​src/​test/​MapLayerManagerDragDrop.test.tsx Guards mock props capture and restores the skipped test.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

[Map layers]: fix flaky test

2 participants