feat: add seed helpers for gist, news, and project comment hierarchies in e2e tests
DevPlace CI / test (push) Failing after 23m2s
DevPlace CI / test (push) Failing after 23m2s
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:
@@ -863,3 +863,72 @@ def test_detail_download_button_downloads(app_server, page):
|
||||
assert dl_info.value.suggested_filename.endswith(".zip")
|
||||
finally:
|
||||
_cleanup_archives()
|
||||
|
||||
|
||||
def _seed_project_with_comments():
|
||||
owner = str(uuid4())
|
||||
get_table("users").insert(
|
||||
{
|
||||
"uid": owner,
|
||||
"username": f"pcseed_{owner[:8]}",
|
||||
"email": f"{owner[:8]}@pc.seed",
|
||||
"password_hash": "x",
|
||||
"role": "Member",
|
||||
"is_active": True,
|
||||
"created_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
)
|
||||
uid = str(uuid4())
|
||||
marker = f"projcom-{uid[:8]}"
|
||||
get_table("projects").insert(
|
||||
{
|
||||
"deleted_at": None,
|
||||
"deleted_by": None,
|
||||
"uid": uid,
|
||||
"user_uid": owner,
|
||||
"slug": make_combined_slug(marker, uid),
|
||||
"title": marker,
|
||||
"description": "Project with comment hierarchy.",
|
||||
"project_type": "software",
|
||||
"platforms": "Linux",
|
||||
"status": "Released",
|
||||
"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": "project",
|
||||
"target_uid": uid,
|
||||
"user_uid": owner,
|
||||
"content": content,
|
||||
"parent_uid": par,
|
||||
"created_at": (base + timedelta(seconds=off)).isoformat(),
|
||||
}
|
||||
)
|
||||
return marker
|
||||
|
||||
|
||||
def test_projects_list_preserves_comment_hierarchy(page, app_server):
|
||||
marker = _seed_project_with_comments()
|
||||
page.goto(f"{BASE_URL}/projects", wait_until="domcontentloaded")
|
||||
card = page.locator(".project-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")
|
||||
|
||||
Reference in New Issue
Block a user