package file

import (
	"strings"
	"testing"
)

func TestSanitizeObjectMetadataEscapesNonASCII(t *testing.T) {
	got := sanitizeObjectMetadata(map[string]string{
		"original-filename": "游戏ID截图 1.png",
	})

	if got["original-filename"] != "%E6%B8%B8%E6%88%8FID%E6%88%AA%E5%9B%BE+1.png" {
		t.Fatalf("metadata filename = %q", got["original-filename"])
	}
}

func TestAnnouncementSceneUsesPublicFileURL(t *testing.T) {
	key := "announcement/2026/06/15/example.webp"
	got := fileURLForScene("announcement", key)

	if !strings.HasPrefix(got, "/api/public/files/object?") {
		t.Fatalf("announcement file url = %q, want public file endpoint", got)
	}
}

func TestNormalizeSceneAllowsAnnouncement(t *testing.T) {
	if got := normalizeScene("announcement"); got != "announcement" {
		t.Fatalf("normalize announcement scene = %q", got)
	}
}
