Integrate Antirion admin with FastAPI and htmx
Add the shared document API, constructor and expert editors, isolated preview, and fragment catalog metadata with typed block IDs. Include design references, specification 001, QA scripts, project guidance, and cached Docker dependency installation. Leave example sites for a separate commit.
This commit is contained in:
@@ -92,15 +92,18 @@ class AccessTest(EditorTestCase):
|
||||
self.assertEqual(result.status, 200, path)
|
||||
self.assertIn("frame-ancestors 'none'", result.headers["Content-Security-Policy"], path)
|
||||
self.assertEqual(result.headers["Cache-Control"], "no-store")
|
||||
for bad in ("<script", "style=", "<style", "onclick="):
|
||||
self.assertNotRegex(result.body, r"<script(?![^>]*\bsrc=)")
|
||||
for bad in ("style=", "<style", "onclick="):
|
||||
self.assertNotIn(bad, result.body, f"{path}: {bad}")
|
||||
|
||||
def test_htmx_is_enabled_only_when_the_file_is_present(self):
|
||||
self.assertNotIn("hx-boost", self.get("/pages").body)
|
||||
with mock.patch("site_engine.web.admin.editor.htmx_available", return_value=True):
|
||||
body = self.get("/pages").body
|
||||
body = self.get("/pages").body
|
||||
self.assertIn("hx-boost='true'", body)
|
||||
self.assertIn("src='/admin/static/htmx.min.js'", body)
|
||||
with mock.patch("site_engine.web.admin.editor.htmx_available", return_value=False):
|
||||
fallback = self.get("/pages").body
|
||||
self.assertNotIn("<body data-skin='light' hx-boost='true'", fallback)
|
||||
self.assertNotIn("src='/admin/static/htmx.min.js'", fallback)
|
||||
|
||||
def test_titles_are_escaped(self):
|
||||
self.edit("pages/privacy.md", "title: Политика обработки персональных данных", "title: '<script>alert(1)</script>'")
|
||||
@@ -277,7 +280,7 @@ class BlockTest(EditorTestCase):
|
||||
"region": "main", "fragment": "disclaimer"})
|
||||
self.assertEqual(result.status, 303)
|
||||
location = result.headers["Location"]
|
||||
self.assertRegex(location, r"^/admin/pages/privacy/blocks/b_[a-z0-9]{5}\?msg=added$")
|
||||
self.assertRegex(location, r"^/admin/pages/privacy/blocks/disclaimer_[a-z0-9]{5}\?msg=added$")
|
||||
block_id = location.split("/blocks/")[1].split("?")[0]
|
||||
path = f"/pages/privacy/blocks/{block_id}"
|
||||
self.submit_form(path, f"/admin{path}", p__text="Важная **оговорка**")
|
||||
|
||||
Reference in New Issue
Block a user