Add HTML5 object context fragment
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 00:00:49 +03:00
parent 41dc88c33b
commit f20c045de9
3 changed files with 132 additions and 3 deletions
+35
View File
@@ -227,6 +227,41 @@ def test_html5_project_index_creates_project_with_fragment():
assert deleted_setup.json()["status"] == "NOT_CONFIGURED"
def test_html5_object_context_fragment(tmp_path: Path):
project_id = f"html5-object-context-{uuid4()}"
(tmp_path / "metadata.xml").write_text(
"""
<Configuration>
<Document name="ЗаказПокупателя" qualifiedName="Документ.ЗаказПокупателя">
<Attribute name="Контрагент" qualifiedName="Документ.ЗаказПокупателя.Контрагент" />
<TabularSection name="Товары" qualifiedName="Документ.ЗаказПокупателя.Товары">
<Attribute name="Количество" qualifiedName="Документ.ЗаказПокупателя.Товары.Количество" />
</TabularSection>
</Document>
</Configuration>
""",
encoding="utf-8",
)
client = TestClient(app)
indexed = client.post("/projects/index", json={"path": str(tmp_path), "project_id": project_id})
assert indexed.status_code == 200
editor = client.get(f"/html5/projects/{project_id}/editor")
assert editor.status_code == 200
assert "data-html5-object-context" in editor.text
assert f'hx-get="/html5/projects/{project_id}/objects/context/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82.%D0%97%D0%B0%D0%BA%D0%B0%D0%B7%D0%9F%D0%BE%D0%BA%D1%83%D0%BF%D0%B0%D1%82%D0%B5%D0%BB%D1%8F"' in editor.text
assert 'hx-target="[data-html5-object-context]"' in editor.text
context = client.get(f"/html5/projects/{project_id}/objects/context/Документ.ЗаказПокупателя")
assert context.status_code == 200
assert "text/html" in context.headers["content-type"]
assert "data-html5-object-context" in context.text
assert "Документ.ЗаказПокупателя" in context.text
assert "Контрагент" in context.text
assert "Товары" in context.text
assert "<html" not in context.text
def test_html5_project_setup_renders_server_fragments():
client = TestClient(app)
project_id = f"html5-setup-{uuid4()}"