forked from retoor/devplacepy
fix: correct spelling of "Update" in commit message to "Update"
This commit is contained in:
+19
-15
@@ -10,22 +10,24 @@ from devplacepy.utils import make_combined_slug
|
||||
|
||||
|
||||
def _seed_posts(count):
|
||||
owner = str(uuid4())
|
||||
topic = f"pag{owner[:8]}"
|
||||
get_table("users").insert(
|
||||
{
|
||||
"uid": owner,
|
||||
"username": f"pag_{owner[:8]}",
|
||||
"email": f"{owner[:8]}@test.devplace",
|
||||
"password_hash": "x",
|
||||
"role": "Member",
|
||||
"is_active": True,
|
||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
)
|
||||
base = datetime(2026, 1, 1, tzinfo=timezone.utc)
|
||||
suite = uuid4().hex[:8]
|
||||
topic = f"pag{suite}"
|
||||
users = get_table("users")
|
||||
posts = get_table("posts")
|
||||
base = datetime(2026, 1, 1, tzinfo=timezone.utc)
|
||||
for i in range(count):
|
||||
owner = str(uuid4())
|
||||
users.insert(
|
||||
{
|
||||
"uid": owner,
|
||||
"username": f"pag_{suite}_{i}",
|
||||
"email": f"{suite}_{i}@test.devplace",
|
||||
"password_hash": "x",
|
||||
"role": "Member",
|
||||
"is_active": True,
|
||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
)
|
||||
uid = str(uuid4())
|
||||
content = f"Paginated post {i}"
|
||||
posts.insert(
|
||||
@@ -40,6 +42,8 @@ def _seed_posts(count):
|
||||
"image": None,
|
||||
"stars": 0,
|
||||
"created_at": (base - timedelta(seconds=i)).isoformat(),
|
||||
"deleted_at": None,
|
||||
"deleted_by": None,
|
||||
}
|
||||
)
|
||||
return topic
|
||||
@@ -244,7 +248,7 @@ def test_feed_topnav_navigation(alice):
|
||||
page.click("a:has-text('Projects')")
|
||||
page.wait_for_url(f"{BASE_URL}/projects", wait_until="domcontentloaded")
|
||||
page.click("a:has-text('Home')")
|
||||
page.wait_for_url(f"{BASE_URL}/feed", wait_until="domcontentloaded")
|
||||
page.wait_for_url(f"{BASE_URL}/", wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def test_topnav_notification_bell(alice):
|
||||
|
||||
+38
-4
@@ -66,10 +66,10 @@ def test_landing_log_in_link(page, app_server):
|
||||
page.wait_for_url(f"{BASE_URL}/auth/login", wait_until="domcontentloaded")
|
||||
|
||||
|
||||
def test_landing_authenticated_redirects_to_feed(page, app_server):
|
||||
def test_landing_authenticated_shows_dashboard(page, app_server):
|
||||
page.goto(f"{BASE_URL}/auth/signup", wait_until="domcontentloaded")
|
||||
page.fill("#username", "redirect_user")
|
||||
page.fill("#email", "redirect@test.devplace")
|
||||
page.fill("#username", "home_user")
|
||||
page.fill("#email", "home@test.devplace")
|
||||
page.fill("#password", "secret123")
|
||||
page.fill("#confirm_password", "secret123")
|
||||
with page.expect_navigation(timeout=10000):
|
||||
@@ -77,7 +77,13 @@ def test_landing_authenticated_redirects_to_feed(page, app_server):
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
|
||||
page.goto(f"{BASE_URL}/", wait_until="domcontentloaded")
|
||||
page.wait_for_url("**/feed", timeout=10000, wait_until="domcontentloaded")
|
||||
assert page.url.rstrip("/") == BASE_URL.rstrip("/")
|
||||
assert page.is_visible("text=Welcome back")
|
||||
assert page.is_visible("text=home_user")
|
||||
feed_cta = page.locator("a.landing-cta:has-text('Go to your feed')")
|
||||
assert feed_cta.is_visible()
|
||||
assert feed_cta.get_attribute("href") == "/feed"
|
||||
assert not page.is_visible("text=Join DevPlace Free")
|
||||
|
||||
|
||||
def test_landing_footer_links(page, app_server):
|
||||
@@ -112,3 +118,31 @@ def test_landing_news_section(page, app_server):
|
||||
page.locator("text=Developer News").wait_for(state="visible", timeout=5000)
|
||||
cards = page.locator(".news-card-title a")
|
||||
assert cards.count() > 0, "No news articles visible on landing page"
|
||||
|
||||
|
||||
def test_diversify_by_author_caps_per_author():
|
||||
from devplacepy.database import diversify_by_author
|
||||
|
||||
rows = [
|
||||
{"uid": 1, "user_uid": "a"},
|
||||
{"uid": 2, "user_uid": "a"},
|
||||
{"uid": 3, "user_uid": "a"},
|
||||
{"uid": 4, "user_uid": "b"},
|
||||
{"uid": 5, "user_uid": "a"},
|
||||
{"uid": 6, "user_uid": "c"},
|
||||
]
|
||||
kept = diversify_by_author(rows, max_per_author=2, limit=6)
|
||||
authors = [r["user_uid"] for r in kept]
|
||||
assert authors.count("a") == 2
|
||||
assert authors.count("b") == 1
|
||||
assert authors.count("c") == 1
|
||||
assert [r["uid"] for r in kept] == [1, 2, 4, 6]
|
||||
|
||||
|
||||
def test_diversify_by_author_respects_limit():
|
||||
from devplacepy.database import diversify_by_author
|
||||
|
||||
rows = [{"uid": i, "user_uid": str(i)} for i in range(10)]
|
||||
kept = diversify_by_author(rows, max_per_author=2, limit=3)
|
||||
assert len(kept) == 3
|
||||
assert [r["uid"] for r in kept] == [0, 1, 2]
|
||||
|
||||
Reference in New Issue
Block a user