Skip to content

Keep schema discovery pending in the edge-query idle test - #2654

Merged
kmcginnes merged 1 commit into
mainfrom
fix-tests-for-minor-and-patch-bumps-schema-sync-edge-test-race
Nov 24, 2026
Merged

kmcginnes merged 1 commit into
mainfrom
fix-tests-for-minor-and-patch-bumps-schema-sync-edge-test-race

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

With @tanstack/react-query 5.108.2, the schema discovery query in the "should not fetch edge connections when no active schema exists" test can finish within one act flush, which enables the edge query and fails the test on Bump the minor-and-patch group (#2649). The test now keeps fetchSchema pending, as other tests in the file already do, so no schema arrives and the result no longer depends on timing.

User-facing: none

 it("should not fetch edge connections when no active schema exists", async () => {
   const state = new DbState(explorer).withNoActiveSchema();
+  vi.spyOn(explorer, "fetchSchema").mockImplementation(
+    () => new Promise(() => {}),
+  );

Evidence

Before: with react-query 5.108.2 the test fails intermittently (2 of 5 runs) with expected 'fetching' to be 'idle'. Pinned back to 5.105.0, it passes.

After: agent-tested: the test passes with react-query 5.105.0 (current main) and with 5.108.2 (the #2649 lockfile), with 15 repeated runs of the file and no failure.

Merge Danger

Door: two-way

Impact: none, test only


🤖 Written by an AI agent on my behalf.

@kmcginnes kmcginnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approved

@kmcginnes
kmcginnes merged commit ac3cb57 into main Nov 24, 2026
4 checks passed
@kmcginnes
kmcginnes deleted the fix-tests-for-minor-and-patch-bumps-schema-sync-edge-test-race branch November 24, 2026 01:41
kmcginnes added a commit that referenced this pull request Nov 25, 2026
## Summary

The test "should not fetch edge connections when no active schema
exists" couldn't always tell "the edge query never ran" from "the query
ran and found no edge types to fetch", so removing the query's `enabled`
gate could slip past it.

**User-facing:** none

```diff
 expect(result.current.edgeDiscoveryQuery.fetchStatus).toBe("idle");
+expect(result.current.edgeDiscoveryQuery.status).toBe("pending");
 expect(fetchEdgeConnectionsSpy).not.toHaveBeenCalled();
```

## Evidence

**Before:** with the gate in `edgeConnectionsQuery` replaced by
`enabled: true` and the query allowed to settle, the test passed:
`fetchStatus` returns to `"idle"` and the query function takes its
empty-edge-list branch without calling `fetchEdgeConnections`.

**After:** agent-tested by mutating the gate locally and reverting:

```text
gate in place                         -> pass
enabled: true, query still in flight  -> fail: fetchStatus expected "idle", received "fetching"
enabled: true, query settled          -> fail: status expected "pending", received "success"
enabled: true, settled, old test      -> pass (the gap this closes)
```

With the test's current timing, the existing `fetchStatus` check already
catches the mutation, because the query is still fetching when it runs.
The new `status` check covers the settled case, so the test no longer
depends on the query being in flight at the assertion. Both checks stay.

## Merge Danger

**Door:** two-way

**Impact:** none. Test-only.

## Changelog entry

None needed. Test-only change.

## Related

- Closes #2662
- Related to #2654

---

<sub>🤖 Written by an AI agent on my behalf.</sub>
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