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),
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
("my-buds", "My Buds", 4, 3),
|
2026-05-03 23:22:01 -04:00
|
|
|
("most-recent-scroll", "Most Recent Scroll", 8, 6),
|
fix CARTE multi-seat Role-Select bug on navigate-away + back; My Sign applet rename
**CARTE bug** (user-reported on iPhone): a CARTE gamer who contributed their deck to multiple gate slots could fill ≥1 role for ≥1 seat, navigate away (BYE → dashboard, CONT GAME → return, etc.), come back to the room — and the JS guard on .card-stack would wrongly fire "Equip card deck before Role select" + block further role picks, even though the deck was demonstrably in play on existing seats. Symmetric for the "stay in room during Role Select" variant the user thought we'd squashed before (the prior fix was 759ce8d for the multi-slot SELECT path, but the room VIEW context never got the same treatment) ; **root cause**: `select_role()` at epic/views.py:619-621 clears `user.equipped_deck` after the first role pick ("deck committed to room"). The room view's role-select context at epic/views.py:286 then passes `equipped_deck_id = user.equipped_deck_id` to the template — which is now None — and the template renders `data-equipped-deck=""` → JS guard at role-select.js:165 sees the empty string and fires the "no deck" warning. The deck IS in play; the context just isn't recognizing seat-level deck assignment as a deck source ; **fix** (epic/views.py:286ish): when `user.equipped_deck_id` is None, fall back to the deck_variant of any of the user's seats in this room (order_by slot_number for determinism). The guard now sees a non-empty id and the fan opens. Storage-side unchanged — seat.deck_variant remains the canonical "this deck is in play on this seat" signal, and the user's deck-third contribution per role (PC=levity brands+crowns / NC=levity trumps / SC=levity grails+blades / AC=gravity grails+blades / EC=gravity trumps / BC=gravity brands+crowns) flows from existing `select_role` logic that inherits deck_variant from the first seat ; **TDD trail** — 2 new ITs in `SelectRoleMultiSeatTest` (apps.epic.tests.integrated.test_views): T1 pins the context (`response.context["equipped_deck_id"]` equals the existing seat's deck_variant_id after `user.equipped_deck` clears); T2 pins the template (rendered `data-equipped-deck="<id>"` not `""`). Initial reds — `None != 2` + `data-equipped-deck=""` substring assertion. Fix lands both green ; **bundled: My Sign applet rename** — user clarified naming convention 2026-05-18: **applets** use the "My X" prefix (My Sign, My Sea, My Posts), **standalone pages** use the "Game/Dash/Bill X" prefix (Game Sign page, Game Sea page, Game Kit page). Sprint 4a's initial migration set the applet name to "Game Sign" — corrected after the user saw the gear-menu toggle list reading the wrong word. Applet template header link "Game Sign" → "My Sign" (user-edited); migration 0010 added to update the Applet row's `name` in already-migrated DBs (dev + staging); applets/0009 frontmatter + defaults updated to "My Sign" in case of a fresh migrate-from-zero; test seed helpers in billboard test_views.py + functional_tests/test_bill_my_sign.py updated to "My Sign". Slug stays `my-sign` (URL + selectors stable) ; **bundled: rootvars.scss** — user-modified mid-session (pre-staged) ; 1022 IT/UT green in 46s — no regressions; 4 ITs in SelectRoleMultiSeatTest green (2 pre-existing CARTE multi-seat ITs + 2 new return-trip context ITs)
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 23:18:32 -04:00
|
|
|
("my-sign", "My Sign", 4, 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)
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
self.assertIn("my-buds", 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"]), [])
|
|
|
|
|
|
2026-05-12 22:48:32 -04:00
|
|
|
# ── recent_buds + recent_notes (applet feed) ──────────────────────
|
|
|
|
|
# Mirrors the recent_posts pattern: each in-grid applet now lists
|
|
|
|
|
# its own most-recent items (capped at 3) plus an empty-state row.
|
|
|
|
|
|
|
|
|
|
def test_passes_recent_buds_context(self):
|
|
|
|
|
first = User.objects.create(email="first-bud@test.io")
|
|
|
|
|
second = User.objects.create(email="second-bud@test.io")
|
|
|
|
|
self.user.buds.add(first)
|
|
|
|
|
self.user.buds.add(second)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
# Most-recently-added bud is first
|
|
|
|
|
self.assertEqual(list(response.context["recent_buds"]), [second, first])
|
|
|
|
|
|
|
|
|
|
def test_recent_buds_capped_at_3(self):
|
|
|
|
|
added = [
|
|
|
|
|
User.objects.create(email=f"bud{i}@test.io") for i in range(5)
|
|
|
|
|
]
|
|
|
|
|
for u in added:
|
|
|
|
|
self.user.buds.add(u)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
recent = list(response.context["recent_buds"])
|
|
|
|
|
self.assertEqual(len(recent), 3)
|
|
|
|
|
# Newest three in newest-first order
|
|
|
|
|
self.assertEqual(recent, list(reversed(added))[:3])
|
|
|
|
|
|
|
|
|
|
def test_recent_buds_empty_when_no_buds(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertEqual(list(response.context["recent_buds"]), [])
|
|
|
|
|
|
|
|
|
|
def test_passes_recent_notes_context(self):
|
|
|
|
|
Note.objects.create(
|
|
|
|
|
user=self.user, slug="stargazer",
|
|
|
|
|
earned_at=timezone.now() - timezone.timedelta(days=2),
|
|
|
|
|
)
|
|
|
|
|
Note.objects.create(
|
|
|
|
|
user=self.user, slug="super-schizo",
|
|
|
|
|
earned_at=timezone.now(),
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
slugs = [n.slug for n in response.context["recent_notes"]]
|
|
|
|
|
# Most-recently-earned first
|
|
|
|
|
self.assertEqual(slugs, ["super-schizo", "stargazer"])
|
|
|
|
|
|
|
|
|
|
def test_recent_notes_capped_at_3(self):
|
|
|
|
|
slugs = ["stargazer", "super-schizo", "super-nomad", "ladidah", "doodah"]
|
|
|
|
|
base = timezone.now()
|
|
|
|
|
for i, slug in enumerate(slugs):
|
|
|
|
|
Note.objects.create(
|
|
|
|
|
user=self.user, slug=slug,
|
|
|
|
|
earned_at=base - timezone.timedelta(hours=i),
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
names = [n.slug for n in response.context["recent_notes"]]
|
|
|
|
|
self.assertEqual(len(names), 3)
|
|
|
|
|
# Newest-first; oldest two trimmed
|
|
|
|
|
self.assertEqual(names, slugs[:3])
|
|
|
|
|
|
|
|
|
|
def test_recent_notes_excludes_other_users(self):
|
|
|
|
|
other = User.objects.create(email="other-note@test.io")
|
|
|
|
|
Note.objects.create(user=other, slug="stargazer", earned_at=timezone.now())
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertEqual(list(response.context["recent_notes"]), [])
|
|
|
|
|
|
|
|
|
|
def test_recent_notes_empty_when_no_notes(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertEqual(list(response.context["recent_notes"]), [])
|
|
|
|
|
|
applet rows: 3-col grid `<title> | <body> | <ts>` mirroring post.html's `.post-line` shape — `_my_posts_applet_item / _my_buds_applet_item / _my_notes_item / _my_scrolls_item / _my_games_item` all gain a `.applet-list-entry.row-3col` w. `<a class="row-title">` (clickable, 35c/32+... server-side truncated via new `lyric_extras.truncate_title` filter) + `<span class="row-body">` (most-recent activity excerpt, dimmed 0.6 opacity, CSS-`text-overflow: ellipsis` clipped to whatever space remains — no server-side trunc here so the full line lives in the DOM for inspectors) + `<time class="row-ts">` (`relative_ts` formatted, same `minmax(3rem,auto)` rightward column allocation post.html's `.post-line-time` uses, font-size 0.75rem + opacity 0.5 + right-aligned + nowrap); SCSS grid `minmax(4rem,auto) 1fr minmax(3rem,auto)` lifted from `.post-line`'s template so the timestamp column lines up across post.html / scroll.html / every applet list; per-applet data shapes — `_recent_posts` annotates each Post w. `latest_line` (Line FK ordered by -id, None for empty Note-unlock posts); `_recent_buds` `select_related('to_user__active_title')` warms the bud's donned-Note FK in one query for the buds row body ("the {{ bud.active_title_display }}" + "since {{ bud.active_title.earned_at|relative_ts }}" — the "since " prefix is unique to this row since the ts is "when they donned it", not the row's own creation); `_recent_notes` attaches `description` from `_NOTE_META` per slug; `annotate_latest_event(rooms)` helper added to `apps.epic.utils` (next to `rooms_for_user`) — attaches `room.latest_event` per Room w. one `.events.order_by('-timestamp').first()` per item, used by `_billboard_context` for `my_rooms` (My Scrolls applet) AND by `apps.gameboard.views.gameboard` + `toggle_game_applets` for `my_games` (My Games applet), keeping the My Scrolls + My Games shapes symmetric; `_billboard_context.my_rooms = annotate_latest_event(...)` swaps `rooms_for_user(...).order_by("-created_at")` materialisation point — bud row's "no active title" branch silently drops body + ts cells so unrecognised buds still surface but don't fabricate a "since None" line; new `truncate_title` filter is the existing `_truncate_post_title` view helper hoisted into the template namespace (literal `...` past 35 chars, None-safe); 5 ITs in BillboardViewTest cover row content / row absence on missing activity / "since" prefix uniquely on the buds row + 1 in GameboardViewTest for My Games row event prose; deferred row-prose body content cap on `<span class="row-body">` purely to CSS `text-overflow: ellipsis` per user's "middle col should take up the remaining space" steer (initial pass also server-side trunc'd the body to 35c; removed) — TDD
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 23:06:55 -04:00
|
|
|
# ── 3-column applet row contract ──────────────────────────────────
|
|
|
|
|
# Each applet's list item renders `<title> | <body> | <ts>` —
|
|
|
|
|
# title + body wrapped in `.row-title` / `.row-body`, timestamp
|
|
|
|
|
# in a `<time class="row-ts">` element. The body shows the
|
|
|
|
|
# most-recent activity (post line / room event / note description /
|
|
|
|
|
# bud's active title). Right column carries `relative_ts` text.
|
|
|
|
|
|
|
|
|
|
def test_my_posts_applet_row_shows_latest_line_and_ts(self):
|
|
|
|
|
from apps.billboard.models import Line, Post
|
|
|
|
|
post = Post.objects.create(
|
|
|
|
|
owner=self.user, kind=Post.KIND_USER_POST, title="StampedPost",
|
|
|
|
|
)
|
|
|
|
|
Line.objects.create(post=post, text="first line text", author=self.user)
|
|
|
|
|
Line.objects.create(post=post, text="latest line text", author=self.user)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
# Title preserved
|
|
|
|
|
self.assertIn("StampedPost", body)
|
|
|
|
|
# Latest line surfaces in the row body, not the older line
|
|
|
|
|
self.assertIn("latest line text", body)
|
|
|
|
|
# A <time> ts element renders on the row
|
|
|
|
|
self.assertRegex(body, r'<time[^>]+class="[^"]*row-ts')
|
|
|
|
|
|
|
|
|
|
def test_my_buds_applet_row_shows_active_title_and_since_ts(self):
|
|
|
|
|
bud = User.objects.create(email="alice@test.io", username="alice")
|
|
|
|
|
note = Note.objects.create(
|
|
|
|
|
user=bud, slug="stargazer", earned_at=timezone.now(),
|
|
|
|
|
)
|
|
|
|
|
bud.active_title = note
|
|
|
|
|
bud.save()
|
|
|
|
|
self.user.buds.add(bud)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
# Bud handle shows; the active title surfaces as the row body;
|
|
|
|
|
# the ts column carries a "since " prefix unique to buds
|
|
|
|
|
self.assertIn("alice", body)
|
|
|
|
|
self.assertIn("the Stargazer", body)
|
|
|
|
|
self.assertRegex(body, r'class="[^"]*row-ts[^"]*"[^>]*>\s*since\s+')
|
|
|
|
|
|
|
|
|
|
def test_my_buds_applet_row_no_active_title_no_body_or_ts(self):
|
|
|
|
|
bud = User.objects.create(email="alice@test.io", username="alice")
|
|
|
|
|
# No active_title donned
|
|
|
|
|
self.user.buds.add(bud)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
self.assertIn("alice", body)
|
|
|
|
|
# Without an active title we don't render a "since" line
|
|
|
|
|
self.assertNotRegex(body, r'class="[^"]*row-ts[^"]*"[^>]*>\s*since\s+')
|
|
|
|
|
|
|
|
|
|
def test_my_notes_applet_row_shows_description_and_earned_at(self):
|
|
|
|
|
Note.objects.create(
|
|
|
|
|
user=self.user, slug="stargazer", earned_at=timezone.now(),
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
self.assertIn("Stargazer", body)
|
|
|
|
|
# Description prefix from _NOTE_META — full string is 40 chars and
|
|
|
|
|
# truncates to 32+"..." via the `truncate_title` filter, so assert
|
|
|
|
|
# against the head only ("You saved your first personal" is 30 chars,
|
|
|
|
|
# comfortably inside the truncation window).
|
|
|
|
|
self.assertIn("You saved your first personal", body)
|
|
|
|
|
# ts column present
|
|
|
|
|
self.assertRegex(body, r'<time[^>]+class="[^"]*row-ts')
|
|
|
|
|
|
|
|
|
|
def test_my_scrolls_applet_row_shows_latest_event_and_ts(self):
|
|
|
|
|
room = Room.objects.create(name="StampedRoom", 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/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
self.assertIn("StampedRoom", body)
|
|
|
|
|
# The slot-fill prose mentions the token; we just check the room's
|
|
|
|
|
# scroll row carries a <time> + some body content (event prose)
|
|
|
|
|
self.assertRegex(body, r'<time[^>]+class="[^"]*row-ts')
|
|
|
|
|
|
2026-05-13 00:13:33 -04:00
|
|
|
def test_my_scrolls_applet_row_body_includes_actor_display_name(self):
|
|
|
|
|
"""Latest event prose w.o. the actor name is meaningless — `deposits
|
|
|
|
|
a Carte Blanche` should read `<actor> deposits a Carte Blanche`.
|
|
|
|
|
scroll.html renders actor via a separate `<strong>` adjacent to
|
|
|
|
|
prose; the applet row has a single body cell so we concatenate.
|
|
|
|
|
Scoped to the `.row-body` span (vs. a loose substring match) so
|
|
|
|
|
we don't pass on the Most Recent Scroll applet's actor render
|
|
|
|
|
— which renders the same actor too, separately."""
|
|
|
|
|
actor = User.objects.create(email="stuart@test.io", username="stuart")
|
|
|
|
|
room = Room.objects.create(name="ScrollRoom", owner=self.user)
|
|
|
|
|
record(
|
|
|
|
|
room, GameEvent.SLOT_FILLED, actor=actor,
|
|
|
|
|
slot_number=1, token_type="coin",
|
|
|
|
|
token_display="Coin-on-a-String", renewal_days=7,
|
|
|
|
|
)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
# The `.row-body` cell inside the My Scrolls applet must carry
|
|
|
|
|
# both the actor handle AND the event prose, in that order.
|
|
|
|
|
self.assertRegex(
|
|
|
|
|
body,
|
|
|
|
|
r'<span class="row-body">[^<]*stuart[^<]*deposits a Coin-on-a-String',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_my_scrolls_applet_row_body_no_actor_prefix_for_welcome(self):
|
|
|
|
|
"""Welcome events (actor=None) must not render an empty `<strong></strong>`
|
|
|
|
|
prefix before the prose — same shape the scroll.html template adopted."""
|
|
|
|
|
room = Room.objects.create(name="GreenroomTwo", owner=self.user)
|
|
|
|
|
record(room, GameEvent.ROOM_CREATED)
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
body = response.content.decode()
|
|
|
|
|
self.assertIn("Welcome to GreenroomTwo!", body)
|
|
|
|
|
# No empty <strong> before the welcome line
|
|
|
|
|
self.assertNotRegex(
|
|
|
|
|
body, r'<strong>\s*</strong>\s*Welcome to GreenroomTwo!'
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-24 16:46:46 -04:00
|
|
|
|
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
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
contacts = Applet.objects.get(slug="my-buds")
|
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",
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
"my-buds",
|
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):
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
# First toggle: hide My Buds 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",
|
|
|
|
|
)
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
# Second toggle: hide Most Recent Scroll additionally — My Buds 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
|
buds rename + applet-list shell — Buddies → Buds everywhere (model field, slug, URL, view, DOM, CSS); my_buds.html + my_posts.html share new _applet-list-shell.html partial — vertical-title applet-scroll card; my_posts hosts two side-by-side in landscape, stacked in portrait — TDD
- lyric/0005 RemoveField+AddField (RenameField doesn't rename the implicit M2M through table; field was new in 0004 so no data loss). Lyric.User.buddies → User.buds; related_name added_as_buddy → added_as_bud.
- applets/0007 renames Applet slug my-buddies → my-buds + name 'My Buddies' → 'My Buds'. UI rationale: BILLBUDDIES overflowed the page-header band; in-game term collapses to BILLBUDS.
- billboard/0006 alter Line.Meta.ordering = ('created_at', 'id') — was already in models.py, just generates the corresponding migration (formalizing the ordering decision from the May-8b refactor).
- global rename via sed: buddies → buds, buddy → bud across 16 files (templates, SCSS, JS, ITs, FTs, page object, view code). 4 file renames via git mv: my_buddies.html → my_buds.html, _applet-my-buddies.html → _applet-my-buds.html, _buddy_panel.html → _bud_panel.html, _buddy_add_panel.html → _bud_add_panel.html, _buddy.scss → _bud.scss. Test files renamed too: test_buddies.py → test_buds.py, test_my_buddies.py → test_my_buds.py, test_buddy_btn.py → test_bud_btn.py. core.scss @import 'buddy' → 'bud'.
- new shared partial templates/apps/applets/_partials/_applet-list-shell.html — vertical-rotated <h2> + scrollable <ul> aperture, parameterised via {% include %} so a single page can invoke it more than once. Params: shell_title, shell_items, shell_item_template, shell_list_id, shell_empty.
- my_buds.html: single shell invocation w. add-bud panel below (page_class page-billbuds).
- my_posts.html: two shell invocations (own posts + posts shared with me) inside .applet-list-page--two-up — portrait stacks them; landscape lays side-by-side via @media (orientation: landscape) flex-direction: row (page_class page-billposts).
- SCSS: drop the bottom-anchored .buds-page block; new shared .applet-list-page (extends %billboard-page-base, flex-column + padding) w. .applet-scroll inside (extends %applet-box) and .applet-list inside that (flex: 1, overflow-y: auto). .applet-list-page--two-up flips to row layout in landscape. Body class trio gains page-billposts.
- 841 ITs + 5 my_buds/my_posts 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 23:08:33 -04:00
|
|
|
contacts = Applet.objects.get(slug="my-buds")
|
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)
|
2026-05-12 15:13:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class PostLineRelativeTimestampTest(TestCase):
|
|
|
|
|
"""post.html mirrors scroll.html's bucketed `relative_ts` time rendering:
|
|
|
|
|
same-day Lines show a time; older ones collapse to weekday / month-day /
|
|
|
|
|
month-day-year. Bypasses `auto_now_add` with a queryset .update() so the
|
|
|
|
|
test can backdate Lines."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.owner = User.objects.create(email="owner@post-ts.io", username="owner")
|
|
|
|
|
self.client.force_login(self.owner)
|
|
|
|
|
from apps.billboard.models import Line, Post
|
|
|
|
|
self.Line = Line
|
|
|
|
|
self.post = Post.objects.create(owner=self.owner, title="Stamp")
|
|
|
|
|
|
|
|
|
|
def _backdate(self, line, **delta):
|
|
|
|
|
from apps.billboard.models import Line
|
|
|
|
|
Line.objects.filter(pk=line.pk).update(
|
|
|
|
|
created_at=timezone.now() - timezone.timedelta(**delta)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_recent_line_renders_clock_time(self):
|
|
|
|
|
self.Line.objects.create(post=self.post, text="now", author=self.owner)
|
|
|
|
|
response = self.client.get(reverse("billboard:view_post", args=[self.post.id]))
|
|
|
|
|
self.assertRegex(
|
|
|
|
|
response.content.decode(),
|
|
|
|
|
r'class="post-line-time"[^>]*>\s*\d+:\d{2}\s*[ap]\.m\.\s*<',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_two_day_old_line_renders_weekday(self):
|
|
|
|
|
line = self.Line.objects.create(post=self.post, text="old", author=self.owner)
|
|
|
|
|
self._backdate(line, days=2)
|
|
|
|
|
response = self.client.get(reverse("billboard:view_post", args=[self.post.id]))
|
|
|
|
|
import re
|
|
|
|
|
m = re.search(
|
|
|
|
|
r'class="post-line-time"[^>]*>\s*(\w+)\s*<', response.content.decode()
|
|
|
|
|
)
|
|
|
|
|
self.assertIsNotNone(m, "no .post-line-time cell rendered")
|
|
|
|
|
self.assertIn(m.group(1), {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"})
|
|
|
|
|
|
|
|
|
|
def test_thirty_day_old_line_renders_day_month(self):
|
|
|
|
|
line = self.Line.objects.create(post=self.post, text="oldr", author=self.owner)
|
|
|
|
|
self._backdate(line, days=30)
|
|
|
|
|
response = self.client.get(reverse("billboard:view_post", args=[self.post.id]))
|
|
|
|
|
self.assertRegex(
|
|
|
|
|
response.content.decode(),
|
|
|
|
|
r'class="post-line-time"[^>]*>\s*\d{2}\s\w{3}\s*<',
|
|
|
|
|
)
|
2026-05-12 22:26:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeletePostViewTest(TestCase):
|
|
|
|
|
"""billboard:delete_post — owner can hard-delete; non-owners are no-op;
|
|
|
|
|
note_unlock Posts are protected (defence-in-depth alongside the menu
|
|
|
|
|
branch that doesn't render DEL on admin-Posts)."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
from apps.billboard.models import Line, Post
|
|
|
|
|
self.Post = Post
|
|
|
|
|
self.owner = User.objects.create(email="del-owner@test.io")
|
|
|
|
|
self.other = User.objects.create(email="del-other@test.io")
|
|
|
|
|
self.post = Post.objects.create(
|
|
|
|
|
owner=self.owner, kind=Post.KIND_USER_POST, title="X",
|
|
|
|
|
)
|
|
|
|
|
Line.objects.create(post=self.post, text="x", author=self.owner)
|
|
|
|
|
|
|
|
|
|
def test_owner_post_redirects_to_my_posts(self):
|
|
|
|
|
self.client.force_login(self.owner)
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:delete_post", args=[self.post.id])
|
|
|
|
|
)
|
|
|
|
|
self.assertRedirects(
|
|
|
|
|
response,
|
|
|
|
|
reverse("billboard:my_posts", args=[self.owner.id]),
|
|
|
|
|
fetch_redirect_response=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_owner_post_deletes_post(self):
|
|
|
|
|
self.client.force_login(self.owner)
|
|
|
|
|
self.client.post(reverse("billboard:delete_post", args=[self.post.id]))
|
|
|
|
|
self.assertFalse(self.Post.objects.filter(id=self.post.id).exists())
|
|
|
|
|
|
|
|
|
|
def test_non_owner_cannot_delete(self):
|
|
|
|
|
self.client.force_login(self.other)
|
|
|
|
|
self.client.post(reverse("billboard:delete_post", args=[self.post.id]))
|
|
|
|
|
self.assertTrue(self.Post.objects.filter(id=self.post.id).exists())
|
|
|
|
|
|
|
|
|
|
def test_get_does_not_delete(self):
|
|
|
|
|
self.client.force_login(self.owner)
|
|
|
|
|
self.client.get(reverse("billboard:delete_post", args=[self.post.id]))
|
|
|
|
|
self.assertTrue(self.Post.objects.filter(id=self.post.id).exists())
|
|
|
|
|
|
|
|
|
|
def test_note_unlock_post_is_protected(self):
|
|
|
|
|
# Even the owner can't DEL a system thread — the gear menu doesn't
|
|
|
|
|
# render DEL for note_unlock, but the view is hardened in case the
|
|
|
|
|
# POST is forged.
|
|
|
|
|
admin_post = self.Post.objects.create(
|
|
|
|
|
owner=self.owner, kind=self.Post.KIND_NOTE_UNLOCK, title="Notes",
|
|
|
|
|
)
|
|
|
|
|
self.client.force_login(self.owner)
|
|
|
|
|
self.client.post(reverse("billboard:delete_post", args=[admin_post.id]))
|
|
|
|
|
self.assertTrue(self.Post.objects.filter(id=admin_post.id).exists())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AbandonPostViewTest(TestCase):
|
|
|
|
|
"""billboard:abandon_post — invitee removes themselves from
|
|
|
|
|
post.shared_with; owner unaffected; other invitees unaffected; admin
|
|
|
|
|
Posts protected from BYE."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
from apps.billboard.models import Line, Post
|
|
|
|
|
self.Post = Post
|
|
|
|
|
self.owner = User.objects.create(email="abandon-owner@test.io")
|
|
|
|
|
self.invitee = User.objects.create(email="abandon-invitee@test.io")
|
|
|
|
|
self.other = User.objects.create(email="abandon-other@test.io")
|
|
|
|
|
self.post = Post.objects.create(
|
|
|
|
|
owner=self.owner, kind=Post.KIND_USER_POST, title="Shared",
|
|
|
|
|
)
|
|
|
|
|
Line.objects.create(post=self.post, text="x", author=self.owner)
|
|
|
|
|
self.post.shared_with.add(self.invitee, self.other)
|
|
|
|
|
|
|
|
|
|
def test_invitee_redirects_to_my_posts(self):
|
|
|
|
|
self.client.force_login(self.invitee)
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:abandon_post", args=[self.post.id])
|
|
|
|
|
)
|
|
|
|
|
self.assertRedirects(
|
|
|
|
|
response,
|
|
|
|
|
reverse("billboard:my_posts", args=[self.invitee.id]),
|
|
|
|
|
fetch_redirect_response=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_invitee_is_removed_from_shared_with(self):
|
|
|
|
|
self.client.force_login(self.invitee)
|
|
|
|
|
self.client.post(reverse("billboard:abandon_post", args=[self.post.id]))
|
|
|
|
|
self.post.refresh_from_db()
|
|
|
|
|
self.assertNotIn(self.invitee, self.post.shared_with.all())
|
|
|
|
|
|
|
|
|
|
def test_post_survives_invitee_abandonment(self):
|
|
|
|
|
self.client.force_login(self.invitee)
|
|
|
|
|
self.client.post(reverse("billboard:abandon_post", args=[self.post.id]))
|
|
|
|
|
self.post.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.post.owner, self.owner)
|
|
|
|
|
self.assertIn(self.other, self.post.shared_with.all())
|
|
|
|
|
|
|
|
|
|
def test_get_does_not_remove(self):
|
|
|
|
|
self.client.force_login(self.invitee)
|
|
|
|
|
self.client.get(reverse("billboard:abandon_post", args=[self.post.id]))
|
|
|
|
|
self.post.refresh_from_db()
|
|
|
|
|
self.assertIn(self.invitee, self.post.shared_with.all())
|
|
|
|
|
|
|
|
|
|
def test_non_invitee_post_is_no_op(self):
|
|
|
|
|
random_user = User.objects.create(email="random@test.io")
|
|
|
|
|
self.client.force_login(random_user)
|
|
|
|
|
self.client.post(reverse("billboard:abandon_post", args=[self.post.id]))
|
|
|
|
|
self.post.refresh_from_db()
|
|
|
|
|
self.assertIn(self.invitee, self.post.shared_with.all())
|
|
|
|
|
self.assertIn(self.other, self.post.shared_with.all())
|
|
|
|
|
|
|
|
|
|
def test_note_unlock_post_is_protected(self):
|
|
|
|
|
# Admin Posts have no recipients to begin with, but harden the view
|
|
|
|
|
# so a forged BYE can't strip shared_with anyway.
|
|
|
|
|
admin_post = self.Post.objects.create(
|
|
|
|
|
owner=self.owner, kind=self.Post.KIND_NOTE_UNLOCK, title="Notes",
|
|
|
|
|
)
|
|
|
|
|
admin_post.shared_with.add(self.invitee)
|
|
|
|
|
self.client.force_login(self.invitee)
|
|
|
|
|
self.client.post(reverse("billboard:abandon_post", args=[admin_post.id]))
|
|
|
|
|
admin_post.refresh_from_db()
|
|
|
|
|
self.assertIn(self.invitee, admin_post.shared_with.all())
|
2026-05-12 22:48:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnonymousPostViewerTest(TestCase):
|
|
|
|
|
"""view_post has no @login_required (Percival ch.18 anonymous-post lab —
|
|
|
|
|
ownerless Posts are viewable by anyone). The gear menu's NVM target
|
|
|
|
|
reverses `my_posts user_id=request.user.id`, which previously exploded
|
|
|
|
|
w. NoReverseMatch when request.user.id was None (anonymous user).
|
|
|
|
|
Gear menu must be gated on is_authenticated; the post body still renders
|
|
|
|
|
for anonymous viewers of ownerless posts."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
from apps.billboard.models import Post
|
|
|
|
|
# Ownerless Post — matches the Percival anonymous-share contract
|
|
|
|
|
# exercised by apps.dashboard.tests.integrated.test_views.SharePostTest.
|
|
|
|
|
# No Line needed; the empty post still exercises the template render.
|
|
|
|
|
self.post = Post.objects.create(title="Public-ish")
|
|
|
|
|
|
|
|
|
|
def test_anonymous_can_view_ownerless_post_without_500(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
reverse("billboard:view_post", args=[self.post.id])
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
def test_anonymous_gets_no_gear_menu(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
reverse("billboard:view_post", args=[self.post.id])
|
|
|
|
|
)
|
|
|
|
|
self.assertNotIn(b"id_post_menu", response.content)
|
Game Sign picker @ /billboard/my-sign/ + billboard applet — Sprint 4a of My Sea roadmap — TDD
User scope (per design conv this session): split the room's sig-select responsibility off into a standalone billboard-context "My Significator" applet — branded "Game Sign" on the surface. Same 18-card pile as room sig-select (16 middle arcana + Major 0 & 1 filtered by Note unlocks); polarity collapses to a single FLIP choice (the FLIP btn in the picker carousel toggles User.significator_reversed). Selection persists globally on the User model + propagates to the billboard's Game Sign applet ; **naming convention locked**: "significator" stays at storage (User.significator FK + User.significator_reversed) + room sig-select context (DRY w. existing template/JS); "Sign" / "Game Sign" is the billboard-surface branding (file my_sign.html, URL /billboard/my-sign/, URL names my_sign + save_sign, applet name "Game Sign", page wordmark "Game Sign", btn label SAVE SIGN). Action URLs don't carry a trailing slash per project convention (/billboard/my-sign/save vs the page's /billboard/my-sign/) ; **schema**: User gains 2 fields — `significator: FK → epic.TarotCard (nullable, on_delete=SET_NULL)` + `significator_reversed: BooleanField(default=False)`. Migration lyric/0006_user_significator_user_significator_reversed.py auto-generated; reversible. Applet seed in applets/0009_seed_my_sig_applet.py adds the row (slug='my-sign', name='Game Sign', context='billboard', default_visible=True, grid_cols=4, grid_rows=6), idempotent update_or_create, reversible unseed() ; **picker page** (my_sign.html): solo lift of `_sig_select_overlay.html` — sig-stage-card scaffold + sig-stat-block + 18-card grid + SAVE SIGN form. Stripped: countdown / WebSocket / polarity / multi-user / reservations. Empty-state branch covers no-equipped-deck (link back to Game Kit; full Brief-redirect + Earthman-Backup fallback deferred to a follow-up sub-sprint). Minimal inline JS: click .sig-card → mark .sig-focused + set hidden card_id + enable SAVE SIGN; FLIP btn toggles .is-reversed + the hidden reversed input. Stage-card preview (name/qualifier population + keyword swap on FLIP) deferred — Sprint 4a follow-up will lift stage-card.js's populator into a non-room context ; **applet partial** (_applet-my-sign.html): renders user.significator's corner-rank + suit-icon + name_title if set; `.my-sign-applet-empty` "No sign chosen yet." otherwise. Header `<h2><a href="{% url 'billboard:my_sign' %}">Game Sign</a></h2>` links to the picker ; **helper refactor** (epic/models.py): extracted `_sig_unique_cards_for_deck(deck_variant)` from `_sig_unique_cards(room)`. New public `personal_sig_cards(user)` parallels `levity_sig_cards / gravity_sig_cards` but pulls from `user.equipped_deck` instead of `room.deck_variant`. Same Note-unlock filtering. No behavior change to existing room callers (3-line wrapper preserves the room signature) ; **TDD trail** — user called out mid-sprint that I'd skipped FTs; pivoted to FT-first. test_bill_my_sign.py (new, 3 FTs): T1 picker renders w. wordmark + target card present in grid; T2 click card → SAVE SIGN enables → POST persists → applet shows the card; T3 fresh user → applet renders empty-state. Initial reds — (a) setUp's `personal_sig_cards(user)` returned [] because StaticLiveServerTestCase → TransactionTestCase flushes migration-seeded DeckVariant + TarotCard between tests; fixed w. `serialized_rollback = True` on the test class (per [[feedback_transactiontestcase_flush]]); (b) h2 wordmark assertion against `MYSIGNIFICATOR` failed against the renamed "Game Sign" + the letter-splitter spreading chars across <span> children — switched to whitespace-stripped substring check `GAMESIGN`; (c) `.fan-corner-rank` text is CSS-hidden so Selenium returns "" — replaced corner-rank assertions w. data-card-id selectors (already-proven reliable from the parent .sig-card lookup) ; ITs (+12, in apps.billboard.tests.integrated.test_views): MySignViewTest (6 — login redirect, 200 + template, 16-card pile, save persists, invalid card_id → 403, GET save redirects); BillboardAppletMySignTest (3 — applet rendered, empty-state w/o sig, card+reversed class w. sig). PersonalSigCardsTest in apps.epic.tests.integrated.test_models (3 — happy path 16 cards, no-equipped-deck → [], schizo Note unlocks Major 1) ; pre-existing change picked up by the commit: my_sea.html branding "Game Sea" (user-modified mid-session; was "My Sea" in Sprint 3 — divergence captured in MEMORY.md follow-up) ; 1020 IT/UT green (+12) in 46s; 3 FTs green in 24s. Sprint 4a unblocks Sprint 4b (My Sea gating w. --terUser link to /billboard/my-sign/) + Sprint 4c (FT helper for mocking the sig choice across other FTs)
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 22:23:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class MySignViewTest(TestCase):
|
|
|
|
|
"""Game Sign picker view at /billboard/my-sign/ — Sprint 4a of
|
|
|
|
|
[[project-my-sea-roadmap]]. Pins the GET render + POST save contract."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="sign@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
_seed_billboard_applets()
|
|
|
|
|
|
|
|
|
|
def test_my_sign_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.get(reverse("billboard:my_sign"))
|
|
|
|
|
self.assertRedirects(
|
|
|
|
|
response, "/?next=/billboard/my-sign/", fetch_redirect_response=False,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_my_sign_renders_200(self):
|
|
|
|
|
response = self.client.get(reverse("billboard:my_sign"))
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertTemplateUsed(response, "apps/billboard/my_sign.html")
|
|
|
|
|
|
|
|
|
|
def test_my_sign_passes_18_card_pile_for_user_w_no_notes(self):
|
|
|
|
|
# The signal auto-equips Earthman; personal_sig_cards returns 16
|
|
|
|
|
# middle arcana courts (Majors 0/1 filtered out w.o Schizo/Nomad).
|
|
|
|
|
response = self.client.get(reverse("billboard:my_sign"))
|
|
|
|
|
self.assertEqual(len(response.context["cards"]), 16)
|
|
|
|
|
|
|
|
|
|
def test_save_sign_persists_card_and_reversed_flag(self):
|
|
|
|
|
from apps.epic.models import personal_sig_cards
|
|
|
|
|
target = personal_sig_cards(self.user)[0]
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:save_sign"),
|
|
|
|
|
{"card_id": target.id, "reversed": "1"},
|
|
|
|
|
)
|
|
|
|
|
self.assertRedirects(response, reverse("billboard:my_sign"))
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.user.significator_id, target.id)
|
|
|
|
|
self.assertTrue(self.user.significator_reversed)
|
|
|
|
|
|
|
|
|
|
def test_save_sign_rejects_invalid_card_id(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
reverse("billboard:save_sign"),
|
|
|
|
|
{"card_id": 999999, "reversed": "0"},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 403)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertIsNone(self.user.significator_id)
|
|
|
|
|
|
|
|
|
|
def test_save_sign_get_redirects_back_to_picker(self):
|
|
|
|
|
response = self.client.get(reverse("billboard:save_sign"))
|
|
|
|
|
self.assertRedirects(response, reverse("billboard:my_sign"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BillboardAppletMySignTest(TestCase):
|
|
|
|
|
"""My Sign applet rendering on /billboard/."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="apllet@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
_seed_billboard_applets()
|
|
|
|
|
|
|
|
|
|
def test_billboard_shows_my_sign_applet(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertContains(response, 'id="id_applet_my_sign"')
|
|
|
|
|
|
|
|
|
|
def test_my_sign_applet_renders_empty_state_when_no_sig(self):
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertContains(response, "my-sign-applet-empty")
|
|
|
|
|
self.assertContains(response, "No sign chosen yet.")
|
|
|
|
|
self.assertNotContains(response, "my-sign-applet-card")
|
|
|
|
|
|
|
|
|
|
def test_my_sign_applet_renders_card_when_sig_set(self):
|
|
|
|
|
from apps.epic.models import personal_sig_cards
|
|
|
|
|
target = personal_sig_cards(self.user)[0]
|
|
|
|
|
self.user.significator = target
|
|
|
|
|
self.user.significator_reversed = True
|
|
|
|
|
self.user.save(update_fields=["significator", "significator_reversed"])
|
|
|
|
|
response = self.client.get("/billboard/")
|
|
|
|
|
self.assertContains(response, "my-sign-applet-card")
|
|
|
|
|
self.assertContains(response, f'data-card-id="{target.id}"')
|
|
|
|
|
# significator_reversed = True → card carries stage-card--reversed class
|
|
|
|
|
self.assertContains(response, "stage-card--reversed")
|