fix: HTML attribute quoting in hx-confirm, test assertion precision (A11-T1)
Critical quoting fix: the hx-confirm attribute now uses U+201D (") for the
closing German quote instead of ASCII " (0x22), which was terminating the
attribute early and losing the confirm message text. The template now
correctly contains: hx-confirm="Szenario „{{ sc.name }}" mit allen..."
Test enhancement: restored the complete assertion text from the brief and
added HTML parsing verification to ensure the attribute value matches exactly
with correct typographic quotes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
· Einmalposten: {{ 'ja' if sc.include_planned else 'nein' }}
|
||||
<button type="button" onclick="toggleEdit('sc', {{ sc.id }}, true)">Bearbeiten</button>
|
||||
<button type="button" hx-delete="/api/scenarios/{{ sc.id }}" hx-swap="none"
|
||||
hx-confirm="Szenario „{{ sc.name }}" mit allen Einträgen wirklich löschen?"
|
||||
hx-confirm="Szenario „{{ sc.name }}” mit allen Einträgen wirklich löschen?"
|
||||
hx-on::after-request="if(event.detail.successful){window.location.reload()}">Löschen</button>
|
||||
</p>
|
||||
<div id="sc-edit-{{ sc.id }}" hidden>
|
||||
|
||||
@@ -486,14 +486,41 @@ def test_grafana_links_fallback_to_host_port_when_unset(client, monkeypatch):
|
||||
|
||||
|
||||
def test_szenarien_seite_hat_loeschen_button(client, db):
|
||||
from html.parser import HTMLParser
|
||||
|
||||
client.post("/login", data={"username": "admin", "password": "geheim"})
|
||||
sc = Scenario(name="Wegwerf", description="", include_recurring=True,
|
||||
include_planned=True)
|
||||
db.add(sc)
|
||||
db.commit()
|
||||
r = client.get("/szenarien")
|
||||
|
||||
# Verify delete button is present
|
||||
assert f'hx-delete="/api/scenarios/{sc.id}"' in r.text
|
||||
assert 'Szenario „Wegwerf" mit allen Einträgen wirklich löschen?' in r.text
|
||||
# Verify the full confirmation text in the page (brief requirement)
|
||||
assert 'Szenario „Wegwerf” mit allen Einträgen wirklich löschen?' in r.text
|
||||
|
||||
# Parse HTML to verify the hx-confirm attribute has correct value with proper quotes
|
||||
class ButtonParser(HTMLParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.hx_confirm_value = None
|
||||
self.found_delete_button = False
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == "button":
|
||||
attrs_dict = dict(attrs)
|
||||
if attrs_dict.get("hx-delete") == f"/api/scenarios/{sc.id}":
|
||||
self.found_delete_button = True
|
||||
self.hx_confirm_value = attrs_dict.get("hx-confirm")
|
||||
|
||||
parser = ButtonParser()
|
||||
parser.feed(r.text)
|
||||
assert parser.found_delete_button, "Delete button not found"
|
||||
# Verify the attribute value uses correct typographic quotes
|
||||
expected_confirm = 'Szenario „Wegwerf” mit allen Einträgen wirklich löschen?'
|
||||
assert parser.hx_confirm_value == expected_confirm, \
|
||||
f"hx-confirm attribute mismatch: got {repr(parser.hx_confirm_value)}, expected {repr(expected_confirm)}"
|
||||
|
||||
|
||||
def test_szenario_loeschen_roundtrip_gui(client, db):
|
||||
|
||||
Reference in New Issue
Block a user