PICK SKY DEL btn: JS-inject after wheel paints so a blank modal carries no DEL action — TDD

Previously the DEL btn was always template-rendered inside .sky-wheel-col, which on a fresh PICK SKY modal (form pristine, schedulePreview not yet fired) put a red DEL btn floating in the empty wheel area suggesting there's something to delete when the user hasn't even seen a wheel yet. Refactored: drop the <button id="id_sky_delete_btn"> from _sky_overlay.html, lazily create it in JS via _ensureDelBtn() called from the schedulePreview success handler (right after SkyWheel.draw/redraw); the existing DEL click handler now also removes the btn from the DOM after clearing the SVG, so the next preview re-injects it. PickSkyRenderingTest.test_no_sky_delete_btn_in_blank_sky_select_modal IT asserts `id="id_sky_delete_btn"` doesn't appear in the rendered HTML for a SKY_SELECT room (the literal identifier still lives inside the inline <script> that does the injection — assertion targets the HTML-attribute-syntax form so the JS reference doesn't trip it). Existing PickSkyDelTest FT still green: it fires preview before clicking DEL, so the btn is present at click time.

Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Disco DeDisco
2026-05-08 14:56:43 -04:00
parent 301b4e8201
commit 8a8d1536b1
2 changed files with 39 additions and 13 deletions

View File

@@ -1792,6 +1792,19 @@ class PickSkyRenderingTest(TestCase):
self.assertContains(response, 'id="id_pick_sky_btn"')
self.assertContains(response, 'style="display:none"')
def test_no_sky_delete_btn_in_blank_sky_select_modal(self):
"""A fresh PICK SKY modal (no preview wheel rendered yet) must not
carry the DEL btn — it would otherwise float in the empty wheel area
suggesting there's something to delete when the user has only seen
the form. The JS schedulePreview success handler is the contract that
injects the btn after the wheel paints — so the rendered HTML should
carry no <button id="id_sky_delete_btn"> markup. (The literal string
does still appear inside the inline <script> that does the injection,
so the assertion targets the rendered attribute syntax, not the bare
identifier.)"""
response = self.client.get(self.url)
self.assertNotContains(response, 'id="id_sky_delete_btn"')
# ── SEA_SELECT rendering ──────────────────────────────────────────────────────