feat(splash): load latest chat message
Docker Image / Build and Push Docker Image (push) Has been cancelled

This commit is contained in:
2026-07-08 17:31:58 +08:00
parent 75aa084095
commit baf0deeb24
7 changed files with 268 additions and 4 deletions
@@ -0,0 +1,67 @@
import { describe, expect, it } from "vitest";
import { getSplashLatestMessagePreview } from "@/lib/chat/splash_latest_message_preview";
describe("getSplashLatestMessagePreview", () => {
it("uses text content for text messages", () => {
expect(
getSplashLatestMessagePreview({
type: "text",
content: " Come closer? ",
audioUrl: null,
image: { type: null, url: null },
}),
).toBe("Come closer?");
});
it("uses image placeholder for image messages", () => {
expect(
getSplashLatestMessagePreview({
type: "image",
content: "",
image: { type: "elio_schedule", url: null },
}),
).toBe("[图片]");
});
it("uses image placeholder when the image url exists", () => {
expect(
getSplashLatestMessagePreview({
type: "text",
content: "",
image: { type: null, url: "https://example.com/image.jpg" },
}),
).toBe("[图片]");
});
it("uses voice placeholder for voice messages", () => {
expect(
getSplashLatestMessagePreview({
type: "audio",
content: "",
audioUrl: "https://example.com/voice.mp3",
}),
).toBe("[语音]");
});
it("uses voice placeholder for locked voice messages", () => {
expect(
getSplashLatestMessagePreview({
type: "text",
content: "",
lockDetail: { reason: "voice_message" },
}),
).toBe("[语音]");
});
it("falls back when the latest message has no displayable content", () => {
expect(
getSplashLatestMessagePreview({
type: "text",
content: " ",
image: { type: null, url: null },
audioUrl: null,
}),
).toBe("[消息]");
});
});