fix(maker): l'editor task si riallinea al copy-on-write invece di 409 (#4)
Dopo il copy-on-write del backend (modifica su versione con misure -> nuovi id per task e quote), task_editor.html teneva in memoria gli id vecchi: il salvataggio successivo riceveva 409 "Cannot modify a non-current version". Ogni handler di salvataggio (create/update/delete di task e quote, reorder, upload immagine) ora ricarica la pagina su 409, mostrando un avviso dopo il reload. updateTask/updateSubtask/ addSubtask ricaricano anche su successo se l'id restituito (recipe_id task, task_id quota) non corrisponde a quello locale - il copy-on-write avvenuto silenziosamente. Stringa aggiunta ai due cataloghi .po. Test: proxy Flask che verifica il passaggio del 409 (test_maker.py), sintassi JS dello script inline di task_editor.html con node --check (test_template_js_syntax.py). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -395,3 +395,45 @@ def test_task_list_inline_js_is_valid(logged_in_client, mock_measure_api):
|
||||
_node_check(body, f"/measure/tasks script[{i}]")
|
||||
|
||||
_check_alpine_attributes(html, "/measure/tasks")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_maker_api():
|
||||
"""Patch api_client used inside the maker blueprint."""
|
||||
mock = MagicMock()
|
||||
with patch("blueprints.maker.api_client", mock):
|
||||
yield mock
|
||||
|
||||
|
||||
def test_task_editor_inline_js_is_valid(logged_in_client, mock_maker_api):
|
||||
"""gitea#4: the version-conflict reload added _reloadForNewVersion() and
|
||||
new `if (…status === 409)` / `data.task_id !== taskId` checks in every
|
||||
save handler. Regression guard that the inline script still parses."""
|
||||
_force_italian(logged_in_client)
|
||||
mock_maker_api.get.side_effect = api_get_router({
|
||||
"/api/recipes/3/tasks": [{
|
||||
"id": 11, "order_index": 0, "title": "Quota d'ingresso",
|
||||
"task_type": "measure", "file_path": None, "file_type": None,
|
||||
"annotations_json": None,
|
||||
"subtasks": [{
|
||||
"id": 21, "marker_number": 1, "description": "Diametro",
|
||||
"nominal": 10.0, "utl": 10.5, "uwl": 10.2, "lwl": 9.8, "ltl": 9.5,
|
||||
"unit": "mm",
|
||||
}],
|
||||
}],
|
||||
"/api/recipes/3": {
|
||||
"id": 3, "code": "REC-3", "name": "Ricetta con l'apostrofo",
|
||||
"description": "Con l'apostrofo anche qui",
|
||||
},
|
||||
})
|
||||
|
||||
resp = logged_in_client.get("/maker/recipes/3/tasks")
|
||||
assert resp.status_code == 200
|
||||
html = resp.get_data(as_text=True)
|
||||
|
||||
scripts = _INLINE_SCRIPT_RX.findall(html)
|
||||
assert scripts, "expected at least one inline <script> on /maker/recipes/3/tasks"
|
||||
for i, body in enumerate(scripts):
|
||||
_node_check(body, f"/maker/recipes/3/tasks script[{i}]")
|
||||
|
||||
_check_alpine_attributes(html, "/maker/recipes/3/tasks")
|
||||
|
||||
Reference in New Issue
Block a user