from __future__ import annotations import asyncio from repub.web import create_app def test_root_get_serves_datastar_shim() -> None: async def run() -> None: client = create_app().test_client() response = await client.get("/") body = await response.get_data(as_text=True) assert response.status_code == 200 assert response.headers["ETag"] assert body.startswith("") assert ( '' in body ) assert 'data-signals:tabid="self.crypto.randomUUID().substring(0,8)"' in body assert 'data-init="@post(window.location.pathname +' in body assert "retryMaxCount: Infinity" in body assert "data-on:online__window=" in body assert '
' in body asyncio.run(run()) def test_root_get_honors_if_none_match() -> None: async def run() -> None: client = create_app().test_client() initial = await client.get("/") etag = initial.headers["ETag"] response = await client.get("/", headers={"If-None-Match": etag}) assert response.status_code == 304 assert response.headers["ETag"] == etag asyncio.run(run()) def test_root_post_serves_morph_component() -> None: async def run() -> None: client = create_app().test_client() response = await client.post("/?u=shim") body = await response.get_data(as_text=True) assert response.status_code == 200 assert response.content_type == "text/html; charset=utf-8" assert body.startswith('