feat: add seed helpers for gist, news, and project comment hierarchies in e2e tests

Introduce `_seed_gist_with_comments`, `_seed_news_with_comments`, and `_seed_project_with_comments` helper functions that create a user, a parent entity, and four comments (excluded, flat, parent, reply) with a shared marker prefix and timestamps, enabling consistent comment tree seeding across test modules.
This commit is contained in:
2026-06-16 04:06:16 +00:00
parent 15bd4ad87c
commit 1934dd5727
3 changed files with 210 additions and 0 deletions
+68
View File
@@ -400,3 +400,71 @@ def test_create_large_gist_via_ui_saves(alice, app_server):
saved = get_table("gists").find_one(title=title)
assert saved is not None
assert len(saved["source_code"]) > DPBOT_SIZE // 2
def _seed_gist_with_comments():
owner = str(uuid4())
get_table("users").insert(
{
"uid": owner,
"username": f"gcseed_{owner[:8]}",
"email": f"{owner[:8]}@gc.seed",
"password_hash": "x",
"role": "Member",
"is_active": True,
"created_at": datetime.now(timezone.utc).isoformat(),
}
)
uid = str(uuid4())
marker = f"gistcom-{uid[:8]}"
get_table("gists").insert(
{
"deleted_at": None,
"deleted_by": None,
"uid": uid,
"user_uid": owner,
"slug": make_combined_slug(marker, uid),
"title": marker,
"description": "Gist with comment hierarchy.",
"source_code": "print('x')",
"language": "python",
"stars": 0,
"created_at": datetime.now(timezone.utc).isoformat(),
}
)
parent = str(uuid4())
base = datetime.now(timezone.utc)
rows = [
(f"{marker}-excluded", str(uuid4()), None, -2),
(f"{marker}-flat", str(uuid4()), None, -1),
(f"{marker}-parent", parent, None, 0),
(f"{marker}-reply", str(uuid4()), parent, 1),
]
comments = get_table("comments")
for content, cuid, par, off in rows:
comments.insert(
{
"deleted_at": None,
"deleted_by": None,
"uid": cuid,
"target_type": "gist",
"target_uid": uid,
"user_uid": owner,
"content": content,
"parent_uid": par,
"created_at": (base + timedelta(seconds=off)).isoformat(),
}
)
return marker
def test_gists_list_preserves_comment_hierarchy(page, app_server):
marker = _seed_gist_with_comments()
page.goto(f"{BASE_URL}/gists", wait_until="domcontentloaded")
card = page.locator(".gist-card").filter(has_text=marker).first
card.wait_for(state="visible")
previews = card.locator(".post-card-comments .comment-text")
expect(previews).to_have_count(3)
expect(card.locator(".post-card-comments")).not_to_contain_text(f"{marker}-excluded")
nested = card.locator(".post-card-comments .comment-replies .comment-text")
expect(nested).to_contain_text(f"{marker}-reply")