70 lines
3.1 KiB
Python
70 lines
3.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
from govoplan_forms.backend.manifest import manifest
|
|
from govoplan_core.core.semantic_documentation import (
|
|
SEMANTIC_DOCUMENTATION_SUBJECT_CONTRACT_VERSION,
|
|
semantic_documentation_subject_capability,
|
|
)
|
|
|
|
|
|
class FormsInterfaceDocumentationContractTests(unittest.TestCase):
|
|
def test_all_static_topics_have_complete_german_content(self) -> None:
|
|
for topic in manifest.documentation:
|
|
german = (topic.translations or {}).get("de", {})
|
|
self.assertEqual({"title", "summary", "body"}, set(german), topic.id)
|
|
self.assertTrue(
|
|
all(str(value).strip() for value in german.values()), topic.id
|
|
)
|
|
|
|
def test_route_and_surfaces_remain_declared(self) -> None:
|
|
frontend = manifest.frontend
|
|
self.assertIsNotNone(frontend)
|
|
self.assertEqual({"/forms"}, {item.path for item in frontend.routes}) # type: ignore[union-attr]
|
|
self.assertEqual(
|
|
{"forms.navigation", "forms.catalogue"},
|
|
{item.id for item in frontend.view_surfaces}, # type: ignore[union-attr]
|
|
)
|
|
|
|
def test_help_privacy_and_consequence_metadata_remain_published(self) -> None:
|
|
topics = {topic.id: topic for topic in manifest.documentation}
|
|
guide = topics["forms.definitions"]
|
|
reference = topics["forms.reference.fields-and-consequences"]
|
|
self.assertIn("forms.catalogue", guide.metadata["help_contexts"])
|
|
self.assertGreaterEqual(len(guide.metadata["privacy_notes"]), 3)
|
|
self.assertEqual("workflow", guide.metadata["kind"])
|
|
self.assertIn(
|
|
"forms.field.publication-state", reference.metadata["help_contexts"]
|
|
)
|
|
self.assertIn("publish", reference.metadata["consequence_classes"])
|
|
self.assertIn("import_package", reference.metadata["consequence_classes"])
|
|
|
|
def test_semantic_subject_provider_and_static_baseline_are_declared(self) -> None:
|
|
capability = semantic_documentation_subject_capability("forms")
|
|
self.assertIn("docs", manifest.optional_dependencies)
|
|
self.assertNotIn("docs", manifest.dependencies)
|
|
self.assertIn(capability, manifest.capability_factories)
|
|
self.assertEqual(
|
|
SEMANTIC_DOCUMENTATION_SUBJECT_CONTRACT_VERSION,
|
|
manifest.capability_documentation[capability].contract_version,
|
|
)
|
|
topics = {topic.id: topic for topic in manifest.documentation}
|
|
semantic = topics["forms.semantic-documentation"]
|
|
self.assertEqual({"admin", "user"}, set(semantic.documentation_types))
|
|
self.assertIn("cannot override", semantic.body)
|
|
|
|
def test_builder_links_semantic_help_without_closing_unsaved_dialog(self) -> None:
|
|
source = (
|
|
Path(__file__).parents[1]
|
|
/ "webui/src/features/forms/FormDefinitionDialog.tsx"
|
|
).read_text(encoding="utf-8")
|
|
self.assertIn('target="_blank"', source)
|
|
self.assertIn("semanticFieldDocumentation", source)
|
|
self.assertIn("/docs/semantic?", source)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|