Skip to content

agentHost: fix mis-nested tests in agentHostGitStateService.test.ts - #342262

Merged
Alexandru Dima (alexdima) merged 1 commit into
mainfrom
alexdima/fix-mocha-test-nesting
Oct 17, 2026
Merged

Alexandru Dima (alexdima) merged 1 commit into
mainfrom
alexdima/fix-mocha-test-nesting

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

fyi Benjamin Christopher Simmonds (@benibenj) we had miss-matched }); in the file which was leading to a pattern like

test(..., () => {
   test(...)
});

The inner tests would never execute, must have been some bad conflict resolution.


Fixes two mis-nested test(...) calls in agentHostGitStateService.test.ts (introduced in 78ac5ac, #329149). They were declared inside the body of a preceding test, so Mocha silently dropped them:

  • preserves GitHub state updated while a pull request lookup is in flight
  • does not capture an empty baseline for a stale branch lookup

The change only closes the enclosing tests, removes the stray closing braces and fixes indentation. No test logic changed.

How to test:

scripts/test.sh --run src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts

Result: 91 passing, including both previously hidden tests. npm run eslint -- src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts passed.

Two test() calls were nested inside another test's body, so Mocha never ran them. Close the enclosing tests and dedent the nested ones.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 10:53

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

Both nesting corrections match the stated purpose, with unchanged test logic and no unresolved findings.

No open issues 🎉

What changed in this PR

Restores two previously hidden Agent Host Git state regression tests so Mocha registers them at suite scope.

Changes:

  • Corrects test boundaries and indentation.
  • Preserves all test setup and assertions; production code is unchanged.
File Description
src/​vs/​platform/​agentHost/​test/​node/​agentHostGitStateService.test.ts Fixes nesting of two regression tests.

Review effort: Balanced

@alexdima
Alexandru Dima (alexdima) merged commit 15dcc3f into main Oct 17, 2026
87 of 88 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the alexdima/fix-mocha-test-nesting branch October 17, 2026 13:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 17, 2026
Alexandru Dima (alexdima) added a commit that referenced this pull request Oct 17, 2026
* eslint: require runWithFakedTimers to wrap the whole test body

Add `local/code-run-with-faked-timers-whole-test`, which flags
`runWithFakedTimers` calls in `src/vs/**/*.test.ts` that wrap only part
of a test. Code outside the callback runs on real timers, and the drain
after the callback can fire unrelated pending timers (e.g. polls) before
the assertions that follow.

Allowed: the call is the whole test body, a wrapper helper whose whole
body is the call, or an `onHistory` capture (history is delivered only
after the drain). Nested calls and calls from hooks are reported too.

Existing violations (19 files) are excluded and can be fixed file by file.

Co-authored-by: Copilot <[email protected]>

* eslint: update runWithFakedTimers baseline after merging main

`agentHostGitStateService.test.ts` no longer has partial wraps (#342262).
`serverIntegrationTestHelpers.test.ts` spawns a real server process, so
only the bounded exit waits run in virtual time; suppress inline with a reason.

Co-authored-by: Copilot <[email protected]>

* eslint: report unawaited and hook-nested runWithFakedTimers calls

A bare `runWithFakedTimers(...)` statement was accepted as a whole test
body, although the test can finish before the callback, the drain, and
the timer restore run. Report it as `floating`.

Calls inside a function nested in a setup/teardown hook were accepted
as wrapper helpers; report them as `hook`.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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.

3 participants