14oqjtsnb: Play trending video answers as video with thumbnail fallback

This commit is contained in:
2026-10-19 17:40:44 -06:00
parent 77f0dd09a4
commit 31fdc41f23
6 changed files with 111 additions and 21 deletions
+17 -2
View File
@@ -52,7 +52,7 @@ describe("GET /api/discover", () => {
});
expect(json.trendingMinnects[0]).toEqual({
id: "c1", question: "How?", views: 10, thumbnailUrl: "https://img/t.jpg",
audio: { url: "https://a/1.mp3", duration: 42, waveform: [1, 2, 3] },
media: { kind: "audio", url: "https://a/1.mp3", duration: 42, waveform: [1, 2, 3] },
expert: { slug: "jane-doe", displayName: "Jane Doe", pictureUrl: "https://img/jane.jpg", byline: "Coach", rating: 4.9 },
});
expect(json.categories).toEqual([
@@ -90,7 +90,7 @@ describe("GET /api/discover", () => {
reviewsCount: null, available: null, location: { city: null, country: null },
}]);
expect(out.trendingMinnects).toHaveLength(1);
expect(out.trendingMinnects[0].audio).toEqual({ url: null, duration: null, waveform: null });
expect(out.trendingMinnects[0].media).toBeNull();
expect(out.categories).toEqual([{ id: 3, name: "A", icon: null, sortOrder: 0 }]);
expect(mapDiscover(null)).toEqual({ featuredExperts: [], trendingMinnects: [], categories: [] });
});
@@ -108,3 +108,18 @@ describe("GET /api/discover", () => {
expect(b.res.status).toBe(502);
});
});
describe("trending media kind", () => {
const conv = (answer: unknown) => mapDiscover({ data: { trending_conversations: [{ id: 1, answer }] } }).trendingMinnects[0].media;
it.each(["MOV", "mp4", "M4V", "QuickTime", "MO4", "webm"])("maps %s to video and keeps the signed url", (t) => {
const url = "https://valuentainment-quick-questions-prod.s3.amazonaws.com/a.mov?X-Amz-Signature=abc";
expect(conv({ url, file_type: t, duration: 5 })).toEqual({ kind: "video", url, duration: 5, waveform: null });
});
it("maps other or missing file types to audio", () => {
expect(conv({ url: "https://a/x", file_type: "aac" })?.kind).toBe("audio");
expect(conv({ url: "https://a/x" })?.kind).toBe("audio");
});
it("has no media without a url", () => {
expect(conv({ file_type: "MOV" })).toBeNull();
});
});