Skip to content

Comments

Tests: stabilize Windows ACL tests + command auth registry#9493

Merged
steipete merged 1 commit intomainfrom
temp/landpr-9335-fix
Feb 5, 2026
Merged

Tests: stabilize Windows ACL tests + command auth registry#9493
steipete merged 1 commit intomainfrom
temp/landpr-9335-fix

Conversation

@steipete
Copy link
Contributor

@steipete steipete commented Feb 5, 2026

Summary

Testing

  • pnpm lint
  • pnpm build
  • OPENCLAW_TEST_WORKERS=4 pnpm test

Greptile Overview

Greptile Summary

This PR updates test-only code to reduce flakiness on Windows by making the current-username source deterministic and by ensuring the command authorization code can normalize provider-prefixed allowlist entries (e.g. discord:123) during tests.

Changes include:

  • src/security/windows-acl.test.ts: mocks node:os.userInfo() and switches to a dynamic import of windows-acl so the mock is applied before the module is loaded; assertions are tightened to check the mocked username is used.
  • src/auto-reply/command-control.test.ts: sets up a test plugin registry containing a discord plugin so channel/owner allowlist normalization behaves consistently.
  • CHANGELOG.md: adds an entry documenting the test stabilization.

Confidence Score: 3/5

  • This PR is likely safe to merge after addressing a couple of test-harness reliability issues.
  • Changes are limited to tests/changelog, but they introduce (1) a global plugin registry state that is not restored and can make unrelated tests order-dependent, and (2) top-level await usage in a test file that can fail in environments without consistent TLA support.
  • src/auto-reply/command-control.test.ts, src/security/windows-acl.test.ts

@cursor
Copy link

cursor bot commented Feb 5, 2026

PR Summary

Low Risk
Test-only changes that adjust mocking and fixture setup; low risk aside from potential for hiding real OS integration issues if the mock diverges from reality.

Overview
Improves test determinism around Windows ACL handling by mocking os.userInfo() and updating assertions to expect a stable username in resolveWindowsUserPrincipal/icacls reset command formatting.

Adjusts auto-reply command authorization tests to register a minimal discord channel plugin in the test plugin registry (via createOutboundTestPlugin) so allowlist/normalization behavior matches runtime expectations. Also updates the changelog to note the Windows ACL test stabilization fix.

Written by Cursor Bugbot for commit daebb74. This will update automatically on new commits. Configure here.

@steipete steipete merged commit d6cde28 into main Feb 5, 2026
39 of 43 checks passed
@steipete steipete deleted the temp/landpr-9335-fix branch February 5, 2026 08:38
@steipete
Copy link
Contributor Author

steipete commented Feb 5, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && OPENCLAW_TEST_WORKERS=4 pnpm test
  • Land commit: d6cde28
  • Merge commit: d6cde28

Thanks @M00N7682!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 21 to 27
beforeEach(() => {
setActivePluginRegistry(createTestRegistry([]));
setActivePluginRegistry(createRegistry());
});

afterEach(() => {
setActivePluginRegistry(createTestRegistry([]));
setActivePluginRegistry(createRegistry());
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Global plugin registry not restored

setActivePluginRegistry writes to a global singleton (src/plugins/runtime.ts:19-46), so leaving a non-empty registry configured in afterEach means subsequent test files can observe a lingering discord plugin even if they expect the default empty registry. This can create order-dependent failures when the full suite runs in a single worker/process. Consider restoring the previous registry state (save/restore) or resetting to an empty registry in afterEach instead of re-applying createRegistry().

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/command-control.test.ts
Line: 21:27

Comment:
**Global plugin registry not restored**

`setActivePluginRegistry` writes to a global singleton (`src/plugins/runtime.ts:19-46`), so leaving a non-empty registry configured in `afterEach` means subsequent test files can observe a lingering `discord` plugin even if they expect the default empty registry. This can create order-dependent failures when the full suite runs in a single worker/process. Consider restoring the previous registry state (save/restore) or resetting to an empty registry in `afterEach` instead of re-applying `createRegistry()`.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +11 to +19
const {
createIcaclsResetCommand,
formatIcaclsResetCommand,
formatWindowsAclSummary,
inspectWindowsAcl,
parseIcaclsOutput,
resolveWindowsUserPrincipal,
summarizeWindowsAcl,
type WindowsAclEntry,
type WindowsAclSummary,
} from "./windows-acl.js";
} = await import("./windows-acl.js");
Copy link
Contributor

Choose a reason for hiding this comment

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

Top-level await in tests

This file uses a top-level await import("./windows-acl.js"). If the test runner/transpilation target doesn’t support top-level await for .test.ts in all environments this repo runs in, this will fail to load the test file entirely (syntax/runtime error before any test executes). If the intention is only to ensure vi.mock("node:os") runs before importing windows-acl, it’s safer to do the dynamic import inside a beforeAll/beforeEach (or otherwise ensure the repo explicitly supports TLA in Vitest across Node versions).

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/security/windows-acl.test.ts
Line: 11:19

Comment:
**Top-level await in tests**

This file uses a top-level `await import("./windows-acl.js")`. If the test runner/transpilation target doesn’t support top-level await for `.test.ts` in all environments this repo runs in, this will fail to load the test file entirely (syntax/runtime error before any test executes). If the intention is only to ensure `vi.mock("node:os")` runs before importing `windows-acl`, it’s safer to do the dynamic import inside a `beforeAll`/`beforeEach` (or otherwise ensure the repo explicitly supports TLA in Vitest across Node versions).

How can I resolve this? If you propose a fix, please make it concise.

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