2026-05-13-report-logo-header.md 3.3 KB

Report Logo Header Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Render the uploaded report-logo.png in the shared page header for both exam sprint PDF/HTML reports.

Architecture: Keep the PNG under classpath resources and have each renderer embed it as a Base64 data URI. Templates receive a {{reportLogoDataUri}} placeholder so Playwright PDF generation does not depend on relative file URL resolution.

Tech Stack: Java 17, Spring ClassPathResource, static HTML templates, JUnit 5, AssertJ.


Files

  • Existing asset: abilities/exam-sprint/infrastructure/src/main/resources/report-assets/report-logo.png
  • Modify: abilities/exam-sprint/infrastructure/src/main/resources/templates/outlook-exam-sprint-report-template.html
  • Modify: abilities/exam-sprint/infrastructure/src/main/resources/templates/achievement-exam-sprint-report-template.html
  • Modify: abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/rendering/outlook/ClasspathOutlookExamSprintReportRenderer.java
  • Modify: abilities/exam-sprint/infrastructure/src/main/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/rendering/achievement/ClasspathAchievementExamSprintReportRenderer.java
  • Test: abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/rendering/outlook/ClasspathOutlookExamSprintReportRendererTest.java
  • Test: abilities/exam-sprint/infrastructure/src/test/java/cn/yunzhixue/ability/center/examsprint/infrastructure/report/rendering/achievement/ClasspathAchievementExamSprintReportRendererTest.java

Task 1: Write failing tests

  • Add assertions to both renderShowsStudentNameInReportHeader tests that rendered HTML contains <img class="header-logo-image" src="data:image/png;base64, and does not contain {{reportLogoDataUri}}.
  • Run mvn -pl abilities/exam-sprint/infrastructure -Dtest=ClasspathOutlookExamSprintReportRendererTest,ClasspathAchievementExamSprintReportRendererTest test and verify RED because templates/renderers do not inject the logo yet.

Task 2: Implement logo embedding

  • Update both templates: replace empty .header-logo content with <img class="header-logo-image" src="{{reportLogoDataUri}}" alt="IATSE"/>.
  • Add .header-logo-image CSS with display: block; max-width: 120px; max-height: 42px; to both templates.
  • In both renderers, load report-assets/report-logo.png via ClassPathResource, convert bytes using Base64.getEncoder().encodeToString(...), prefix data:image/png;base64,, and replace/fill reportLogoDataUri.
  • Run the focused renderer tests and verify GREEN.

Task 3: Verify module

  • Run mvn -pl abilities/exam-sprint/infrastructure test.
  • Inspect relevant diff and confirm only report header/logo changes, tests, the uploaded asset, and plan docs are included.

Self-review

  • Spec coverage: both reports render the uploaded PNG logo in the left header slot.
  • Placeholder scan: no unresolved implementation placeholders in this plan.
  • Type consistency: all resource names and placeholder names match the existing renderer/template style.