Skip to content

test(ios-readplace): backfill untested logic seams and ratchet coverage#922

Closed
FagnerMartinsBrack wants to merge 1 commit into
ios/share-extension-testablefrom
ios/untested-seams
Closed

test(ios-readplace): backfill untested logic seams and ratchet coverage#922
FagnerMartinsBrack wants to merge 1 commit into
ios/share-extension-testablefrom
ios/untested-seams

Conversation

@FagnerMartinsBrack

Copy link
Copy Markdown
Member

Stacked on #921 (base = ios/share-extension-testable). Review/merge after it.

Purpose

Several logic seams had error/edge paths with no coverage — the kind of gaps that surface as a silent regression. E3 covers them and ratchets the coverage floors up (the gate PR #920 seeded them at today's numbers).

What got covered (and the floors raised)

File Before After New coverage
OAuthService 90% 98% malformed 200 body → .malformedResponse; 200 without refresh_token.malformedResponse; refresh with no stored token → .noRefreshToken (no request made); revoke with no token → skips the network, still clears
KeychainTokenStorage 57% 98% a real simulator-keychain round trip through the production path (add / read / update / remove, key isolation) — the UserDefaults double never exercised the Keychain code
TokenStore 85% 99% extracted the embedded-provisioning-profile parsing into a pure parseAppGroupId(fromProvisioningProfile:) and covered it with fixtures (valid, no plist, no app-group entitlement, empty array); only the Bundle.main read stays untested
ReadingListViewModel 94% 95% a 401 whose refresh also fails routes to the logout callback with no error banner; a collection warning populates warningText
AppSession (completeSignIn) 79% 83% a callback carrying error= is denied; a callback with no code is .missingCode; a failed code exchange surfaces as a failure — none logging in

The one production change is the parseAppGroupId extraction (behaviour-preserving) so the profile parsing is unit-testable without a real Bundle.main.

Still deferred (noted for a later ratchet)

HTMLCaptor's WKWebView state machine and the reader htmx JS detector remain in the OS-boundary exclusions — covering them needs a JSContext/WebKit harness, a larger change than this backfill. AppSession is at 83% (the remaining lines are the concurrent WebKit-wipe logout choreography).

Testing

Full suite green with the gate active (242 tests, +15; iOS coverage gate passed: 21 files at or above floor, 9 excluded), plus the STAGING smoke pass.

Cover error and edge paths that had no tests, and raise their coverage floors:

- OAuthService (90%→98%): a malformed 200 body and a 200 missing refresh_token
  both surface .malformedResponse; refresh without a stored token throws
  .noRefreshToken and makes no request; revoke without a token skips the network
  but still clears.
- AppSession completeSignIn (79%→83%): a callback carrying error= is denied, a
  callback with no code is .missingCode, and a failed code exchange surfaces as a
  failure — none exchanging or logging in.
- ReadingListViewModel (94%→95%): a 401 whose refresh also fails routes to the
  logout callback without an error banner; a collection warning populates
  warningText.
- KeychainTokenStorage (57%→98%): a real simulator-keychain round trip through
  the production path (add / read / update / remove, key isolation) — the test
  double never exercised it.
- TokenStore (85%→99%): extract the embedded-provisioning-profile parsing into a
  pure `parseAppGroupId(fromProvisioningProfile:)` and cover it with fixtures
  (valid profile, no plist, no app-group entitlement, empty group array); the
  `Bundle.main` read stays the only untested line.
@FagnerMartinsBrack

Copy link
Copy Markdown
Member Author

Superseded by #927, which consolidates all 9 stacked PRs into one PR targeting main (so CI runs and it's independently deployable). See #927 for the full description.

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