test(editor-v2): pin form-POST round-trip for blueprint config
New test_blueprint_config_form_post_round_trip — POSTs a multi-line config, GETs the page, asserts each line re-renders inside the textarea. Pins the round-trip the v2 editor's submit-time copy handler must preserve before any template wiring lands. Skipped a corresponding test_overlay_script_form_post_contract test — the existing test_admin_creates_system_wide_script_overlay at test_script_overlay_routes.py:~270 already asserts overlay.script == "echo admin" after a POST /overlays/<id>/script, which is the same form-contract pin. YAGNI; no need to duplicate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b1a6290c8c
commit
9ca0e789f4
1 changed files with 42 additions and 0 deletions
|
|
@ -411,3 +411,45 @@ def test_blueprint_detail_picker_emits_hidden_overlay_ids_in_order(user_client)
|
||||||
second = body.find('name="overlay_ids" value="1"')
|
second = body.find('name="overlay_ids" value="1"')
|
||||||
assert first != -1 and second != -1
|
assert first != -1 and second != -1
|
||||||
assert first < second
|
assert first < second
|
||||||
|
|
||||||
|
|
||||||
|
def test_blueprint_config_form_post_round_trip(user_client) -> None:
|
||||||
|
"""Pin the form-POST contract for the `config` textarea: a multi-line
|
||||||
|
value sent in the POST body re-renders inside the textarea on the
|
||||||
|
subsequent GET. The CodeMirror 6 editor wires a submit-time copy
|
||||||
|
handler that writes `controller.getValue()` into `textarea.value`
|
||||||
|
before the browser serializes the form; if that handler regresses,
|
||||||
|
this test breaks before the e2e suite even runs."""
|
||||||
|
create = user_client.post(
|
||||||
|
"/blueprints",
|
||||||
|
data={
|
||||||
|
"name": "form-contract",
|
||||||
|
"arguments": "",
|
||||||
|
"config": "",
|
||||||
|
"overlay_ids": [],
|
||||||
|
},
|
||||||
|
headers={"X-CSRF-Token": "test-token"},
|
||||||
|
)
|
||||||
|
assert create.status_code == 302
|
||||||
|
blueprint_path = create.headers["Location"]
|
||||||
|
|
||||||
|
pinned_config = "// pinned by form-contract test\nsv_cheats 0\nexec server.cfg\n"
|
||||||
|
update = user_client.post(
|
||||||
|
blueprint_path,
|
||||||
|
data={
|
||||||
|
"name": "form-contract",
|
||||||
|
"arguments": "",
|
||||||
|
"config": pinned_config,
|
||||||
|
"overlay_ids": [],
|
||||||
|
},
|
||||||
|
headers={"X-CSRF-Token": "test-token"},
|
||||||
|
)
|
||||||
|
assert update.status_code == 302
|
||||||
|
|
||||||
|
page = user_client.get(blueprint_path)
|
||||||
|
assert page.status_code == 200
|
||||||
|
body = page.get_data(as_text=True)
|
||||||
|
# The route may normalize trailing whitespace; assert each non-empty
|
||||||
|
# line round-tripped into the rendered textarea.
|
||||||
|
for line in ("// pinned by form-contract test", "sv_cheats 0", "exec server.cfg"):
|
||||||
|
assert line in body, f"line not found in rendered page: {line!r}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue