Expand WMFPageViewsDataController test coverage - #5968
Conversation
Investigation notes: why
|
Adds tests for the previously-untested methods of WMFPageViewsDataController against a temporary WMFCoreDataStore, raising the file from ~26% to ~87% line coverage: - fetchMostRecentTime (latest timestamp and empty-store nil) - fetchTimelinePages (descending timestamp order) - addPageViewSeconds + fetchPageViewMinutes (seconds summed into minutes) - fetchPageViewDates (bucketing by day, hour, and month) - the reading-challenge state machine via injected `now` and seeded page views: removed, not-live-yet, not-enrolled, concluded-no-streak, enrolled-not-started, ongoing streak (read/not-yet-read today), and concluded-incomplete (longest past streak) The reading-challenge state reads process-wide shared defaults; setUp now clears the dev-override and completion flags so each test is deterministic, and the tests never drive the completion path (which would persist state). fetchLinkedPageViews is left uncovered for now: exercising it with a linked page-view chain crashes the runner, which appears to be a latent issue in the relationship walk rather than a test problem. Tracking separately rather than shipping a crashing test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3c57d5b to
28c7529
Compare
Main removed the reading-challenge feature (fetchReadingChallengeState, ReadingChallengeState, and the devReadingChallengeState/readingChallengeUserCompleted user-defaults keys), so those 8 tests no longer compile. Drop them and their setUp defaults-clearing; the 10 remaining WMFPageViewsDataController tests (add/delete/import/counts/mostRecentTime/timeline/minutes/dates) are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Heads-up on a change from syncing this branch with The 10 remaining Note the |
Adds tests for the previously-untested methods of
WMFPageViewsDataController(against a temporaryWMFCoreDataStore), raising the file to ~74% (416/559 lines) coverage.What
fetchMostRecentTime— latest timestamp, andnilon an empty storefetchTimelinePages— descending timestamp orderaddPageViewSeconds+fetchPageViewMinutes— seconds summed into minutesfetchPageViewDates— bucketing by day, hour, and monthNotes
Known gap:
fetchLinkedPageViews(investigated)fetchLinkedPageViewsis intentionally left uncovered. Investigation (full notes in this comment) showed the crash is not in the relationship walk: the method returns[[CDPageView]]— raw Core DataNSManagedObjects — and the crash occurs when the caller reads a property (pageView.page?.title) off the context's queue, which trips-com.apple.CoreData.ConcurrencyDebug 1(enabled in the WMFData test plan). The walk itself terminates and returns correctly; a control that only inspects array structure passes.The method is
publicwith zero callers, and is the only method on this controller returning managed objects instead of value types (cf.fetchTimelinePages → [WMFPageWithTimestamp]). It still exists onmainas of this update. Recommended fix: remove it (dead code) or extract value types inside theperformblock, after which the linked-chain test can be added back. Worth a Phabricator ticket (GitHub issues are disabled on this repo).Verified locally: 10/10 tests pass across serial runs, SwiftLint
--strictclean.🤖 Generated with Claude Code