Add HTML5 contracts and operations renderer split
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 11:00:50 +03:00
parent 22f59b7580
commit 0f8141d5f9
4 changed files with 274 additions and 181 deletions
+61
View File
@@ -28,6 +28,20 @@ def create_authoring_session(client: TestClient, project_id: str, task_id: str,
assert session.status_code == 200
def assert_html5_contract(text: str, *markers: str, full_page: bool = False) -> None:
assert "__next" not in text
assert "unpkg.com" not in text
assert 'hx-trigger="every' not in text
if full_page:
assert "<!doctype html>" in text
assert "/html5/assets/htmx.min.js" in text
assert "/html5/assets/htmx-ext-sse.js" in text
else:
assert "<html" not in text
for marker in markers:
assert marker in text
def test_cors_allows_lan_panel_origin():
client = TestClient(app)
response = client.options(
@@ -245,6 +259,51 @@ def test_html5_server_rendered_project_editor(tmp_path: Path):
assert "sse" in sse_asset.text
def test_html5_contracts_are_server_rendered_and_stable(tmp_path: Path):
client = TestClient(app)
project_id = f"html5-contract-{uuid4()}"
module = tmp_path / "contract_module.bsl"
module.write_text(
"Процедура ПроверитьКонтракт()\n"
" Сообщить(\"contract\");\n"
"КонецПроцедуры\n",
encoding="utf-8",
)
indexed = client.post("/projects/index", json={"path": str(tmp_path), "project_id": project_id})
assert indexed.status_code == 200
settings = client.post(
f"/projects/{project_id}/settings",
json={"name": "HTML5 Contract", "structure_source": "XML_DUMP"},
)
assert settings.status_code == 200
full_pages = [
("/html5", ("data-html5-page=\"projects\"", "data-html5-projects")),
(f"/html5/projects/{project_id}/editor", ("data-html5-page=\"editor\"", "data-html5-editor")),
(f"/html5/projects/{project_id}/setup", ("data-html5-page=\"setup\"", "data-html5-setup-summary")),
("/html5/operations", ("data-html5-page=\"operations\"", "data-html5-operations-filter")),
]
for path, markers in full_pages:
response = client.get(path)
assert response.status_code == 200
assert_html5_contract(response.text, *markers, full_page=True)
partials = [
(f"/html5/projects/{project_id}/symbols", {"q": "Проверить"}, ("data-html5-symbol",)),
(f"/html5/projects/{project_id}/report", {}, ("data-html5-project-report", "data-html5-project-summary")),
(f"/html5/projects/{project_id}/review", {}, ("data-html5-review", "data-html5-review-summary")),
(f"/html5/projects/{project_id}/flowchart", {}, ("data-html5-flowchart",)),
(f"/html5/projects/{project_id}/authoring/changes", {}, ("data-html5-authoring-changes", "data-html5-authoring-summary")),
(f"/html5/projects/{project_id}/setup/summary", {}, ("data-html5-setup-summary",)),
("/html5/operations/jobs", {}, ("data-html5-operation",)),
("/html5/operations/summary", {}, ("data-html5-operations-summary",)),
]
for path, params, markers in partials:
response = client.get(path, params=params)
assert response.status_code == 200
assert_html5_contract(response.text, *markers)
def test_html5_project_index_creates_project_with_fragment():
client = TestClient(app)
project_id = f"html5-created-{uuid4()}"
@@ -2778,11 +2837,13 @@ def test_authoring_context_and_completion_preview(tmp_path: Path):
assert "text/html" in html5_changes.headers["content-type"]
assert "data-html5-authoring-changes" in html5_changes.text
assert "data-html5-authoring-summary" in html5_changes.text
assert "data-html5-authoring-recent-change" in html5_changes.text
assert "workspace" in html5_changes.text
assert "+3 / -0" in html5_changes.text
assert "data-html5-authoring-detail" in html5_changes.text
assert 'hx-target="[data-html5-authoring-detail]"' in html5_changes.text
assert apply_payload["change_id"] in html5_changes.text
assert apply_payload["version"]["version_id"] in html5_changes.text
assert "<html" not in html5_changes.text
rollback = client.get(