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:
@@ -121,3 +121,43 @@ class TestRecipeEdit:
|
||||
resp = logged_in_client.get("/maker/recipes/999/edit", follow_redirects=False)
|
||||
assert resp.status_code == 302
|
||||
assert "/maker/recipes" in resp.headers["Location"]
|
||||
|
||||
|
||||
class TestVersionConflictProxy:
|
||||
"""gitea#4: a 409 from the backend (edit targeting a non-current version,
|
||||
left behind by an earlier copy-on-write) must reach the browser as a 409 -
|
||||
task_editor.html's _reloadForNewVersion() only triggers on that status.
|
||||
"""
|
||||
|
||||
_CONFLICT = {
|
||||
"error": True,
|
||||
"status_code": 409,
|
||||
"detail": "Cannot modify a non-current version. Create a new version first.",
|
||||
}
|
||||
|
||||
def test_update_task_proxies_409(self, logged_in_client, mock_api_client):
|
||||
mock_api_client.put.return_value = self._CONFLICT
|
||||
|
||||
resp = logged_in_client.put("/maker/api/tasks/11", json={"title": "x"})
|
||||
|
||||
assert resp.status_code == 409
|
||||
assert resp.get_json()["detail"] == self._CONFLICT["detail"]
|
||||
|
||||
def test_update_subtask_proxies_409(self, logged_in_client, mock_api_client):
|
||||
mock_api_client.put.return_value = self._CONFLICT
|
||||
|
||||
resp = logged_in_client.put("/maker/api/subtasks/21", json={"nominal": 1.0})
|
||||
|
||||
assert resp.status_code == 409
|
||||
assert resp.get_json()["detail"] == self._CONFLICT["detail"]
|
||||
|
||||
def test_create_subtask_proxies_409(self, logged_in_client, mock_api_client):
|
||||
mock_api_client.post.return_value = self._CONFLICT
|
||||
|
||||
resp = logged_in_client.post(
|
||||
"/maker/api/tasks/11/subtasks",
|
||||
json={"marker_number": 1, "description": "x"},
|
||||
)
|
||||
|
||||
assert resp.status_code == 409
|
||||
assert resp.get_json()["detail"] == self._CONFLICT["detail"]
|
||||
|
||||
Reference in New Issue
Block a user