2026-04-16 03:03:19 -04:00
|
|
|
"""Integration tests for the My Sky dashboard views.
|
|
|
|
|
|
|
|
|
|
sky_view — GET /dashboard/sky/ → renders sky template
|
2026-04-21 20:07:40 -04:00
|
|
|
sky_preview — GET /dashboard/sky/preview → proxies to PySwiss (no DB write)
|
2026-04-22 02:13:29 -04:00
|
|
|
sky_save — POST /dashboard/sky/save → saves natal data to User model;
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
grants Stargazer Note on first save with real chart_data
|
2026-04-16 03:03:19 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
from unittest.mock import patch, MagicMock
|
|
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
from apps.drama.models import Note
|
2026-04-16 03:03:19 -04:00
|
|
|
from apps.lyric.models import User
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
|
|
|
|
|
def test_sky_view_renders_template(self):
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertTemplateUsed(response, "apps/dashboard/sky.html")
|
|
|
|
|
|
|
|
|
|
def test_sky_view_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_sky_view_passes_preview_and_save_urls(self):
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertContains(response, reverse("sky_preview"))
|
|
|
|
|
self.assertContains(response, reverse("sky_save"))
|
|
|
|
|
|
+52 IT/UT to close IT/UT-only coverage gaps (93% → 96%) — full suite 983 tests in 47s ; UTs in epic/tests/unit/test_models.py — `TarotCardEmanationForTest` (4) covers `emanation_for(polarity)` w. levity/gravity overrides + fallback to name_title for cards w.o a polarity split (cards 48-49 are the only polarity-split cards in the deck so this method is sparsely exercised by ITs); `TarotCardReversalForTest` (4) covers `reversal_for(polarity)` w. polarity-split + reversal_qualifier fallback + further fallthrough to emanation_for; `TarotCardNameSplitTest` (4) covers `name_group`/`name_title` colon-split parsing (prefix-w-colon / suffix / no-colon edge); `TarotCardCautionsJsonTest` (2) covers the `cautions_json` JSON serialiser ; UTs in epic/tests/unit/test_utils.py — `PlanetHouseFallbackTest` +1 happy-path test (degree=15 lands in house 1 w. sequential cusps) for the normal cusp-match branch alongside the existing pathological fallback test; `TopCapacitorsTest` (6) covers all `top_capacitors()` branches — empty dict / None / all-zero counts (the L56 `max(counts.values()) <= 0` fallback that was uncovered) / single-winner / tie-clockwise-order / enriched dict {"count":N} input shape ; ITs in epic/tests/integrated/test_models.py — `TarotDeckDrawTest` extended w. 5 tests for `remaining_count` (happy + no-deck-variant fallback to 0) + `draw()` happy-path (returns n tuples of (TarotCard, bool) / appends to drawn_card_ids / never repeats cards across consecutive draws); existing ValueError + shuffle tests preserved ; ITs in epic/tests/integrated/test_views.py — `SigEventRetractionTest` (4 tests) covers the three `data["retracted"] = True` paths that the FT `test_game_room_select_sig.py` walks transitively but no IT pins directly: sig_unready retracts prior SIG_READY (L937), sig_ready retracts prior SIG_UNREADY (L907), sig_reserve action=release while ready retracts prior SIG_READY + records fresh SIG_UNREADY (L823); `SigReserveInvalidCardIdTest` (1) covers `TarotCard.DoesNotExist` → 400 (L840-841) ; `SigSelectGravityContextTest` (3) covers the `user_polarity = 'gravity'` branch (L322) + the `gravity_sig_cards` lookup (L357) — all existing SIG_SELECT context tests use the founder-as-PC-levity setup so these branches sat uncovered; logs in as gamers[5] (BC role) + asserts user_polarity + sig_cards match `gravity_sig_cards()` output ; `SeaDeckViewTest` (7) mirrors the `test_game_room_select_sea.py` FT but isolates the JSON contract — covers 403 when unseated, empty halves when seat has no deck_variant (L1255-1256 early-out), two-halves shape, ~even split, card_dict keys (`id`/`name`/`arcana`/`corner_rank`/`suit_icon`/`name_group`/`name_title`/`reversed`/qualifiers), `reversed` field is bool, claimed-significator exclusion via `room.table_seats.exclude(significator__isnull=True)` ; ITs in dashboard/tests/integrated/test_views.py — `ProfileViewTest` +2 (reserved-handle "adman" rejection — L116-117: username stays unchanged + redirect to /); `KitBagViewTest` (3) covers the `kit_bag` view's panel render w. TITHE-sort branch (L169-175) + login guard ; ITs in dashboard/tests/integrated/test_sky_views.py — `SkyViewTest` +2 (saved birth datetime renders in user's `sky_birth_tz` via astimezone L300-306 — 16:00 UTC → 12:00 EDT; invalid-tz string triggers `ZoneInfoNotFoundError` → swallowed `pass` → UTC fallback at 16:00) ; ITs in gameboard/tests/integrated/test_views.py — `EquipTrinketViewTest` +2 (POST equips trinket + returns 204 — L83-85; non-owner POST returns 404 via `get_object_or_404`); `UnequipTrinketViewTest` +2 (POST clears matching equipped_trinket — L107-110; POST of non-matching token is a 204 no-op, the implicit `else` branch) ; .coveragerc omit gains `*/reset_staging_db.py` per user — mgmt cmd was the only 0%-stmt module that wasn't exercised by tests at all + we agreed it's deliberately untested staging-side code ; palette-monochrome-dark rebalance in rootvars.scss — --quiUser/--sixUser/--sepUser remapped to (secAg / quaAg / priPt) instead of (quaAg / terAg / secAg), shifting the secondary/subtle/deep-subtle anchors up the silver gradient so the palette reads more cleanly under the new sig-stage card colours from 3242873 ; uncovered remnants from earlier analysis intentionally left in place — consumers.py at 68% (channels-tag tests excluded; would need --tag=channels run), Carte Blanche slot navigation + sky_dice + tarot_deck preview view paths (the "bigger investments" tier from session triage; FT-covered + the IT setup is heavier than the immediate value), defensive `except` fallbacks that need contrived inputs to fire, and a handful of __str__s/`pass` branches not worth a test apiece — TDD
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 01:07:13 -04:00
|
|
|
def test_saved_birth_date_renders_in_user_tz_when_set(self):
|
|
|
|
|
"""A user w. saved sky_birth_dt + sky_birth_tz hits the astimezone
|
|
|
|
|
branch (views.py L300-306) — saved_birth_date / saved_birth_time
|
|
|
|
|
render in the user's local tz, not UTC."""
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
import zoneinfo
|
|
|
|
|
# 1990-06-15 16:00 UTC = 12:00 PM in America/New_York (EDT, UTC-4)
|
|
|
|
|
self.user.sky_birth_dt = datetime(1990, 6, 15, 16, 0, tzinfo=zoneinfo.ZoneInfo("UTC"))
|
|
|
|
|
self.user.sky_birth_tz = "America/New_York"
|
|
|
|
|
self.user.save()
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertEqual(response.context["saved_birth_date"], "1990-06-15")
|
|
|
|
|
self.assertEqual(response.context["saved_birth_time"], "12:00")
|
|
|
|
|
|
|
|
|
|
def test_saved_birth_falls_back_to_utc_when_tz_invalid(self):
|
|
|
|
|
"""A garbage sky_birth_tz triggers ZoneInfoNotFoundError — the view
|
|
|
|
|
swallows it (pass) and renders the UTC representation."""
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
import zoneinfo
|
|
|
|
|
self.user.sky_birth_dt = datetime(1990, 6, 15, 16, 0, tzinfo=zoneinfo.ZoneInfo("UTC"))
|
|
|
|
|
self.user.sky_birth_tz = "Not/A/Real_Zone"
|
|
|
|
|
self.user.save()
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
# UTC fallback — 16:00 stays 16:00
|
|
|
|
|
self.assertEqual(response.context["saved_birth_time"], "16:00")
|
|
|
|
|
|
2026-05-08 15:27:09 -04:00
|
|
|
def test_tz_input_is_readonly_and_carries_auto_detect_placeholder(self):
|
|
|
|
|
"""Manual TZ edits throw the schedulePreview / PySwiss fetch off (the
|
|
|
|
|
backend gets a stale TZ for the new lat/lon), so the field is render-
|
|
|
|
|
readonly like lat/lon — auto-fills from preview, never from a typed
|
|
|
|
|
override. The old <small id="id_nf_tz_hint"> is gone; its copy lives
|
|
|
|
|
in the placeholder so an empty field is self-explanatory."""
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertContains(response, 'id="id_nf_tz"')
|
|
|
|
|
# readonly + tabindex:-1 mirrors the lat/lon pattern.
|
|
|
|
|
self.assertRegex(
|
|
|
|
|
response.content.decode(),
|
|
|
|
|
r'id="id_nf_tz"[^>]*\breadonly\b',
|
|
|
|
|
)
|
|
|
|
|
self.assertContains(response, 'placeholder="auto-detected from coordinates"')
|
|
|
|
|
self.assertNotContains(response, 'id="id_nf_tz_hint"')
|
|
|
|
|
|
2026-04-16 03:03:19 -04:00
|
|
|
|
|
|
|
|
class SkyPreviewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_preview")
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_missing_params_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_invalid_lat_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "999", "lon": "0"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_proxies_to_pyswiss_and_returns_chart(self, mock_requests):
|
|
|
|
|
chart_payload = {
|
|
|
|
|
"planets": {"Sun": {"degree": 84.5, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [0]*12},
|
|
|
|
|
"elements": {"Fire": 1, "Earth": 0, "Air": 0, "Water": 0},
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
}
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.json.return_value = {"timezone": "Europe/London"}
|
|
|
|
|
tz_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.json.return_value = chart_payload
|
|
|
|
|
chart_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {
|
|
|
|
|
"date": "1990-06-15", "time": "09:30",
|
|
|
|
|
"lat": "51.5074", "lon": "-0.1278",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
data = response.json()
|
|
|
|
|
self.assertIn("planets", data)
|
|
|
|
|
# Earth→Stone rename applied
|
|
|
|
|
self.assertIn("Stone", data["elements"])
|
|
|
|
|
self.assertNotIn("Earth", data["elements"])
|
|
|
|
|
self.assertIn("timezone", data)
|
|
|
|
|
self.assertIn("distinctions", data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkySaveTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_save")
|
|
|
|
|
|
|
|
|
|
def _post(self, payload):
|
|
|
|
|
return self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=json.dumps(payload),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self._post({})
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_get_not_allowed(self):
|
|
|
|
|
response = self.client.get(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 405)
|
|
|
|
|
|
|
|
|
|
def test_saves_sky_fields_to_user(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5074,
|
|
|
|
|
"birth_lon": -0.1278,
|
|
|
|
|
"birth_place": "London, UK",
|
|
|
|
|
"house_system": "O",
|
2026-04-21 20:07:40 -04:00
|
|
|
"chart_data": {},
|
2026-04-16 03:03:19 -04:00
|
|
|
}
|
|
|
|
|
response = self._post(payload)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(str(self.user.sky_birth_dt), "1990-06-15 08:30:00+00:00")
|
|
|
|
|
self.assertAlmostEqual(float(self.user.sky_birth_lat), 51.5074, places=3)
|
|
|
|
|
self.assertAlmostEqual(float(self.user.sky_birth_lon), -0.1278, places=3)
|
|
|
|
|
self.assertEqual(self.user.sky_birth_place, "London, UK")
|
|
|
|
|
self.assertEqual(self.user.sky_house_system, "O")
|
|
|
|
|
|
|
|
|
|
def test_invalid_json_returns_400(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
self.url, data="not json", content_type="application/json"
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_response_contains_saved_flag(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5,
|
|
|
|
|
"birth_lon": -0.1,
|
|
|
|
|
"birth_place": "",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": {},
|
|
|
|
|
}
|
|
|
|
|
data = self._post(payload).json()
|
|
|
|
|
self.assertTrue(data["saved"])
|
COVERAGE: patch 91% → 96%+ — 603 tests, tasks.py at 100%
New/extended tests across billboard, dashboard, drama, epic, gameboard,
and lyric to cover previously untested branches: dev_login view, scroll
position endpoints, sky preview error paths, drama to_prose/to_activity
branches, consumer broadcast handlers, tarot deck draw/shuffle, astrology
model __str__, character model, sig reserve/ready/confirm views, natus
preview/save views, and the full tasks.py countdown scheduler.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 23:23:28 -04:00
|
|
|
|
|
|
|
|
def test_invalid_birth_dt_string_sets_sky_birth_dt_to_none(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "not-a-date",
|
|
|
|
|
"birth_lat": 51.5,
|
|
|
|
|
"birth_lon": -0.1,
|
|
|
|
|
"birth_place": "",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": {},
|
|
|
|
|
}
|
|
|
|
|
response = self._post(payload)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertIsNone(self.user.sky_birth_dt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyPreviewErrorPathTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star2@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_preview")
|
|
|
|
|
|
|
|
|
|
def test_non_numeric_lat_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "abc", "lon": "0"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_invalid_tz_string_returns_400(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1", "tz": "Not/ATimezone"}
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_bad_date_format_returns_400(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
self.url,
|
|
|
|
|
{"date": "not-a-date", "time": "09:00", "lat": "51.5", "lon": "-0.1", "tz": "UTC"},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_pyswiss_tz_failure_falls_back_to_utc_and_continues(self, mock_requests):
|
|
|
|
|
chart_payload = {
|
|
|
|
|
"planets": {"Sun": {"degree": 84.5, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [0] * 12},
|
|
|
|
|
"elements": {},
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
}
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.raise_for_status.side_effect = Exception("tz timeout")
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.json.return_value = chart_payload
|
|
|
|
|
chart_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertEqual(response.json()["timezone"], "UTC")
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_pyswiss_chart_failure_returns_502(self, mock_requests):
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.json.return_value = {"timezone": "UTC"}
|
|
|
|
|
tz_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.raise_for_status.side_effect = Exception("chart timeout")
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 502)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
_REAL_CHART = {
|
|
|
|
|
"planets": {"Sun": {"degree": 66.7, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [180, 210, 240, 270, 300, 330, 0, 30, 60, 90, 120, 150]},
|
|
|
|
|
"elements": {"Fire": 1, "Stone": 2, "Air": 4, "Water": 0, "Time": 1, "Space": 1},
|
|
|
|
|
"aspects": [],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
class SkySaveNoteTest(TestCase):
|
|
|
|
|
"""sky_save grants the Stargazer Note on the first save with real chart_data."""
|
2026-04-22 02:13:29 -04:00
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_save")
|
|
|
|
|
|
|
|
|
|
def _post(self, chart_data=_REAL_CHART):
|
|
|
|
|
return self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=json.dumps({
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5074,
|
|
|
|
|
"birth_lon": -0.1278,
|
|
|
|
|
"birth_place": "London, UK",
|
|
|
|
|
"birth_tz": "Europe/London",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": chart_data,
|
|
|
|
|
}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
def test_first_save_with_chart_data_returns_stargazer_brief(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post().json()
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
self.assertIn("brief", data)
|
|
|
|
|
brief = data["brief"]
|
|
|
|
|
self.assertEqual(brief["kind"], "note_unlock")
|
|
|
|
|
self.assertEqual(brief["title"], "Stargazer")
|
|
|
|
|
self.assertIn("Stargazer", brief["line_text"])
|
|
|
|
|
self.assertIn("/billboard/post/", brief["post_url"])
|
|
|
|
|
self.assertEqual(brief["square_url"], "/billboard/my-notes/")
|
|
|
|
|
self.assertIn("created_at", brief)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_first_save_creates_note_in_db(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 1)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
def test_second_save_returns_null_brief(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
|
|
|
|
data = self._post().json()
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
self.assertIsNone(data["brief"])
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_second_save_does_not_create_duplicate_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
|
|
|
|
self._post()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 1)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_save_with_empty_chart_data_does_not_grant_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post(chart_data={}).json()
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
self.assertIsNone(data["brief"])
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 0)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_save_with_null_chart_data_does_not_grant_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post(chart_data=None).json()
|
brief sprint C3.a: Note unlock spawns Line + Brief on the user's per-category Post; banner JS consumes the new brief payload (FYI → post detail, square → my-notes) — TDD
Wires the C2 Brief model into the existing Note-unlock pipeline. Per the per-category Post model: each user has a single Post(owner=user, kind=NOTE_UNLOCK) titled by the header Line "Look! — new Note unlocked"; each unlock appends a per-event Line ("Stargazer, 5:21:00 PM") + spawns a Brief FK'd to that Line.
Server:
- billboard.Post gains a `kind` enum (NOTE_UNLOCK / USER_POST / SHARE_INVITE, default USER_POST) so the per-category Post is deterministically discoverable via (owner, kind=NOTE_UNLOCK).
- drama.Note.grant_if_new now returns (note, created, brief) — backwards-incompat tuple shape; the new third slot is None on idempotent re-grants. On a fresh grant it: get-or-creates the user's Note Unlocks Post; ensures the header Line; appends a per-event Line w. timestamp; creates a Brief(kind=NOTE_UNLOCK, owner, post, line, title=note.display_title).
- dashboard.views.sky_save's response shape flips {note: {...}|null} → {brief: {...}|null}. The new helper _brief_to_banner_dict exposes {id, kind, title, line_text, post_url, square_url, created_at}; for NOTE_UNLOCK kind, square_url = reverse('billboard:my_notes').
Banner JS (apps/dashboard/note.js):
- Module renamed Note → Brief (Note kept as an alias during the C3 sprint; will retire in C3.e). showBanner now consumes the Brief shape: title from brief.title, body from brief.line_text, time from brief.created_at, FYI href = brief.post_url, NVM dismisses, .note-banner__image is rendered as a clickable <a href=brief.square_url> when square_url is set. The CSS class names (.note-banner, .note-banner__title, etc.) stay so all existing SCSS + FT selectors keep working.
- sky.html + _applet-my-sky.html flip Note.handleSaveResponse → Brief.handleSaveResponse.
Tests:
- new IT class GrantIfNewSpawnsBriefTest (5 tests): first grant creates Post+Line+Brief, idempotent on second grant returns no brief, two different slugs share one Post, line text carries note title, post.kind == NOTE_UNLOCK. PostKindFieldTest (2 tests): default user_post + all three choices present.
- existing drama test_models.GrantIfNew tests updated to unpack the third tuple element.
- dashboard.tests.integrated.test_sky_views: 5 tests flipped from data["note"] → data["brief"] w/ the new payload shape (kind=note_unlock, title=Stargazer, line_text contains Stargazer, post_url under /billboard/post/, square_url=/billboard/my-notes/).
- NoteSpec.js (Jasmine): 12 specs rewritten for the Brief shape — SAMPLE_BRIEF carries the seven fields, T6 asserts the square is a clickable <a>, T8 asserts FYI points at brief.post_url (was hardcoded /billboard/my-notes/).
- functional_tests.test_applet_my_notes: T2 split — FYI now navigates to /billboard/post/<uuid>/ (the post detail / mark-read contract), the .note-banner__image square preserves the legacy jump direct to /billboard/my-notes/.
billboard/0003_post_kind migration auto-generated. 808 ITs + 9 my_notes FTs + 1 Jasmine FT all green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 18:00:01 -04:00
|
|
|
self.assertIsNone(data["brief"])
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 0)
|
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>
2026-05-08 13:07:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|