- Replace nav inline newsletter form with Subscribe CTA link per wireframe - Remove newsletter form from footer; add Connect section with social/RSS links - Fix honeypot inputs using hidden attribute (inline style blocked by CSP) - Add available_tags to HomePage.get_context for Explore Topics section - Add data-comment-form attribute to main comment form for reliable locating - Seed approved comment in E2E content for reply flow testing - Expand test_comments.py: moderation message, not-immediately-visible, missing fields, reply form visible, reply submission - Make COMMENT_RATE_LIMIT_PER_MINUTE configurable; set 100 in dev to prevent E2E test exhaustion; update rate limit unit test with override_settings - Update newsletter/home E2E tests to reflect nav form removal - Update unit test to assert no nav/footer newsletter forms Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""E2E tests for the home page."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
|
|
import pytest
|
|
from playwright.sync_api import Page, expect
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_homepage_title_contains_brand(page: Page, base_url: str) -> None:
|
|
page.goto(f"{base_url}/", wait_until="networkidle")
|
|
expect(page).to_have_title(re.compile("No Hype AI"))
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_nav_links_present(page: Page, base_url: str) -> None:
|
|
page.goto(f"{base_url}/", wait_until="networkidle")
|
|
nav = page.locator("nav")
|
|
expect(nav.get_by_role("link", name="Home")).to_be_visible()
|
|
expect(nav.get_by_role("link", name="Articles")).to_be_visible()
|
|
expect(nav.get_by_role("link", name="About")).to_be_visible()
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_theme_toggle_adds_dark_class(page: Page, base_url: str) -> None:
|
|
page.goto(f"{base_url}/", wait_until="networkidle")
|
|
toggle = page.get_by_role("button", name="Toggle theme")
|
|
expect(toggle).to_be_visible()
|
|
# Initial state: html may or may not have dark class
|
|
html = page.locator("html")
|
|
before = "dark" in (html.get_attribute("class") or "")
|
|
toggle.click()
|
|
after = "dark" in (html.get_attribute("class") or "")
|
|
assert before != after, "Theme toggle must flip the dark class on <html>"
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_nav_subscribe_cta_present(page: Page, base_url: str) -> None:
|
|
page.goto(f"{base_url}/", wait_until="networkidle")
|
|
nav = page.locator("nav")
|
|
# Nav has a Subscribe CTA link (not a form — wireframe spec)
|
|
expect(nav.get_by_role("link", name="Subscribe")).to_be_visible()
|
|
|
|
|
|
@pytest.mark.e2e
|
|
def test_home_shows_articles(page: Page, base_url: str) -> None:
|
|
"""Latest articles section is populated after seeding."""
|
|
page.goto(f"{base_url}/", wait_until="networkidle")
|
|
# Seeded content means there should be at least one article card link
|
|
article_links = page.locator("main article a")
|
|
expect(article_links.first).to_be_visible()
|