fix: URL persistence in export + cache-busting v4.8.0
Some checks failed
Build & Push Docker / build (push) Has been cancelled

- getDocument() now explicitly lists all block fields including url
- loadDocument() initializes url/series_id for backward compat with older JSONs
- Cache-busting query params (?v=4.8) on all static assets
- PDF generator uses block.url directly (proper model field)
- Added 7 new URL tests (model, API, PDF link annotations)
- Version bumped to 4.8.0
This commit is contained in:
Martin Sukany
2026-03-14 19:51:05 +01:00
parent 0a694ce63a
commit 04fe5590b0
7 changed files with 121 additions and 10 deletions

View File

@@ -173,3 +173,60 @@ def test_generate_pdf_no_notes_single_page():
pdf_bytes = generate_pdf(doc)
pages = len(re.findall(rb'/Type\s*/Page[^s]', pdf_bytes))
assert pages == 1, f"Expected 1 page, got {pages}"
def test_generate_pdf_block_with_url_creates_link():
"""Block with url should produce a clickable link annotation in PDF."""
import re
doc = make_doc(
blocks=[
Block(id="b1", date="2026-03-01", start="09:00", end="10:00",
title="Linked Block", type_id="ws",
url="https://example.com/test"),
]
)
pdf_bytes = generate_pdf(doc)
assert pdf_bytes[:5] == b'%PDF-'
# Must contain a /URI annotation with the URL
uris = re.findall(rb'/URI\s*\(([^)]+)\)', pdf_bytes)
assert len(uris) == 1, f"Expected 1 URI annotation, got {len(uris)}"
assert uris[0] == b'https://example.com/test'
# Must have a Link subtype annotation
assert re.search(rb'/Subtype\s*/Link', pdf_bytes), "Missing /Subtype /Link annotation"
def test_generate_pdf_block_without_url_no_link():
"""Blocks without url should NOT produce link annotations."""
import re
doc = make_doc(
blocks=[
Block(id="b1", date="2026-03-01", start="09:00", end="10:00",
title="No Link", type_id="ws"),
]
)
pdf_bytes = generate_pdf(doc)
assert pdf_bytes[:5] == b'%PDF-'
uris = re.findall(rb'/URI\s*\(([^)]+)\)', pdf_bytes)
assert len(uris) == 0, f"Expected 0 URI annotations, got {len(uris)}"
def test_generate_pdf_mixed_url_blocks():
"""Only blocks with url should produce link annotations."""
import re
doc = make_doc(
blocks=[
Block(id="b1", date="2026-03-01", start="09:00", end="10:00",
title="Has Link", type_id="ws",
url="https://example.com/one"),
Block(id="b2", date="2026-03-01", start="10:00", end="11:00",
title="No Link", type_id="ws"),
Block(id="b3", date="2026-03-01", start="11:00", end="12:00",
title="Also Linked", type_id="ws",
url="https://example.com/two"),
]
)
pdf_bytes = generate_pdf(doc)
uris = re.findall(rb'/URI\s*\(([^)]+)\)', pdf_bytes)
assert len(uris) == 2, f"Expected 2 URI annotations, got {len(uris)}"
urls = sorted(u.decode() for u in uris)
assert urls == ['https://example.com/one', 'https://example.com/two']