Skip to content

[Repo Assist] test: add BuildMissingScopeFixCommands and BuildPairingApprovalFixCommands unit tests#145

Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/test-fix-command-builders-2026-04-04-ef4a5df5d73d800f
Draft

[Repo Assist] test: add BuildMissingScopeFixCommands and BuildPairingApprovalFixCommands unit tests#145
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/test-fix-command-builders-2026-04-04-ef4a5df5d73d800f

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 4, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

BuildMissingScopeFixCommands and BuildPairingApprovalFixCommands on OpenClawGatewayClient are public user-facing methods that build detailed error/help messages shown in the Quick Send dialog. Both have complex conditional logic (scope defaulting, placeholder fallbacks, node-token detection, deviceId fallback chain) but zero existing test coverage.

This PR adds 15 unit tests covering all branching paths in both methods.

BuildMissingScopeFixCommands (10 tests)

Test What it verifies
NullOrEmptyScope_DefaultsToOperatorWrite Empty scope string → defaults to "operator.write"
WhitespaceScope_DefaultsToOperatorWrite Whitespace-only scope → same default
WithSpecificScope_IncludesItInOutput Named scope (e.g. operator.approvals) appears in output
EmptyGrantedScopes_ShowsNoneReportedPlaceholder _grantedOperatorScopes == [] → placeholder text
WithGrantedScopes_ListsScopesInOutput Scopes joined and included in output
WithOperatorDeviceId_IncludesItInOutput _operatorDeviceId appears in output
NoOperatorDeviceId_ShowsNotReportedPlaceholder Null _operatorDeviceId → placeholder text
WithNodeScopes_ShowsNodeTokenWarning node.* scopes trigger the node-token warning block
WithOnlyOperatorScopes_NoNodeTokenWarning Operator-only scopes → no warning
NodeScopeIsCaseInsensitive NODE.read (uppercase) still triggers warning

BuildPairingApprovalFixCommands (5 tests)

Test What it verifies
WithOperatorDeviceId_UsesItInOutput Set _operatorDeviceId appears in output
NoOperatorDeviceId_FallsBackToDeviceIdentity Null _operatorDeviceIdDeviceIdentity.DeviceId used
EmptyGrantedScopes_ShowsNoneYetPlaceholder _grantedOperatorScopes == [] → distinct "not yet" placeholder
WithGrantedScopes_ListsThemInOutput Scopes listed in output
ContainsApprovalInstructions Output always contains required approval instructions

Why These Tests Matter

Both methods produce the messages users see when their Quick Send token is mis-configured. Regressions here would silently break the user's ability to diagnose the problem. The tests also document the exact fallback and branching behaviour, making future refactors safer.

Test Status

Suite Before After
OpenClaw.Shared.Tests 543 passed, 20 skipped 558 passed, 20 skipped (+15)
OpenClaw.Tray.Tests 120 passed 120 passed (no change)

All tests pass. No production code was modified — only OpenClawGatewayClientTests.cs.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

…mands tests

Add 15 unit tests covering the two public error-message builder methods on
OpenClawGatewayClient that previously had zero test coverage.

BuildMissingScopeFixCommands (10 tests):
- Null/empty/whitespace scope defaults to 'operator.write'
- Specific scope is preserved in output
- Empty _grantedOperatorScopes shows '(none reported by gateway)' placeholder
- Populated scopes are listed correctly
- _operatorDeviceId present vs absent (placeholder shown when missing)
- node.* scopes trigger 'node token' warning (case-insensitive match)
- Operator-only scopes produce no node-token warning

BuildPairingApprovalFixCommands (5 tests):
- _operatorDeviceId used when set
- Falls back to DeviceIdentity.DeviceId when _operatorDeviceId is null
- Empty scopes shows '(none reported by gateway yet)' placeholder
- Populated scopes are listed correctly
- Output always contains pairing approval instructions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants