2026-04-22 04:02:14 -04:00
|
|
|
import json as _json
|
|
|
|
|
|
2026-03-24 16:46:46 -04:00
|
|
|
from django.test import TestCase
|
|
|
|
|
from django.urls import reverse
|
2026-04-22 04:02:14 -04:00
|
|
|
from django.utils import timezone
|
2026-03-24 16:46:46 -04:00
|
|
|
|
|
|
|
|
from apps.applets.models import Applet
|
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 GameEvent, Note, ScrollPosition, record
|
2026-03-24 16:46:46 -04:00
|
|
|
from apps.epic.models import Room
|
|
|
|
|
from apps.lyric.models import User
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _seed_billboard_applets():
|
|
|
|
|
for slug, name, cols, rows in [
|
2026-05-03 23:22:01 -04:00
|
|
|
("my-scrolls", "My Scrolls", 4, 3),
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
("my-buddies", "My Buddies", 4, 3),
|
2026-05-03 23:22:01 -04:00
|
|
|
("most-recent-scroll", "Most Recent Scroll", 8, 6),
|
2026-03-24 16:46:46 -04:00
|
|
|
]:
|
|
|
|
|
Applet.objects.get_or_create(
|
|
|
|
|
slug=slug,
|
|
|
|
|
defaults={"name": name, "grid_cols": cols, "grid_rows": rows, "context": "billboard"},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BillboardViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="test@billboard.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
_seed_billboard_applets()
|
|
|
|
|
|
|
|
|
|
def test_uses_billboard_template(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertTemplateUsed(response, "apps/billboard/billboard.html")
|
|
|
|
|
|
|
|
|
|
def test_passes_applets_context(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertIn("applets", response.context)
|
|
|
|
|
slugs = [e["applet"].slug for e in response.context["applets"]]
|
2026-05-03 23:22:01 -04:00
|
|
|
self.assertIn("my-scrolls", slugs)
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
self.assertIn("my-buddies", slugs)
|
2026-05-03 23:22:01 -04:00
|
|
|
self.assertIn("most-recent-scroll", slugs)
|
2026-03-24 16:46:46 -04:00
|
|
|
|
|
|
|
|
def test_passes_my_rooms_context(self):
|
|
|
|
|
room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertIn(room, response.context["my_rooms"])
|
|
|
|
|
|
|
|
|
|
def test_passes_recent_room_and_events(self):
|
|
|
|
|
room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
record(
|
|
|
|
|
room, GameEvent.SLOT_FILLED, actor=self.user,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertEqual(response.context["recent_room"], room)
|
|
|
|
|
self.assertEqual(len(response.context["recent_events"]), 1)
|
|
|
|
|
|
2026-03-24 17:19:09 -04:00
|
|
|
def test_recent_events_capped_at_36(self):
|
|
|
|
|
room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
for i in range(40):
|
|
|
|
|
record(
|
|
|
|
|
room, GameEvent.SLOT_FILLED, actor=self.user,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertEqual(len(response.context["recent_events"]), 36)
|
|
|
|
|
|
|
|
|
|
def test_recent_events_in_chronological_order(self):
|
|
|
|
|
room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
for _ in range(3):
|
|
|
|
|
record(
|
|
|
|
|
room, GameEvent.SLOT_FILLED, actor=self.user,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
events = response.context["recent_events"]
|
|
|
|
|
timestamps = [e.timestamp for e in events]
|
|
|
|
|
self.assertEqual(timestamps, sorted(timestamps))
|
|
|
|
|
|
2026-03-24 16:46:46 -04:00
|
|
|
def test_recent_room_is_none_when_no_events(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertIsNone(response.context["recent_room"])
|
|
|
|
|
self.assertEqual(list(response.context["recent_events"]), [])
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
class SaveScrollPositionViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="reader@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
self.url = f"/billboard/room/{self.room.id}/scroll-position/"
|
|
|
|
|
|
|
|
|
|
def test_get_returns_405(self):
|
|
|
|
|
response = self.client.get(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 405)
|
|
|
|
|
|
|
|
|
|
|
2026-03-24 16:46:46 -04:00
|
|
|
class ToggleBillboardAppletsTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="test@toggle.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
_seed_billboard_applets()
|
|
|
|
|
|
|
|
|
|
def test_toggle_hides_unchecked_applets(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
2026-05-03 23:22:01 -04:00
|
|
|
{"applets": ["my-scrolls"]},
|
2026-03-24 16:46:46 -04:00
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
from apps.applets.models import UserApplet
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
contacts = Applet.objects.get(slug="my-buddies")
|
2026-03-24 16:46:46 -04:00
|
|
|
ua = UserApplet.objects.get(user=self.user, applet=contacts)
|
|
|
|
|
self.assertFalse(ua.visible)
|
|
|
|
|
|
|
|
|
|
def test_toggle_returns_partial_on_htmx(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
2026-05-03 23:22:01 -04:00
|
|
|
{"applets": ["my-scrolls"]},
|
2026-03-24 16:46:46 -04:00
|
|
|
HTTP_HX_REQUEST="true",
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertTemplateUsed(response, "apps/billboard/_partials/_applets.html")
|
|
|
|
|
|
2026-05-03 23:22:01 -04:00
|
|
|
def test_htmx_toggle_response_renders_most_recent_scroll_with_real_events(self):
|
|
|
|
|
# Seed a room + event so Most Recent Scroll renders prose, not the empty fallback.
|
2026-05-03 17:15:26 -04:00
|
|
|
room = Room.objects.create(name="Sound Chamber", owner=self.user)
|
|
|
|
|
record(
|
|
|
|
|
room, GameEvent.SLOT_FILLED, actor=self.user,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
|
|
|
|
{"applets": [
|
2026-05-03 23:22:01 -04:00
|
|
|
"my-scrolls",
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
"my-buddies",
|
2026-05-03 23:22:01 -04:00
|
|
|
"most-recent-scroll",
|
2026-05-03 17:15:26 -04:00
|
|
|
]},
|
|
|
|
|
HTTP_HX_REQUEST="true",
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertContains(response, "Coin-on-a-String")
|
|
|
|
|
# And My Scrolls renders the room name (needs my_rooms in context).
|
|
|
|
|
self.assertContains(response, "Sound Chamber")
|
|
|
|
|
|
|
|
|
|
def test_htmx_toggle_response_has_single_applet_menu_div(self):
|
|
|
|
|
# The response is hx-swapped into the page; if it contains both the menu
|
|
|
|
|
# div and the applets-container div, the original menu remains and the
|
|
|
|
|
# next gear-click resurrects stale form state. Response must contain the
|
|
|
|
|
# menu exactly once (the wrapper) — never two siblings of the same id.
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
2026-05-03 23:22:01 -04:00
|
|
|
{"applets": ["my-scrolls"]},
|
2026-05-03 17:15:26 -04:00
|
|
|
HTTP_HX_REQUEST="true",
|
|
|
|
|
)
|
|
|
|
|
body = response.content.decode("utf-8")
|
|
|
|
|
self.assertEqual(body.count('id="id_billboard_applet_menu"'), 1)
|
|
|
|
|
|
|
|
|
|
def test_second_toggle_preserves_prior_hidden_state(self):
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
# First toggle: hide My Buddies only.
|
2026-05-03 17:15:26 -04:00
|
|
|
self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
|
|
|
|
{"applets": [
|
|
|
|
|
"new-post", "my-posts",
|
2026-05-03 23:22:01 -04:00
|
|
|
"my-scrolls",
|
|
|
|
|
"most-recent-scroll",
|
2026-05-03 17:15:26 -04:00
|
|
|
]},
|
|
|
|
|
HTTP_HX_REQUEST="true",
|
|
|
|
|
)
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
# Second toggle: hide Most Recent Scroll additionally — My Buddies must stay hidden.
|
2026-05-03 17:15:26 -04:00
|
|
|
self.client.post(
|
|
|
|
|
reverse("billboard:toggle_applets"),
|
|
|
|
|
{"applets": [
|
|
|
|
|
"new-post", "my-posts",
|
2026-05-03 23:22:01 -04:00
|
|
|
"my-scrolls",
|
2026-05-03 17:15:26 -04:00
|
|
|
]},
|
|
|
|
|
HTTP_HX_REQUEST="true",
|
|
|
|
|
)
|
|
|
|
|
from apps.applets.models import UserApplet
|
buddies sprint phase 1: User.buddies M2M(self,symm=False) + my_buddies aperture page + add_buddy JSON endpoint + buddy btn slide-out — TDD; My Contacts applet renamed → My Buddies (slug + name + partial)
- lyric/0004 adds User.buddies = ManyToManyField('self', symmetrical=False, blank=True, related_name='added_as_buddy'). Asymmetric one-way add: A.buddies.add(B) doesn't reciprocate. Reverse via B.added_as_buddy.all() — load-bearing for the future "buddy changed username" snapshot-accept flow noted in design.
- applets/0006 renames slug my-contacts → my-buddies + name 'Contacts' → 'My Buddies'. Existing migrations 0003/0004 untouched (historical artifacts).
- billboard.views.my_buddies + add_buddy:
• my_buddies: GET /billboard/my-buddies/ → renders the aperture page with request.user.buddies.all().
• add_buddy: POST /billboard/buddies/add → JSON {buddy: {id, username, email}|null}. Privacy: returns null when email isn't a registered User OR is the requester's own; never leaks membership. Idempotent on re-add (M2M dedup).
- templates:
• _applet-my-contacts.html → _applet-my-buddies.html (heading + link to /billboard/my-buddies/).
• my_buddies.html — bottom-anchored aperture list of buddies w. {% empty %} fallback "No buddies yet."
• _buddy_add_panel.html — bottom-left handshake btn + slide-out, mirrors _buddy_panel.html (post share) but POSTs to add_buddy and appends to #id_buddies_list. Skips append if data-buddy-id already in DOM (race-safe). Drops the .buddy-entry--empty row on first add.
- SCSS: page-billbuddies joins the body-class aperture trio; .buddies-page extends %billboard-page-base + flex-column + bottom-anchor for #id_buddies_list. id_applet_my_contacts → id_applet_my_buddies (test references + grid placement).
- tests: new test_buddies.py — 14 ITs covering UserBuddiesM2MTest (asymmetric, idempotent), MyBuddiesViewTest (lists own buddies only, anon redirect), AddBuddyViewTest (registered/unregistered/self/idempotent/email-fallback/405). Existing test_views/test_billboard/test_game_kit references swapped to my-buddies. New test_my_buddies.py FT — 4 tests: pre-existing buddies render, empty state, add via panel appends entry w. username, unregistered silent no-op.
- 841 ITs (+14) + 4 my_buddies FTs green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 22:31:42 -04:00
|
|
|
contacts = Applet.objects.get(slug="my-buddies")
|
2026-05-03 23:22:01 -04:00
|
|
|
most_recent_scroll = Applet.objects.get(slug="most-recent-scroll")
|
2026-05-03 17:15:26 -04:00
|
|
|
self.assertFalse(
|
|
|
|
|
UserApplet.objects.get(user=self.user, applet=contacts).visible
|
|
|
|
|
)
|
|
|
|
|
self.assertFalse(
|
2026-05-03 23:22:01 -04:00
|
|
|
UserApplet.objects.get(user=self.user, applet=most_recent_scroll).visible
|
2026-05-03 17:15:26 -04:00
|
|
|
)
|
|
|
|
|
|
2026-03-24 16:46:46 -04:00
|
|
|
|
|
|
|
|
class BillscrollViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="test@billscroll.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
record(
|
|
|
|
|
self.room, GameEvent.SLOT_FILLED, actor=self.user,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
|
2026-05-03 23:22:01 -04:00
|
|
|
def test_uses_scroll_template(self):
|
2026-03-24 16:46:46 -04:00
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
2026-05-03 23:22:01 -04:00
|
|
|
self.assertTemplateUsed(response, "apps/billboard/scroll.html")
|
2026-03-24 16:46:46 -04:00
|
|
|
|
|
|
|
|
def test_passes_events_context(self):
|
|
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
|
|
|
|
self.assertIn("events", response.context)
|
|
|
|
|
self.assertEqual(response.context["events"].count(), 1)
|
|
|
|
|
|
|
|
|
|
def test_passes_page_class_billscroll(self):
|
|
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
|
|
|
|
self.assertEqual(response.context["page_class"], "page-billscroll")
|
2026-03-24 17:44:34 -04:00
|
|
|
|
|
|
|
|
def test_passes_scroll_position_zero_when_none_saved(self):
|
|
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
|
|
|
|
self.assertEqual(response.context["scroll_position"], 0)
|
|
|
|
|
|
|
|
|
|
def test_passes_saved_scroll_position_in_context(self):
|
|
|
|
|
ScrollPosition.objects.create(user=self.user, room=self.room, position=250)
|
|
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
|
|
|
|
self.assertEqual(response.context["scroll_position"], 250)
|
|
|
|
|
|
2026-04-02 14:51:08 -04:00
|
|
|
def test_scroll_renders_event_body_and_time_columns(self):
|
|
|
|
|
response = self.client.get(f"/billboard/room/{self.room.id}/scroll/")
|
|
|
|
|
self.assertContains(response, 'class="drama-event-body"')
|
|
|
|
|
self.assertContains(response, 'class="drama-event-time"')
|
|
|
|
|
|
2026-03-24 17:44:34 -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
|
|
|
class NotePageViewTest(TestCase):
|
2026-04-22 04:02:14 -04:00
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="recog@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
2026-04-22 04:02:14 -04:00
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
|
|
|
|
|
def test_returns_200(self):
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
2026-04-22 04:02:14 -04:00
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
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_uses_note_page_template(self):
|
|
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertTemplateUsed(response, "apps/billboard/my_notes.html")
|
2026-04-22 04:02:14 -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_passes_notes_in_context(self):
|
|
|
|
|
recog = Note.objects.create(
|
2026-04-22 04:02:14 -04:00
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now()
|
|
|
|
|
)
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertIn(recog, response.context["notes"])
|
2026-04-22 04:02:14 -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_excludes_other_users_notes(self):
|
2026-04-22 04:02:14 -04:00
|
|
|
other = User.objects.create(email="other@test.io")
|
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
|
|
|
Note.objects.create(
|
2026-04-22 04:02:14 -04:00
|
|
|
user=other, slug="stargazer", earned_at=timezone.now()
|
|
|
|
|
)
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertEqual(list(response.context["notes"]), [])
|
2026-04-22 04:02:14 -04:00
|
|
|
|
|
|
|
|
def test_renders_recog_list_and_items(self):
|
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
|
|
|
Note.objects.create(
|
2026-04-22 04:02:14 -04:00
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now()
|
|
|
|
|
)
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertContains(response, 'class="note-list"')
|
|
|
|
|
self.assertContains(response, 'class="note-item"')
|
2026-04-22 04:02:14 -04:00
|
|
|
|
|
|
|
|
def test_renders_recog_item_title_description_image_box(self):
|
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
|
|
|
Note.objects.create(
|
2026-04-22 04:02:14 -04:00
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now()
|
|
|
|
|
)
|
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
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertContains(response, 'class="note-item__title"')
|
|
|
|
|
self.assertContains(response, 'class="note-item__description"')
|
|
|
|
|
self.assertContains(response, 'class="note-item__image-box"')
|
2026-04-22 04:02:14 -04:00
|
|
|
|
2026-04-23 01:31:19 -04:00
|
|
|
def test_palette_modal_renders_swatch_labels(self):
|
|
|
|
|
"""Each palette option in the swatch modal should display its human-readable
|
|
|
|
|
label next to the swatch body so the user knows what they are choosing."""
|
|
|
|
|
Note.objects.create(
|
|
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now()
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/my-notes/")
|
|
|
|
|
self.assertContains(response, 'class="note-swatch-label"')
|
|
|
|
|
self.assertContains(response, "Bardo")
|
|
|
|
|
self.assertContains(response, "Sheol")
|
|
|
|
|
|
2026-04-22 04:02:14 -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
|
|
|
class NoteSetPaletteViewTest(TestCase):
|
2026-04-22 04:02:14 -04:00
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="setpal@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
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.note = Note.objects.create(
|
2026-04-22 04:02:14 -04:00
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now(),
|
|
|
|
|
)
|
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.url = "/billboard/note/stargazer/set-palette"
|
2026-04-22 04:02:14 -04:00
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=_json.dumps({"palette": "palette-bardo"}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
|
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_sets_palette_on_note(self):
|
2026-04-22 04:02:14 -04:00
|
|
|
self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=_json.dumps({"palette": "palette-bardo"}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
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.note.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.note.palette, "palette-bardo")
|
2026-04-22 04:02:14 -04:00
|
|
|
|
|
|
|
|
def test_returns_200_with_ok(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=_json.dumps({"palette": "palette-bardo"}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertEqual(response.json(), {"ok": True})
|
|
|
|
|
|
|
|
|
|
def test_returns_404_for_slug_user_does_not_own(self):
|
|
|
|
|
response = self.client.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
|
|
|
"/billboard/note/schizo/set-palette",
|
2026-04-22 04:02:14 -04:00
|
|
|
data=_json.dumps({"palette": "palette-bardo"}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 404)
|
|
|
|
|
|
2026-04-22 23:54:05 -04:00
|
|
|
def test_also_saves_user_palette(self):
|
|
|
|
|
"""note_set_palette must persist the choice to user.palette so the
|
|
|
|
|
palette survives page navigation (sitewide commitment)."""
|
|
|
|
|
self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=_json.dumps({"palette": "palette-bardo"}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.user.palette, "palette-bardo")
|
|
|
|
|
|
2026-04-22 04:02:14 -04:00
|
|
|
|
2026-04-23 01:44:58 -04:00
|
|
|
class NoteEquipTitleViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="don@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.note = Note.objects.create(
|
|
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now(),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_don_sets_active_title(self):
|
|
|
|
|
self.client.post("/billboard/note/stargazer/don")
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.user.active_title, self.note)
|
|
|
|
|
|
|
|
|
|
def test_doff_clears_active_title(self):
|
|
|
|
|
self.user.active_title = self.note
|
|
|
|
|
self.user.save(update_fields=["active_title"])
|
|
|
|
|
self.client.post("/billboard/note/stargazer/doff")
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertIsNone(self.user.active_title)
|
|
|
|
|
|
|
|
|
|
def test_don_returns_200_with_title(self):
|
|
|
|
|
response = self.client.post("/billboard/note/stargazer/don")
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertEqual(response.json()["title"], "Stargazer")
|
|
|
|
|
|
|
|
|
|
def test_doff_returns_200(self):
|
|
|
|
|
response = self.client.post("/billboard/note/stargazer/doff")
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
2026-04-28 02:00:22 -04:00
|
|
|
data = response.json()
|
|
|
|
|
self.assertTrue(data["ok"])
|
|
|
|
|
self.assertEqual(data["greeting"], "Welcome,")
|
|
|
|
|
self.assertEqual(data["title"], "Earthman")
|
2026-04-23 01:44:58 -04:00
|
|
|
|
|
|
|
|
def test_don_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.post("/billboard/note/stargazer/don")
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
|
|
|
|
|
def test_don_returns_404_for_unowned_note(self):
|
|
|
|
|
other = User.objects.create(email="other@test.io")
|
|
|
|
|
Note.objects.create(user=other, slug="stargazer", earned_at=timezone.now())
|
|
|
|
|
self.client.logout()
|
|
|
|
|
self.client.force_login(other)
|
|
|
|
|
response = self.client.post("/billboard/note/stargazer/don")
|
|
|
|
|
# other user's own note — should work
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
|
2026-03-24 17:44:34 -04:00
|
|
|
class SaveScrollPositionTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="test@savescroll.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.room = Room.objects.create(name="Test Room", owner=self.user)
|
|
|
|
|
|
|
|
|
|
def test_post_saves_scroll_position(self):
|
|
|
|
|
self.client.post(
|
|
|
|
|
f"/billboard/room/{self.room.id}/scroll-position/",
|
|
|
|
|
{"position": 300},
|
|
|
|
|
)
|
|
|
|
|
sp = ScrollPosition.objects.get(user=self.user, room=self.room)
|
|
|
|
|
self.assertEqual(sp.position, 300)
|
|
|
|
|
|
|
|
|
|
def test_post_updates_existing_position(self):
|
|
|
|
|
ScrollPosition.objects.create(user=self.user, room=self.room, position=100)
|
|
|
|
|
self.client.post(
|
|
|
|
|
f"/billboard/room/{self.room.id}/scroll-position/",
|
|
|
|
|
{"position": 450},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
ScrollPosition.objects.get(user=self.user, room=self.room).position, 450
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_post_returns_204(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
f"/billboard/room/{self.room.id}/scroll-position/",
|
|
|
|
|
{"position": 100},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 204)
|
|
|
|
|
|
|
|
|
|
def test_post_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
f"/billboard/room/{self.room.id}/scroll-position/",
|
|
|
|
|
{"position": 100},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|