Improve test coverage#91
Merged
Merged
Conversation
Covers Bill params, JSON decoding, balance calculation, bill sorting, network request contracts (Cospend + iHateMoney), URL scheme decoding,and AddProjectManually URL normalization.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a substantial unit-testing safety net for PayForMe before larger refactors. It introduces shared test helpers, expands existing URL/AddProject tests with clearer naming and richer assertions, and adds new test suites covering URL request building, JSON decoding, bill parameter generation, sort modes, and balance calculation. A stray copyright line is also removed from ShareProjectQRCodeViewModel.swift.
Changes:
- New test files:
TestHelpers(mock URL protocol + fixtures),NetworkRequestTests,JSONDecodingTests,BillTests,BillSortingTests,BalanceCalculationTests. - Existing
UrlExtensionsTestsandAddProjectManuallyTestsare simplified, renamed for intent, and given explanatory comments. - Xcode project updated to include the new test files in the test target.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| PayForMeTests/TestHelpers.swift | Adds MockURLProtocol and Project/Bill/Person fixtures used across new tests. |
| PayForMeTests/NetworkRequestTests.swift | Verifies URL paths, auth headers, and HTTP methods for both backends via MockURLProtocol. |
| PayForMeTests/JSONDecodingTests.swift | Decodes representative server payloads into Bill, Person, and APIProject. |
| PayForMeTests/BillTests.swift | Asserts backend-specific shape of Bill.paramsFor and Bill.newBill() defaults. |
| PayForMeTests/BillSortingTests.swift | Covers BillListViewModel.SortedBy.sort for both modes and edge cases. |
| PayForMeTests/BalanceCalculationTests.swift | Validates BalanceViewModel.setBalances() math, including the zero-sum invariant. |
| PayForMeTests/UrlExtensionsTests.swift | Tightens existing tests and adds QR-dispatch and malformed-URL coverage. |
| PayForMeTests/AddProjectManuallyTests.swift | Renames tests for clarity and documents debounce timing. |
| PayForMe/Views/Projects/ShareProjectQRCodeViewModel.swift | Removes a single copyright line from the file header. |
| PayForMe.xcodeproj/project.pbxproj | Wires the new test files into the test target. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
I plan to improve the app and need to do some significant amount of changes to the infrastructure (especially likely to combine) eventually. Real people depend on this single client on the iOS platform and one of my highest goals is to only increase the value PayForMe brings to them and therefore prevent introducing new bugs. That's why one of my first bigger contribution to this codebase are many unit tests that ensure the current (correct) behavior of the app.
Changes were co-authored by Claude Sonnet 4.6 High and every line of code was manually reviewed, and altered if needed, by a real human (me).