Files
website/app/internal/gallery/media_test.go
Jimmy 3f5235daaf Improve gallery video UX and add upload-to-publish media workflow.
Stage raw files in upload/, publish with make sync-media/publish, and polish the lightbox: autoplay, remembered volume, Escape to close, and image/video icons without poster or caption clutter.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 23:55:43 +12:00

54 lines
1.2 KiB
Go

package gallery
import (
"os"
"path/filepath"
"testing"
)
func TestVideoPosterRel(t *testing.T) {
if got := videoPosterRel("portal/clip.mp4"); got != "portal/clip.jpg" {
t.Fatalf("got %q", got)
}
}
func TestIsWebDerivative(t *testing.T) {
if !isWebDerivative("clip.web.mp4") {
t.Fatal("expected web derivative")
}
if isGalleryMedia("clip.web.mp4") {
t.Fatal("web derivative must not be listed")
}
}
func TestList_includesVideo(t *testing.T) {
dir := t.TempDir()
album := filepath.Join(dir, "portal")
if err := os.MkdirAll(album, 0o755); err != nil {
t.Fatal(err)
}
name := "showreel.mp4"
if err := os.WriteFile(filepath.Join(album, name), []byte("fake"), 0o644); err != nil {
t.Fatal(err)
}
images, err := List(dir)
if err != nil {
t.Fatal(err)
}
if len(images) != 1 || !images[0].IsVideo || images[0].RelPath != "portal/"+name {
t.Fatalf("got %+v", images)
}
}
func TestSelectHero_skipsVideo(t *testing.T) {
images := []Image{
{RelPath: "portal/showreel.mp4", IsVideo: true},
{RelPath: "portal/photo.jpg", IsVideo: false},
}
hero, ok := SelectHero(images)
if !ok || hero.RelPath != "portal/photo.jpg" {
t.Fatalf("got %+v ok=%v", hero, ok)
}
}