sky.html: DEL btn at wheel center; async SAVE SKY transitions into saved state without reload; pre-save hides wheel-col so form+SAVE SKY stay centered — TDD

DEL btn (.btn-danger, "Forget sky?" data-confirm wired to the global #id_guard_portal) sits absolutely centered inside .sky-wheel-col; OK submits a POST to the new sky_delete view, which clears every sky_* field on the User model & redirects back to /dashboard/sky/.

The sky.html aperture is now uniform across saved/unsaved: form-col is always flex-column align-center justify-center so the fields + SAVE SKY pair sits visually centered. body.sky-saved adds *only* the snap-binary scroll layer (scroll-snap-type:y, modal-body display:contents, cols min-height:100% scroll-snap-align:start, wheel-col aspect-ratio cap released, form-col flex:0 0 auto so the snap basis wins) — the column-stacking is no longer gated.

Async save: SAVE SKY's success branch now calls _activateSavedState(), which adds body.sky-saved, draws the wheel from _lastChartData, pins overlay.scrollTop to the form section's offsetTop, then runs the existing _scrollApertureToTop ease-out so the wheel reveals from above instead of replacing the form with a hard cut. The wheel preview that previously redrew during typing is now gated on _savedSky — pre-first-save typing fetches the chart data (so SAVE SKY enables) but does not render the wheel, mirroring the My Sky applet's "no wheel until saved" UX. The in-room PICK SKY overlay (_sky_overlay.html) still previews live, deliberately untouched.

Pre-save the wheel-col is hidden via `body:not(.sky-saved) .sky-page .sky-wheel-col { display: none }`, so the empty SVG can't shunt the form below the fold (& the DEL btn rides the same selector since it lives inside .sky-wheel-col).

Tests: SkyDeleteTest IT class (5: clears fields, redirects, 405 on GET, login required, preserves unrelated user fields). MySkyDeleteFlowTest FT class (3: DEL btn visibility gated on sky data, NVM dismisses w. data intact, OK clears + reverts body class). MySkyAsyncSaveTest FT (1: fresh user → SAVE SKY → body picks up sky-saved, wheel SVG populates, DEL btn becomes visible — all without a page reload). All 13 sky FTs + sky ITs green; existing MySkyApertureSnapScrollTest & MySkyTimezoneRefreshTest still pass.

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 13:07:56 -04:00
parent bbd1b22bb0
commit 9ff437012a
6 changed files with 346 additions and 34 deletions

View File

@@ -288,3 +288,59 @@ class SkySaveNoteTest(TestCase):
data = self._post(chart_data=None).json()
self.assertIsNone(data["note"])
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 0)
class SkyDeleteTest(TestCase):
"""POST /dashboard/sky/delete clears all sky fields on the User model and
redirects back to /dashboard/sky/. The Stargazer Note is preserved (it's
earned, not stateful)."""
def setUp(self):
from datetime import datetime
import zoneinfo
self.user = User.objects.create(email="star@test.io")
self.user.sky_chart_data = {"planets": {"Sun": {"sign": "Gemini"}}}
self.user.sky_birth_place = "Baltimore, MD, US"
self.user.sky_birth_tz = "America/New_York"
self.user.sky_birth_lat = 39.2904
self.user.sky_birth_lon = -76.6122
self.user.sky_birth_dt = datetime(
1990, 6, 15, 12, 0, tzinfo=zoneinfo.ZoneInfo("UTC")
)
self.user.sky_house_system = "O"
self.user.save()
self.client.force_login(self.user)
self.url = reverse("sky_delete")
def test_post_clears_all_sky_fields(self):
self.client.post(self.url)
self.user.refresh_from_db()
self.assertIsNone(self.user.sky_chart_data)
self.assertIsNone(self.user.sky_birth_dt)
self.assertIsNone(self.user.sky_birth_lat)
self.assertIsNone(self.user.sky_birth_lon)
self.assertEqual(self.user.sky_birth_place, "")
self.assertEqual(self.user.sky_birth_tz, "")
def test_post_redirects_to_sky_view(self):
response = self.client.post(self.url)
self.assertEqual(response.status_code, 302)
self.assertEqual(response["Location"], reverse("sky"))
def test_get_returns_405(self):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 405)
def test_requires_login(self):
self.client.logout()
response = self.client.post(self.url)
self.assertEqual(response.status_code, 302)
self.assertIn("/?next=", response["Location"])
def test_post_preserves_unrelated_user_fields(self):
self.user.username = "stargazer-keepme"
self.user.save()
self.client.post(self.url)
self.user.refresh_from_db()
self.assertEqual(self.user.username, "stargazer-keepme")