Files
python-tdd/src/functional_tests/post_page.py

64 lines
2.1 KiB
Python
Raw Normal View History

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from .base import wait
class PostPage:
def __init__(self, test):
self.test = test
def get_table_rows(self):
return self.test.browser.find_elements(By.CSS_SELECTOR, "#id_post_table tr")
@wait
def wait_for_row_in_post_table(self, line_text, line_number):
expected_row_text = f"{line_number}. {line_text}"
rows = self.get_table_rows()
self.test.assertIn(expected_row_text, [row.text for row in rows])
def get_line_input_box(self):
return self.test.browser.find_element(By.ID, "id_text")
def add_post_line(self, line_text):
new_line_no = len(self.get_table_rows()) + 1
self.get_line_input_box().send_keys(line_text)
self.get_line_input_box().send_keys(Keys.ENTER)
self.wait_for_row_in_post_table(line_text, new_line_no)
return self
def get_share_box(self):
return self.test.browser.find_element(
By.CSS_SELECTOR,
'input[name="recipient"]',
)
def get_shared_with_list(self):
return self.test.browser.find_elements(
By.CSS_SELECTOR,
".post-recipient"
)
def share_post_with(self, email):
buddy btn sprint: banner-anchor + window.Brief fix lands the last red FT — 16/16 buddy + 12 share/jasmine/my_notes + 818 IT regression — TDD Two small fixes close out the OK→banner gap: 1. Anchor over h2: base.html drops <div id="id_brief_banner_anchor"></div> right before {% block content %} (after the messages block). note.js's showBanner now prefers the explicit anchor over the first <h2> — keeps the banner in the visible content flow on pages where the first h2 is position:absolute (post.html's rotated navbar header was the immediate motivator; sky.html's rotated h2 is the same shape, so this catches that pre-emptively too). 2. window.Brief explicit assignment: const Brief = (...) at script-tag scope is reachable as a bare name but does NOT auto-attach to window. The buddy panel's OK handler gates banner reveal on `if (window.Brief && data.brief)` — that gate was always false, so Brief.showBanner never fired on share-OK even though the chip + Line append in DOM proved the fetch.then() was running. Explicit window.Brief = Brief; window.Note = Note; in note.js (post-IIFE) closes the gap. Also picks up the deferred page-object update — functional_tests.post_page.PostPage.share_post_with() now drives the buddy-btn flow (click #id_buddy_btn → type → click #id_buddy_panel .btn.btn-confirm → wait for recipient chip), so legacy SharingTest exercises the new pipeline end-to-end. NoteSpec.js T10 split into T10a/T10b: a covers the anchor-preferred path, b covers the <h2> fallback. 16/16 buddy FTs green (previously 15/16). 12/12 sharing + Jasmine + my_notes FTs green. 818-test IT sweep green. Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 19:14:50 -04:00
# Buddy-btn flow (post-Brief sprint): click bottom-left handshake,
# type the email in the slide-out, click the .btn-confirm OK, wait
# for the recipient chip.
buddy_btn = self.test.browser.find_element(By.ID, "id_buddy_btn")
buddy_btn.click()
recipient = self.test.wait_for(
lambda: self.test.browser.find_element(By.ID, "id_recipient")
)
recipient.send_keys(email)
ok = self.test.browser.find_element(
By.CSS_SELECTOR, "#id_buddy_panel .btn.btn-confirm"
)
ok.click()
self.test.wait_for(
lambda: self.test.assertIn(
email, [item.text for item in self.get_shared_with_list()]
)
)
def get_post_owner(self):
return self.test.browser.find_element(By.ID, "id_post_owner").text