Add HTML5 authoring apply summaries
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 02:22:10 +03:00
parent dde672202c
commit 8f2a17b24a
2 changed files with 45 additions and 1 deletions
@@ -837,6 +837,7 @@ def render_html5_authoring_apply_result(project_id: str, result: object | None =
<span>{escape(change_id)}</span>
<small>{escape(version_id)}</small>
</article>
{_authoring_apply_summary("change-set", status, change_id, version_id)}
<p class="muted padded">Change-set применен в workspace для проекта {escape(project_id)}.</p>
</div>
"""
@@ -944,6 +945,7 @@ def render_html5_metadata_apply_result(project_id: str, result: object | None =
<span>{escape(change_id)}</span>
<small>{escape(version_id)}</small>
</article>
{_authoring_apply_summary("metadata", status, change_id, version_id)}
<p class="muted padded">Metadata draft применен в workspace для проекта {escape(project_id)}.</p>
</div>
"""
@@ -1754,6 +1756,18 @@ def _authoring_detail_summary(diff: Iterable[object], checks: Iterable[object],
"""
def _authoring_apply_summary(kind: str, status: str, change_id: str, version_id: str) -> str:
return f"""
<p
class="authoring-summary"
data-html5-authoring-apply-summary
data-html5-authoring-apply-kind="{escape(kind)}"
>
{escape(kind)} · {escape(status or "UNKNOWN")} · {escape(change_id or "change unavailable")} · {escape(version_id or "version unavailable")}
</p>
"""
def _named_node_item(label: str, node: object) -> str:
name = getattr(node, "qualified_name", None) or getattr(node, "name", "")
kind = getattr(node, "kind", label)
+31 -1
View File
@@ -1,6 +1,7 @@
from pathlib import Path
from uuid import uuid4
import re
import time
from uuid import uuid4
import zipfile
from fastapi.testclient import TestClient
@@ -3045,6 +3046,35 @@ def test_authoring_metadata_object_preview_and_apply(tmp_path: Path):
assert "Expected version id does not match current metadata preview" in html5_blocked_apply.text
assert "<html" not in html5_blocked_apply.text
html5_expected_version = re.search(r'name="expected_next_version_id" value="([^"]+)"', html5_preview.text)
assert html5_expected_version is not None
html5_apply = client.post(
f"/html5/projects/{project_id}/authoring/apply-metadata-object",
data={
"object_kind": "DOCUMENT",
"name": "ЗаявкаНаЗакупкуHtml5",
"synonym": "Заявка на закупку HTML5",
"attributes": "Контрагент:СправочникСсылка.Контрагенты",
"tabular_sections": "Товары[Номенклатура:СправочникСсылка.Номенклатура;Количество:Число]",
"forms": "ФормаДокумента",
"commands": "Заполнить:ЗаполнитьКоманда",
"task_id": "task.metadata",
"session_id": "session.metadata",
"user_id": "dev.ivan",
"expected_next_version_id": html5_expected_version.group(1),
"approved_by": "dev.ivan",
"approval_note": "html5 metadata draft checked",
},
)
assert html5_apply.status_code == 200
assert "text/html" in html5_apply.headers["content-type"]
assert "data-html5-metadata-apply-result" in html5_apply.text
assert "data-html5-authoring-apply-summary" in html5_apply.text
assert 'data-html5-authoring-apply-kind="metadata"' in html5_apply.text
assert "METADATA_DRAFT_APPLIED_TO_WORKSPACE" in html5_apply.text
assert "ЗаявкаНаЗакупкуHtml5" in html5_apply.text
assert "<html" not in html5_apply.text
apply_response = client.post(
f"/projects/{project_id}/authoring/apply-metadata-object",
json={