diff --git a/tests/test_speaker_edit_submit.py b/tests/test_speaker_edit_submit.py index 70dfb7e..0e6e977 100644 --- a/tests/test_speaker_edit_submit.py +++ b/tests/test_speaker_edit_submit.py @@ -77,19 +77,40 @@ def test_every_onsubmit_return_handler_returns_a_boolean() -> None: def test_voice_regen_on_save_is_not_empty() -> None: - """The specific function that was gutted.""" + """The specific handler that was gutted in the voice-queue commit.""" bodies = _function_bodies((TEMPLATES / "speakers.html").read_text()) - assert "queueVoiceRegenOnSave" in bodies, "handler is missing entirely" - body = bodies["queueVoiceRegenOnSave"].strip() - assert body, "queueVoiceRegenOnSave has an empty body" + assert "onSpeakerSaved" in bodies, "handler is missing entirely" + body = bodies["onSpeakerSaved"].strip() + assert body, "onSpeakerSaved has an empty body" assert "enqueueVoice" in body, "it must actually queue a regeneration" + assert "notify" in body, "a save must tell the reviewer it happened" -def test_edit_form_queues_regen_after_a_successful_save() -> None: - """Re-voice must run after the new profile is persisted, not before.""" +def test_edit_form_carries_the_regen_marker() -> None: row = _strip_comments((TEMPLATES / "_speaker_row.html").read_text()) - assert "queueVoiceRegenOnSave" in row - assert "hx-on::after-request" in row, ( - "regeneration should be hooked to after-request so the saved profile " - "is on disk before the voice is rebuilt from it" + assert "data-regen-on-save" in row, ( + "the form must be identifiable so a save can trigger a re-voice" ) + assert "hx-on::after-request" not in row, ( + "htmx dispatches afterRequest on the enclosing TBODY for a row swap, " + "so a listener bound to the form never fires - verified in a real browser" + ) + + +def test_regen_trigger_uses_the_event_that_carries_the_form() -> None: + """detail.elt is the FORM at beforeRequest but the TBODY at afterRequest.""" + js = _strip_comments((TEMPLATES / "speakers.html").read_text()) + assert "htmx:beforeRequest" in js, ( + "the index must be captured at beforeRequest, where detail.elt is still " + "the form; reading it at afterRequest yields a TBODY and finds nothing" + ) + assert "htmx:afterRequest" in js + assert "onSpeakerSaved" in js + + +def test_saving_tells_the_reviewer() -> None: + """A save with no visible response reads as a broken button.""" + bodies = _function_bodies(_strip_comments((TEMPLATES / "speakers.html").read_text())) + body = bodies["onSpeakerSaved"] + assert "enqueueVoice" in body, "it must actually queue a regeneration" + assert "notify" in body, "it must confirm to the reviewer" diff --git a/umbraaudio/web/templates/_speaker_row.html b/umbraaudio/web/templates/_speaker_row.html index 8001ed3..e4168b6 100644 --- a/umbraaudio/web/templates/_speaker_row.html +++ b/umbraaudio/web/templates/_speaker_row.html @@ -171,13 +171,23 @@