Archived
Refactor UI assets and harden quality checks
This commit is contained in:
1 parent
23ab466c52
commit
4ecc8eb874
62 files changed
+3314
-3206
No files matched your search
@@ -0,0 +1,46 @@
|
||||
from karldns.web.html_utils import trusted
|
||||
from karldns.web.layout import PageOptions, _page, _social_meta_tags, _structured_data_tag
|
||||
|
||||
|
||||
def test_page_options_render_metadata_and_preloads() -> None:
|
||||
html = _page(
|
||||
"KarlDNS",
|
||||
trusted("<main id='main'></main>"),
|
||||
PageOptions(
|
||||
description="Dynamic DNS",
|
||||
preload_logo=True,
|
||||
canonical_url="https://karldns.example/",
|
||||
image_url="https://karldns.example/social.png",
|
||||
image_alt="Preview",
|
||||
structured_data={"name": "KarlDNS"},
|
||||
),
|
||||
)
|
||||
|
||||
assert 'content="Dynamic DNS"' in html
|
||||
assert 'rel="canonical" href="https://karldns.example/"' in html
|
||||
assert 'rel="preload" as="image" href="/logo.webp?v=3"' in html
|
||||
assert 'property="og:image" content="https://karldns.example/social.png"' in html
|
||||
assert 'type="application/ld+json"' in html
|
||||
|
||||
|
||||
def test_social_meta_tags_include_large_card_when_image_exists() -> None:
|
||||
html = _social_meta_tags(
|
||||
title="KarlDNS",
|
||||
description="Dynamic DNS",
|
||||
canonical_url="https://karldns.de/",
|
||||
image_url="https://karldns.de/social-preview.png",
|
||||
image_alt="Preview",
|
||||
)
|
||||
|
||||
assert 'property="og:title" content="KarlDNS"' in html
|
||||
assert 'property="og:image" content="https://karldns.de/social-preview.png"' in html
|
||||
assert 'name="twitter:card" content="summary_large_image"' in html
|
||||
assert 'name="twitter:image:alt" content="Preview"' in html
|
||||
|
||||
|
||||
def test_structured_data_tag_escapes_json_for_html() -> None:
|
||||
html = _structured_data_tag({"name": "KarlDNS", "description": "<dynamic>"})
|
||||
|
||||
assert 'type="application/ld+json"' in html
|
||||
assert "<dynamic>" in html
|
||||
assert "<dynamic>" not in html
|
||||
Reference in new issue
Block a user