Repository navigation
test: run reading-profile SQL Server tests on Testcontainers - #1614
Draft
BenjaminMichaelis wants to merge 39 commits into
Draft
BenjaminMichaelis wants to merge 39 commits into
BenjaminMichaelis wants to merge 39 commits into
Conversation
- WordCountService: singleton that walks all SiteMappings at startup,
strips <pre>/<code>/<script>/<style> via HtmlAgilityPack, and caches
per-page, per-chapter, and book-wide prose word counts + prefix sums
- ReadingActivity + UserReadingProfile EF entities with migration
AddReadingTimeTracking; retention capped at 500 rows/user
- ReadingController (POST /session, GET /profile, GET /book-stats,
POST /reset); WPM algorithm: >900 WPM hard-discard, slow outlier
clamped at 0.25x referenceWpm, aggregate stored as
{totalWords, totalActiveSeconds}
- useReadingTracker.js composable: activity state machine (READING /
IDLE / HIDDEN), 5-min idle threshold, visibilitychange instant-pause,
localStorage for anonymous users, flush-on-navigate, sync local→server
on first authenticated page load
- ReadingTimeRemaining.vue: displays 'X min left in chapter / Y min left
in book' in header; live scroll-fraction update; only renders on
chapter pages; integrated into HeaderStatus.vue
- Reset button in Identity Manage Profile page
- Wired in HomeController (word-count ViewBag) and _Layout.cshtml
(window.* globals: CURRENT_PAGE_KEY, PAGE_WORD_COUNT, CHAPTER_WORD_COUNT,
WORDS_BEFORE_PAGE, CHAPTER_START_WORDS, BOOK_WORD_COUNT)
- Tests: WordCountServiceTests (prose-only counting, prefix sums,
chapter/book totals) and ReadingControllerTests (auth guards, WPM
algorithm constants, book-stats endpoint)
… deserialization) SiteMapping.PrimaryKey is not serialized in sitemap.json; after deserialization it is null, causing ArgumentNullException in WordCountService constructor and HomeController when calling Dictionary.ContainsKey(null). Use mapping.Keys.FirstOrDefault() ?? mapping.PrimaryKey consistently, matching the pattern already used in BookToolQueryService. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove unused chapter offset, credit only scroll progress made during the session, validate PageKey length, and apply outlier rules to anonymous sessions.
…r with page-lifecycle flushing Split the tracker into activity-state, readingApi and orchestrator units, measure progress against the content element, cap credited words by active time, remove localStorage and the duplicated outlier rules, and improve the header widget accessibility.
…dingActivity Replace the activity audit table with a single UserReadingProfile migration, move business rules out of the controller into IReadingProfileService and ReadingSpeedPolicy bound to ReadingOptions, use an atomic upsert, validate requests, and add per-user rate limiting.
…age stats Single immutable PageWordStats snapshot (FrozenDictionary), built in IHostedLifecycleService.StartingAsync; logs and isolates bad content files, decodes HTML entities, counts inline code but not code blocks. Tests rewritten around requirements.
Removes the reading ViewBag entries and window globals; csrf-token meta is only rendered for signed-in users.
…t, personal data export, regenerated migration - ReadingOptions: DefaultWpm/MaxCreditWpm/IdleThresholdSeconds/PeriodicFlushActiveSeconds/MaxActiveSecondsPerInterval with validation (ValidateOnStart + cross-field validator) - drop unused Completed from the interval DTO; per-interval active-seconds cap from options - replace MERGE/ON CONFLICT with ExecuteUpdate + insert-on-miss + duplicate-key retry - READING_CONTEXT carries wpm and client constants - include UserReadingProfile in personal data download - restore Program.cs CRLF and empty OnModelCreating; regenerate migration
…ry-forward, reset broadcast, a11y, Vitest
…, progress, activity
… rate limit, context parsing, personal data Co-Authored-By: Claude <noreply@anthropic.com>
…eal unreadable file, just-below-slow case
…; add reading-reset tests
…details Data-driven speed policy and options tests, HtmlAgilityPack-based context parsing, endpoint-metadata request size check, structured log assertions, CI-failing SQL Server gating, migration lookup by name, FK-violation and UpdatedAtUtc tests.
…from the 400 body shape
…he signed-in user
Neither endpoint is called by the client (it reads wpm from the session response and READING_CONTEXT). Removes the dead response types, IWordCountService.GetChapterWordCounts, the ReadingPublic rate-limit policy and the tests that only covered the removed endpoints.
…d error keys Move the interval-count and active-seconds limits into IValidatableObject on the request DTOs (reading ReadingOptions from the validation service provider) so MVC reports keys such as Intervals[1].ActiveSeconds. The unknown-page-key error now carries the indexed key too. The controller no longer needs ReadingOptions.
… privacy, rate limit default, dead code)
They need a real SQL Server and failed on every PR CI job that has none. They move to a follow-up that uses Testcontainers.
…rver Self-provisions a pinned SQL Server container per test class instead of requiring ESSENTIALCSHARP_TEST_SQLSERVER and a CI service container. Skips when no Linux container runtime is available; fails on GitHub Linux CI so coverage cannot silently drop.
BenjaminMichaelis
force-pushed
the
bmichaelis-reading-time-tracker-8ef
branch
from
November 14, 2026 01:20
ca5e847 to
d02419e
Compare
This branch has not been deployed
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
Follow-up to #1267. Adds the real-SQL-Server integration tests for the reading profile back, now self-provisioned with Testcontainers instead of an environment variable and a CI service container.
Stacked on #1267: the base is that PR's branch, because these tests exercise code that only exists there. Retarget to
mainonce #1267 merges.Why a separate PR
In #1267 these tests required
ESSENTIALCSHARP_TEST_SQLSERVERand failed when it was missing in CI. The SQL Server service container and that variable existed only on the push-only "Build and test (Ubuntu)" job, so all 8 tests failed on every OS in the PR's CI matrix (8 of 540 per job, nothing else failing).What it covers
Against a real SQL Server (SQLite serializes writers, so it cannot prove these):
AddUserReadingProfilemigration applies, reverts and reapplies; no pending model changes; expected columnsHow it works
Testcontainers.MsSql4.16.0; one container per test class with a pinned image (2022-CU20-ubuntu-22.04), disposed in the class teardown.GITHUB_ACTIONS=trueandRUNNER_OS=Linux) a failure to start the container fails the tests, so coverage cannot silently disappear.Testing
Review notes
RUNNER_OS; an explicit workflow env var would be the alternative.