[PR #155] [MERGED] [tests] Add golden tests for post mapper and HTML renderer #157

Closed
opened 2026-10-13 19:48:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/155
Author: @Glitchy-Sheep
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: test/golden-fixtures


📝 Commits (1)

  • f8e95ab test: Add golden tests for post mapper and HTML renderer

📊 Changes

5 files changed (+1058 additions, -2 deletions)

View changed files

➕ test/fixtures/rendered_post.html (+592 -0)
➕ test/fixtures/single_post.json (+275 -0)
➕ test/fixtures/single_post_domain.json (+99 -0)
📝 test/unit/html_generator/html_templates_test.py (+34 -2)
➕ test/unit/mappers/post_mapper_golden_test.py (+58 -0)

📄 Description

[tests] Add golden tests for post mapper and HTML renderer

Summary

Third PR of the test safety-net stage (stacked on #154, merge order: #153 -> #154 -> this). Golden files pin the two transformations the upcoming refactoring touches hardest: DTO-to-domain mapping and HTML rendering. From now on neither can change a field or a byte unnoticed - the test goes red and the golden diff shows up in review.

What is in here

  • test/fixtures/single_post.json - a captured real API response of one post, sanitized: all ids, urls and texts replaced with fakes, zero real identifiers (checked). The real emptiness pattern of playerUrls is preserved: progressive mp4 + dash/hls set, ondemand/live/hd empty. Extended with an audio chunk and an unknown-type chunk
  • test/fixtures/single_post_domain.json - the pinned mapping result: 11 DTO chunks -> 10 domain chunks + unknown content recorded with its exact path (data[10].type)
  • test/fixtures/rendered_post.html - the pinned byte-for-byte render of a fixed chunk showcase
  • The showcase moved into a _showcase_chunks() helper (fresh list per call - the renderer mutates video/audio urls in place) and now covers file and audio chunks too

UPDATE_GOLDEN=1 task test regenerates both goldens for intentional changes - the golden diff is then reviewed like any code.

The goldens already document three audit findings

  • image and audio urls get no signed_query appended (files do) - a 403 risk on protected content
  • a file name goes into HTML unescaped (the showcase pins release <v2> & notes.zip raw)
  • external video links render with hardcoded type="video/mp4"

The upcoming render-fix PR will change these lines - visibly, as golden diffs.

Verification

  • task ci green: lint, format, pyright, 149 passed + 1 xfailed, build
  • Leak check on fixtures: author name, boosty hostnames, real post/chunk ids - 0 hits

Notes

  • No changelog entry: tests only (ci/skip-changelog)
  • Last PR of the stage after this: local-server e2e + CLI smoke + coverage gate

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/155 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `test/golden-fixtures` --- ### 📝 Commits (1) - [`f8e95ab`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/f8e95ab74e028a92bf2509935213308bbb91c452) test: Add golden tests for post mapper and HTML renderer ### 📊 Changes **5 files changed** (+1058 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `test/fixtures/rendered_post.html` (+592 -0) ➕ `test/fixtures/single_post.json` (+275 -0) ➕ `test/fixtures/single_post_domain.json` (+99 -0) 📝 `test/unit/html_generator/html_templates_test.py` (+34 -2) ➕ `test/unit/mappers/post_mapper_golden_test.py` (+58 -0) </details> ### 📄 Description # [tests] Add golden tests for post mapper and HTML renderer ## Summary Third PR of the test safety-net stage (stacked on #154, merge order: #153 -> #154 -> this). Golden files pin the two transformations the upcoming refactoring touches hardest: DTO-to-domain mapping and HTML rendering. From now on neither can change a field or a byte unnoticed - the test goes red and the golden diff shows up in review. ## What is in here - `test/fixtures/single_post.json` - a captured real API response of one post, sanitized: all ids, urls and texts replaced with fakes, zero real identifiers (checked). The real emptiness pattern of `playerUrls` is preserved: progressive mp4 + dash/hls set, ondemand/live/hd empty. Extended with an audio chunk and an unknown-type chunk - `test/fixtures/single_post_domain.json` - the pinned mapping result: 11 DTO chunks -> 10 domain chunks + unknown content recorded with its exact path (`data[10].type`) - `test/fixtures/rendered_post.html` - the pinned byte-for-byte render of a fixed chunk showcase - The showcase moved into a `_showcase_chunks()` helper (fresh list per call - the renderer mutates video/audio urls in place) and now covers file and audio chunks too `UPDATE_GOLDEN=1 task test` regenerates both goldens for intentional changes - the golden diff is then reviewed like any code. ## The goldens already document three audit findings - image and audio urls get no `signed_query` appended (files do) - a 403 risk on protected content - a file name goes into HTML unescaped (the showcase pins `release <v2> & notes.zip` raw) - external video links render with hardcoded `type="video/mp4"` The upcoming render-fix PR will change these lines - visibly, as golden diffs. ## Verification - `task ci` green: lint, format, pyright, 149 passed + 1 xfailed, build - Leak check on fixtures: author name, boosty hostnames, real post/chunk ids - 0 hits ## Notes - No changelog entry: tests only (`ci/skip-changelog`) - Last PR of the stage after this: local-server e2e + CLI smoke + coverage gate --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#157
No description provided.