From c6d83b272cc45c03954816776f8b83d067ffe37b Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Tue, 16 Jun 2026 11:00:50 -0400 Subject: [PATCH] test: add buildChapterDownloadLink regression cases for blank audio host Mirrors the buildDownloadLink coverage for the chapter link builder, which shares the same PUBLIC_HOST_URL fallback. Verified red against the unfixed chapter path. Addresses CodeRabbit review feedback on PR #1. Co-Authored-By: Claude Opus 4.8 (1M context) --- ui/src/app/app.spec.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ui/src/app/app.spec.ts b/ui/src/app/app.spec.ts index a4cff0f..7ca128f 100644 --- a/ui/src/app/app.spec.ts +++ b/ui/src/app/app.spec.ts @@ -305,6 +305,30 @@ describe('App', () => { expect(app.buildDownloadLink(makeDownload())).toBe('song.mp3'); }); + it('builds chapter audio link from PUBLIC_HOST_AUDIO_URL when set', () => { + downloads.configuration['PUBLIC_HOST_URL'] = 'download/'; + downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = 'audio_download/'; + const app = TestBed.createComponent(App).componentInstance; + const link = app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3'); + expect(link).toBe('audio_download/chapter1.mp3'); + }); + + it('chapter audio link falls back to PUBLIC_HOST_URL when audio host is blank (regression)', () => { + downloads.configuration['PUBLIC_HOST_URL'] = 'download/'; + downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = ''; + const app = TestBed.createComponent(App).componentInstance; + const link = app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3'); + expect(link).not.toBe('chapter1.mp3'); + expect(link).toBe('download/chapter1.mp3'); + }); + + it('chapter audio link stays root-relative when both hosts are blank', () => { + downloads.configuration['PUBLIC_HOST_URL'] = ''; + downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = ''; + const app = TestBed.createComponent(App).componentInstance; + expect(app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3')).toBe('chapter1.mp3'); + }); + it('blocks subscribe with invalid title regex', () => { const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => undefined); const fixture = TestBed.createComponent(App);