Mark HTML5 responses as dynamic
This commit is contained in:
@@ -8442,7 +8442,11 @@ def _html5_sse_headers() -> dict[str, str]:
|
|||||||
|
|
||||||
|
|
||||||
def _html5_response(fragment: str) -> Response:
|
def _html5_response(fragment: str) -> Response:
|
||||||
return Response(fragment, media_type="text/html; charset=utf-8")
|
return Response(
|
||||||
|
fragment,
|
||||||
|
media_type="text/html; charset=utf-8",
|
||||||
|
headers={"Cache-Control": "no-cache, no-transform"},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _html5_sse_response(content: Any) -> StreamingResponse:
|
def _html5_sse_response(content: Any) -> StreamingResponse:
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ def assert_html5_contract(text: str, *markers: str, full_page: bool = False) ->
|
|||||||
assert marker in text
|
assert marker in text
|
||||||
|
|
||||||
|
|
||||||
|
def assert_html5_response_contract(response, *markers: str, full_page: bool = False) -> None:
|
||||||
|
assert "text/html" in response.headers["content-type"]
|
||||||
|
assert response.headers["cache-control"] == "no-cache, no-transform"
|
||||||
|
assert_html5_contract(response.text, *markers, full_page=full_page)
|
||||||
|
|
||||||
|
|
||||||
def test_cors_allows_lan_panel_origin():
|
def test_cors_allows_lan_panel_origin():
|
||||||
client = TestClient(app)
|
client = TestClient(app)
|
||||||
response = client.options(
|
response = client.options(
|
||||||
@@ -301,7 +307,7 @@ def test_html5_contracts_are_server_rendered_and_stable(tmp_path: Path):
|
|||||||
for path, markers in full_pages:
|
for path, markers in full_pages:
|
||||||
response = client.get(path)
|
response = client.get(path)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert_html5_contract(response.text, *markers, full_page=True)
|
assert_html5_response_contract(response, *markers, full_page=True)
|
||||||
|
|
||||||
partials = [
|
partials = [
|
||||||
(f"/html5/projects/{project_id}/symbols", {"q": "Проверить"}, ("data-html5-symbol",)),
|
(f"/html5/projects/{project_id}/symbols", {"q": "Проверить"}, ("data-html5-symbol",)),
|
||||||
@@ -316,7 +322,7 @@ def test_html5_contracts_are_server_rendered_and_stable(tmp_path: Path):
|
|||||||
for path, params, markers in partials:
|
for path, params, markers in partials:
|
||||||
response = client.get(path, params=params)
|
response = client.get(path, params=params)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert_html5_contract(response.text, *markers)
|
assert_html5_response_contract(response, *markers)
|
||||||
|
|
||||||
|
|
||||||
def test_html5_project_index_creates_project_with_fragment():
|
def test_html5_project_index_creates_project_with_fragment():
|
||||||
|
|||||||
Reference in New Issue
Block a user