Add unit tests for the parser layer#98
Merged
Merged
Conversation
Repo had zero test coverage. NodeLinkParser, NodeLinkSerializer, and ClashConfigParser carry the most user-visible risk in the codebase (a dropped field silently produces a working-looking config that just times out — see the VLESS-XHTTP mode/extra bug) with no automated regression guard. XrayUI.Tests is a plain net10.0 xunit project that source-links the pure-logic production files instead of referencing the WinUI app project, so the test build never touches XAML compile or CsWinRT. WinAppSDK-backed dependencies (L/Loc, AppJsonSerializerContext) are stubbed test-side. 49 tests: link parsing per protocol, Parse -> ToLink -> Parse round-trip equality (via reflection over ServerEntry's public properties, so a newly persisted field is covered automatically), Clash YAML import, and custom-rule value parsing. CI runs it as a new `test` job in build.yml, parallel to the existing AOT publish job. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
XrayUI.Tests, a plainnet10.0xunit project coveringNodeLinkParser,NodeLinkSerializer,ClashConfigParser, andCustomRuleValueParser— the only parts of the codebase with zero test coverage despite carrying the most user-visible risk (a dropped field produces a config that looks valid but silently fails to connect; see the VLESS-XHTTP mode/extra bug).L/Loc,AppJsonSerializerContext.WriteReadable) are stubbed test-side.ServerEntry's public properties, so a newly persisted field is covered automatically without editing the test), Clash YAML import, and custom-rule value parsing.testjob intobuild.yml, running in parallel with the existing AOT publish job.Scope is deliberately parser-layer only. Config-builder shape tests and
xray.exe run -testsmoke tests were prototyped and dropped as more complexity than wanted for this repo.Test plan
dotnet test XrayUI.Tests/XrayUI.Tests.csproj -c Release— 49/49 passing locally.\BuildAndRun.ps1 -SkipRun— confirms the newXrayUI.Tests\**glob exclusion doesn't affect the main app builddotnet sln XrayUI-dev.slnx list— confirms the test project is registered correctlytestjob (will run on this PR)🤖 Generated with Claude Code