Skip to content

test: close coverage gaps in persistence, portal stores, EPG, players, and E2E#1124

Merged
4gray merged 9 commits into
masterfrom
claude/test-coverage-boost
Jul 4, 2026
Merged

test: close coverage gaps in persistence, portal stores, EPG, players, and E2E#1124
4gray merged 9 commits into
masterfrom
claude/test-coverage-boost

Conversation

@4gray

@4gray 4gray commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Closes the highest-risk test-coverage gaps found in a full audit of the repo: the persistence layer (playback positions, watch history, DB migrations), the Electron DB-first Xtream data source, Stalker favorites/recent store features, the shared EPG catch-up/summary utilities, the EPG worker service, and the VLC session service.
  • Adds the first E2E coverage for the downloads page and for direct EPG timeline interaction (zoom + programme dialog).
  • ~146 new unit tests and 3 new E2E tests across 18 new spec files. Test-only change: the single production-code edit is one line exposing createTables through the existing __databaseConnectionTestHooks object.

Changes

  • DB layer: specs for playback-position.operations (upsert, placeholder-playlist auto-creation, scoped reads/deletes), recently-viewed.operations (dedup, newest-first, 100-row cap, batch removal), path-utils, and createTables/column+index migrations incl. Xtream cache deduplication.
  • Xtream: electron-xtream-data-source DB-hit vs cold-cache paths, concurrent-request dedup, error propagation, and full method delegation; new guard-path tests in with-favorites.feature.
  • Stalker: with-stalker-favorites and with-stalker-recent feature specs (payload normalization, series-mode category forcing, meta sync, error paths).
  • EPG: specs for epg-archive.util and epg-summary.util — the pure helpers shared by the timeline (and the upcoming list view from feat(epg): add vertical list view for the live EPG panel #1115); epg-worker.service in-flight dedup, double-settle guard, progress-aware timeouts, worker lifecycle. Also settles an interrupted fetch in epg.events.spec that produced "Cannot log after tests are done" in longer runs.
  • Players: vlc-session.service specs mirroring the MPV patterns — launch argv, RC-socket reuse, exit-code handling, retry-without-RC fallback.
  • E2E: downloads.e2e.ts (empty state; full lifecycle with a stubbed native folder dialog, real download from a local server, file-on-disk assertion, UI removal) and epg-timeline-interaction.e2e.ts (zoom re-render, on-air info affordance opens the programme dialog).

Testing

  • pnpm nx run-many --target=test --projects=electron-backend,portal-xtream-data-access,portal-stalker-data-access,ui-epg,database — all green (~842 tests, of which ~146 are new)
  • pnpm nx run electron-backend-e2e:e2e-ci--src/downloads.e2e.ts — 2/2 passed
  • pnpm nx run electron-backend-e2e:e2e-ci--src/epg-timeline-interaction.e2e.ts — 1/1 passed
  • pnpm nx run-many --target=lint across all six touched projects — clean

Note: one flaky addXtreamPortal navigation timeout was observed once in a shared E2E fixture (unrelated to the new specs; it can also affect existing suites).

🤖 Generated with Claude Code

4gray and others added 6 commits July 4, 2026 11:12
…igrations

Add specs for the previously untested persistence paths: playback-position
and recently-viewed operations (upsert/dedup/ordering/scoped deletes),
shared-database path-utils, createTables and the tolerant column/index
migrations incl. Xtream cache deduplication. Exposes createTables through
the existing __databaseConnectionTestHooks object.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…uards

Add specs for electron-xtream-data-source (DB-hit vs cold-cache paths,
concurrent request dedup, error propagation, full method delegation) and
extend the favorites feature spec with the invalid-input and
content-not-found guard paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add specs for with-stalker-favorites and with-stalker-recent: payload
normalization and id/title fallbacks, series-mode category forcing, meta
sync dispatches, snackbar/callback side effects, and error paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add specs for the pure catch-up window and summary-progress helpers shared
by the EPG panels, and for epg-worker.service: in-flight dedup by URL,
double-settle guard, progress-aware timeouts, worker lifecycle and error
broadcasting. Also settle an interrupted fetch in epg.events.spec that
caused "Cannot log after tests are done" in longer runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirror the MPV session spec patterns for VLC: enqueue-command building and
RC response parsing, launch argv construction, instance reuse over the RC
socket, exit-code handling, and the retry-without-RC fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Downloads: empty state without sources, and a full lifecycle - authorize a
folder via a stubbed native dialog, download from a local server, verify
the completed item and file on disk, remove it from the UI. Timeline: zoom
changes block widths and the on-air info affordance opens the programme
dialog with the correct title and watch-live action.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR closes test-coverage gaps across the persistence layer, portal stores, EPG utilities, player services, and E2E flows, adding ~146 new unit tests and 3 new E2E tests across 18 new spec files. The single production-code change exposes createTables through the existing __databaseConnectionTestHooks object so the new migration spec can call it directly; all other files are test-only.

  • Unit tests: New specs for playback-position.operations, recently-viewed.operations, connection-migrations, electron-xtream-data-source (DB-first paths, delegation, user data), with-stalker-favorites/recent, epg-archive.util, epg-summary.util, epg-worker.service (lifecycle + timeout/progress), and vlc-session.service (argv + lifecycle).
  • E2E tests: downloads.e2e.ts covers the empty state and a full download lifecycle with a local file server and stubbed native dialog; epg-timeline-interaction.e2e.ts verifies zoom re-render and programme-dialog opening from a timeline block.
  • Infrastructure: tsconfig.app.json is updated to exclude .test-helpers.ts files from the production build, and a shared operations.test-helpers.ts provides reusable Drizzle-ORM and DB query-builder mocks for the operations specs.

Confidence Score: 5/5

Safe to merge — effectively a test-only change with one minimal, well-scoped production line added.

The single production-code edit (exposing createTables through the already-existing __databaseConnectionTestHooks object) is backward-compatible and introduces no runtime risk. Every other file is a new or extended test. The test infrastructure is sound: module mocks are file-scoped, timers are restored in afterEach, and E2E tests clean up with try/finally. No functional regressions are introduced.

libs/portal/xtream/data-access/src/lib/data-sources/electron-xtream-data-source.spec.ts sits at exactly 350 lines — the start of the hard-maximum range described in CLAUDE.md — and could be split as a follow-up.

Important Files Changed

Filename Overview
libs/shared/database/src/lib/connection.ts Single production-code change: adds createTables to the existing __databaseConnectionTestHooks export so the new connection-migrations spec can invoke it directly. Minimal and appropriate.
apps/electron-backend/tsconfig.app.json Adds *.test-helpers.ts glob patterns to the exclude list, preventing the new Jest-dependent operations.test-helpers.ts from being compiled into the production build.
libs/portal/xtream/data-access/src/lib/data-sources/electron-xtream-data-source.spec.ts New spec (350 lines): DB-hit vs cold-cache paths, concurrent-request dedup, and error propagation. At exactly 350 lines — the start of the hard-maximum range in CLAUDE.md.
apps/electron-backend/src/app/database/operations/operations.test-helpers.ts New shared Drizzle-ORM mock helpers (mockDrizzle, createDbMock, resetDrizzleMocks) used by the two new operations specs; correctly excluded from the production build via tsconfig.app.json.
apps/electron-backend-e2e/src/downloads.e2e.ts New E2E spec: empty-state check and full download lifecycle (local file server + stubbed native dialog + file-on-disk assertion + UI removal). Well-structured with proper try/finally cleanup.
apps/electron-backend-e2e/src/epg-timeline-interaction.e2e.ts New E2E spec: verifies zoom re-render (block width grows with px/min) and programme dialog opens from a timeline block; uses TZ=UTC env to stabilise EPG time calculations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph "New Unit Test Coverage"
        DB["DB Layer\nplayback-position.operations.spec\nrecently-viewed.operations.spec\nconnection-migrations.spec\npath-utils.spec"]
        XD["Xtream Data Source\nelectron-xtream-data-source.spec\n.delegation.spec\n.user-data.spec"]
        SF["Store Features\nwith-favorites.feature.spec (extended)\nwith-stalker-favorites.feature.spec\nwith-stalker-recent.feature.spec"]
        EPG["EPG Utilities\nepg-archive.util.spec\nepg-summary.util.spec\nepg-worker.service.spec\nepg-worker.service.progress.spec\nepg.events.spec (fixed)"]
        PL["Players\nvlc-session.service.spec\nvlc-session.service.lifecycle.spec"]
    end
    subgraph "New E2E Coverage"
        DL["downloads.e2e.ts\nEmpty state\nFull lifecycle (local server + native dialog stub)"]
        TL["epg-timeline-interaction.e2e.ts\nZoom re-render\nProgramme dialog open"]
    end
    subgraph "Infrastructure"
        TH["operations.test-helpers.ts\nShared Drizzle-ORM mocks"]
        TC["tsconfig.app.json\nExcludes .test-helpers.ts from prod build"]
        CT["connection.ts (+1 line)\nExposes createTables via __databaseConnectionTestHooks"]
    end
    TH --> DB
    TH --> XD
    CT --> DB
    TC --> TH
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph "New Unit Test Coverage"
        DB["DB Layer\nplayback-position.operations.spec\nrecently-viewed.operations.spec\nconnection-migrations.spec\npath-utils.spec"]
        XD["Xtream Data Source\nelectron-xtream-data-source.spec\n.delegation.spec\n.user-data.spec"]
        SF["Store Features\nwith-favorites.feature.spec (extended)\nwith-stalker-favorites.feature.spec\nwith-stalker-recent.feature.spec"]
        EPG["EPG Utilities\nepg-archive.util.spec\nepg-summary.util.spec\nepg-worker.service.spec\nepg-worker.service.progress.spec\nepg.events.spec (fixed)"]
        PL["Players\nvlc-session.service.spec\nvlc-session.service.lifecycle.spec"]
    end
    subgraph "New E2E Coverage"
        DL["downloads.e2e.ts\nEmpty state\nFull lifecycle (local server + native dialog stub)"]
        TL["epg-timeline-interaction.e2e.ts\nZoom re-render\nProgramme dialog open"]
    end
    subgraph "Infrastructure"
        TH["operations.test-helpers.ts\nShared Drizzle-ORM mocks"]
        TC["tsconfig.app.json\nExcludes .test-helpers.ts from prod build"]
        CT["connection.ts (+1 line)\nExposes createTables via __databaseConnectionTestHooks"]
    end
    TH --> DB
    TH --> XD
    CT --> DB
    TC --> TH
Loading

Reviews (3): Last reviewed commit: "fix(build): exclude *.test-helpers.ts fr..." | Re-trigger Greptile

4gray and others added 2 commits July 4, 2026 12:04
Address review feedback: extract shared drizzle mocks into
operations.test-helpers.ts and split the Electron data-source delegation
spec into delegation + user-data files. Pure reorganization - test counts
and assertions unchanged (29/13/10), all files now under 300 lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
On slow CI runners (macOS) the renderer can query SQLite while the DB
worker is still creating tables, leaving the downloads page on its
skeleton state forever. Poll a playlist read until it succeeds before
navigating on a cold profile.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@4gray

4gray commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

…sconfig

The new operations.test-helpers.ts uses jest globals and broke the webpack
build and tsc typecheck, which compile every non-spec file in the app.
Exclude the test-helpers pattern alongside the existing spec exclusions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@4gray

4gray commented Jul 4, 2026

Copy link
Copy Markdown
Owner Author

@greptileai

@4gray 4gray merged commit 57ba197 into master Jul 4, 2026
17 checks passed
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