Forum: thread cards with the start of the opening post, latest threads and pinned threads on the front page
- Every thread card shows the start of the opening post (two lines on a computer, three on a phone), its topic with the icon (a lock for members-only and restricted ones), pinned and the wish; the replies, the last activity and what is new on the right (in the bottom line on a phone). The same card in topics, search and followed threads. - The front page: "Legutóbbi szálak" below the topics, from every topic the viewer may read (not the archived ones), the latest activity first, 20 a page with a pager; pinned threads in "Kitűzve" above the topics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1408,3 +1408,31 @@ async fn any_member_may_upload_an_avatar(pool: PgPool) {
|
||||
assert_eq!(status, StatusCode::FORBIDDEN);
|
||||
assert!(body.to_string().contains("nem érhető el"), "{body}");
|
||||
}
|
||||
|
||||
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||
async fn latest_threads_with_their_beginning(pool: PgPool) {
|
||||
let app = TestApp::new(pool);
|
||||
let anna = app.member("anna@example.com", "Csendesvíz", &["user"]).await;
|
||||
let public = app.thread(&anna, "torzsasztal", "Téli levesek").await;
|
||||
let members = app.thread(&anna, "ami-a-szivemen-van", "Nehéz napok").await;
|
||||
app.reply(&anna, public, "Még egy gondolat.", None).await;
|
||||
let ids =
|
||||
|v: Value| -> Vec<i64> { v["threads"].as_array().unwrap().iter().map(|t| t["id"].as_i64().unwrap()).collect() };
|
||||
// Members see every topic they may read, the latest activity first; visitors the public ones.
|
||||
assert_eq!(ids(app.get("/v1/forum/latest", Some(&anna)).await), vec![public, members]);
|
||||
let visitor = app.get("/v1/forum/latest", None).await;
|
||||
assert_eq!(ids(visitor.clone()), vec![public]);
|
||||
assert_eq!(visitor["has_more"], false);
|
||||
// The card carries the start of the opening post and the topic's visibility.
|
||||
let card = &visitor["threads"][0];
|
||||
assert!(card["excerpt"].as_str().unwrap().len() > 3, "{card}");
|
||||
assert_eq!(card["topic"]["visibility"], "public");
|
||||
|
||||
// A pinned thread stands above the topics on the front page.
|
||||
let admin = app.member("admin@example.com", "Gondnok", &["admin"]).await;
|
||||
let (status, _) =
|
||||
app.call("PATCH", &format!("/v1/forum/threads/{public}"), Some(&admin), json!({ "pinned": true })).await;
|
||||
assert_eq!(status, StatusCode::NO_CONTENT);
|
||||
let home = app.get("/v1/forum/home", None).await;
|
||||
assert_eq!(home["pinned"][0]["id"], public);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user