[Repo Assist] test: add BuildMissingScopeFixCommands and BuildPairingApprovalFixCommands unit tests#145
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…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>
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
BuildMissingScopeFixCommandsandBuildPairingApprovalFixCommandsonOpenClawGatewayClientare 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)NullOrEmptyScope_DefaultsToOperatorWrite"operator.write"WhitespaceScope_DefaultsToOperatorWriteWithSpecificScope_IncludesItInOutputoperator.approvals) appears in outputEmptyGrantedScopes_ShowsNoneReportedPlaceholder_grantedOperatorScopes == []→ placeholder textWithGrantedScopes_ListsScopesInOutputWithOperatorDeviceId_IncludesItInOutput_operatorDeviceIdappears in outputNoOperatorDeviceId_ShowsNotReportedPlaceholder_operatorDeviceId→ placeholder textWithNodeScopes_ShowsNodeTokenWarningnode.*scopes trigger the node-token warning blockWithOnlyOperatorScopes_NoNodeTokenWarningNodeScopeIsCaseInsensitiveNODE.read(uppercase) still triggers warningBuildPairingApprovalFixCommands(5 tests)WithOperatorDeviceId_UsesItInOutput_operatorDeviceIdappears in outputNoOperatorDeviceId_FallsBackToDeviceIdentity_operatorDeviceId→DeviceIdentity.DeviceIdusedEmptyGrantedScopes_ShowsNoneYetPlaceholder_grantedOperatorScopes == []→ distinct "not yet" placeholderWithGrantedScopes_ListsThemInOutputContainsApprovalInstructionsWhy 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
OpenClaw.Shared.TestsOpenClaw.Tray.TestsAll tests pass. No production code was modified — only
OpenClawGatewayClientTests.cs.