post aperture refactor (May-8b): Post.title field; Line.author PROTECT FK + created_at; Note.grant_if_new admin-vs-Look! format dispatch w. note-ref anchor; bottom-anchored aperture w. shared-between header + per-Line user/timestamp; dotted-? Brief square; reserved adman seed — TDD
- schema: billboard/0004 adds Post.title (CharField 35) + Line.author (PROTECT FK, related_name=authored_lines) + Line.created_at (auto_now_add); RunPython backfill stamps existing rows (note_unlock → "Notes & recognitions" + author=adman; user_post → first-line glean + author=Post.owner).
- lyric/0003 seeds adman User (system author for note unlock + share invite Lines); apps.lyric.models gains RESERVED_USERNAMES = {"adman"}, is_reserved_username() guard in dashboard.set_profile, get_or_create_adman() lazy fetch (TransactionTestCase flushes the seed).
- drama: Note.grant_if_new dispatches via _ADMIN_NOTE_SLUGS = {"super-schizo","super-nomad"} — admin slugs use "The administration recognizes…" prose; everyone else uses "Look!—new Note unlocked." Both wrap Note name in `<a class="note-ref">`. Header Line dropped (test_two_different_grants_share_one_post asserts 2 lines, not 3). Note.display_name property added (slug.title() default — "super-schizo" → "Super-Schizo"). User.active_title_display returns donned recognition title or "Earthman" default.
- billboard models: Post.name property removed → my_posts.html, _applet-my-posts.html, PostSerializer switched to Post.title. LineForm.save(for_post, author) + ExistingPostLineForm.save(author) signature + all callers (api.views, billboard.views.new_post + view_post + share_post). billboard.views.share_post authors via get_or_create_adman; new_post truncates first line for Post.title via _truncate_post_title.
- post.html: <h3> post title heading; .post-shared-recipients (commas only) + .post-shared-self lines ("just me, X the Earthman" / "& me, X the Y" 0/≥1 split); #id_post_table is now a <ul> w. justify-content: flex-end + per-Line 3-col grid (author/text/time); adman Lines render |safe + .post-line--system italic; #id_text → #id_post_line_text rename (post.html only — /billboard/ new-post applet keeps #id_text); page_class page-billpost (joins billboard+billscroll body-class trio).
- SCSS _billboard.scss: .post-page extends %billboard-page-base, adds bottom-anchored flex-column scroll + 3-col .post-line grid + .post-line-form pinned at bottom. _note.scss: a.note-banner__image picks up .note-item__image-box dashed-? styling for the Brief square.
- _buddy_panel.html JS rewired for new layout: _appendLine builds <li class="post-line post-line--system"> w. adman+timestamp; _appendRecipientChip handles 0→1+ transition (rewrites "just me," → "& me,", inserts .post-shared-recipients line above self).
- FT post_page.py: get_table_rows queries .post-line; wait_for_row_in_post_table matches by text containment (line_number arg ignored — kept for backwards compat); get_line_input_box probes #id_post_line_text first, falls back to #id_text; get_post_owner reads textContent (hidden span). test_applet_new_post_line_validation switched to input[name="text"]:invalid/:valid for cross-page selectors.
- rootvars.scss: minor plutonium + fuschia tweaks (pre-existing).
- 818 ITs + 35 FTs (buddy/new-post/sharing/validation/layout/jasmine/my-notes/my-posts) green.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,15 +9,30 @@ class PostPage:
|
||||
self.test = test
|
||||
|
||||
def get_table_rows(self):
|
||||
return self.test.browser.find_elements(By.CSS_SELECTOR, "#id_post_table tr")
|
||||
# Post-May08b: #id_post_table is now a <ul> of <li class="post-line">
|
||||
# rows (no <ol> numbering). The CSS selector still works since the
|
||||
# id is preserved.
|
||||
return self.test.browser.find_elements(By.CSS_SELECTOR, "#id_post_table .post-line")
|
||||
|
||||
@wait
|
||||
def wait_for_row_in_post_table(self, line_text, line_number):
|
||||
expected_row_text = f"{line_number}. {line_text}"
|
||||
def wait_for_row_in_post_table(self, line_text, line_number=None):
|
||||
# `line_number` retained for backwards compat with callers that
|
||||
# passed a position counter — ignored now (lines order by created_at,
|
||||
# numbering is gone). Match by text containment instead.
|
||||
rows = self.get_table_rows()
|
||||
self.test.assertIn(expected_row_text, [row.text for row in rows])
|
||||
row_texts = [row.text for row in rows]
|
||||
self.test.assertTrue(
|
||||
any(line_text in t for t in row_texts),
|
||||
f"Line text {line_text!r} not in any row: {row_texts!r}",
|
||||
)
|
||||
|
||||
def get_line_input_box(self):
|
||||
# /billboard/ new-post applet uses #id_text (creates a fresh Post);
|
||||
# post.html aperture uses #id_post_line_text (appends to existing).
|
||||
# `add_post_line` is called from both contexts, so probe in order.
|
||||
boxes = self.test.browser.find_elements(By.ID, "id_post_line_text")
|
||||
if boxes:
|
||||
return boxes[0]
|
||||
return self.test.browser.find_element(By.ID, "id_text")
|
||||
|
||||
def add_post_line(self, line_text):
|
||||
@@ -60,4 +75,8 @@ class PostPage:
|
||||
)
|
||||
|
||||
def get_post_owner(self):
|
||||
return self.test.browser.find_element(By.ID, "id_post_owner").text
|
||||
# `<span id="id_post_owner" hidden>` — Selenium .text returns "" for
|
||||
# hidden elements, so read textContent attribute instead.
|
||||
return self.test.browser.find_element(
|
||||
By.ID, "id_post_owner"
|
||||
).get_attribute("textContent")
|
||||
|
||||
@@ -18,12 +18,12 @@ class LineValidationTest(FunctionalTest):
|
||||
post_page.get_line_input_box().send_keys(Keys.ENTER)
|
||||
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:invalid")
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, 'input[name="text"]:invalid')
|
||||
)
|
||||
|
||||
post_page.get_line_input_box().send_keys("Purchase milk")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:valid")
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, 'input[name="text"]:valid')
|
||||
)
|
||||
|
||||
post_page.get_line_input_box().send_keys(Keys.ENTER)
|
||||
@@ -33,14 +33,14 @@ class LineValidationTest(FunctionalTest):
|
||||
|
||||
post_page.wait_for_row_in_post_table("Purchase milk", 1)
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, "#id_text:invalid")
|
||||
lambda: self.browser.find_element(By.CSS_SELECTOR, 'input[name="text"]:invalid')
|
||||
)
|
||||
|
||||
post_page.get_line_input_box().send_keys("Make tea")
|
||||
self.wait_for(
|
||||
lambda: self.browser.find_element(
|
||||
By.CSS_SELECTOR,
|
||||
"#id_text:valid",
|
||||
'input[name="text"]:valid',
|
||||
)
|
||||
)
|
||||
post_page.get_line_input_box().send_keys(Keys.ENTER)
|
||||
|
||||
@@ -99,8 +99,8 @@ from .base import FunctionalTest
|
||||
|
||||
def _seed_a_post(user):
|
||||
"""Create a Post w. one Line so view_post renders w/o redirect."""
|
||||
p = Post.objects.create(owner=user)
|
||||
Line.objects.create(post=p, text="seed line")
|
||||
p = Post.objects.create(owner=user, title="seed line")
|
||||
Line.objects.create(post=p, text="seed line", author=user)
|
||||
return p
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ class PostHtmlAperturePageClassTest(FunctionalTest):
|
||||
body = self.wait_for(lambda: self.browser.find_element(By.TAG_NAME, "body"))
|
||||
cls = body.get_attribute("class")
|
||||
self.assertTrue(
|
||||
"page-billboard" in cls or "page-post" in cls,
|
||||
"page-billboard" in cls or "page-billpost" in cls,
|
||||
f"post.html body class missing aperture marker: {cls!r}",
|
||||
)
|
||||
|
||||
@@ -376,6 +376,6 @@ class PostHtmlAperturePageClassTest(FunctionalTest):
|
||||
body = self.wait_for(lambda: self.browser.find_element(By.TAG_NAME, "body"))
|
||||
cls = body.get_attribute("class")
|
||||
self.assertTrue(
|
||||
"page-billboard" in cls or "page-post" in cls,
|
||||
"page-billboard" in cls or "page-billpost" in cls,
|
||||
f"my_posts.html body class missing aperture marker: {cls!r}",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user