package e2e import ( "strings" "testing" ) func TestRenderCapsAndNonASCIIPaths(t *testing.T) { e := newEnv(t, "MAX_RENDER_BYTES", "2000") admin := e.admin() e.createRepo(admin, "caps") e.seedRepo("caps", map[string]string{ "README.md": "# small\n", "docs/README.md": strings.Repeat("big readme line\n", 200), }) small := e.seedRepo("caps", map[string]string{ "dir/ä ö.txt": "umlaut\n", "bin/bild ü.bin": "\x00\x01\x02binary", }, "non-ASCII names") t.Run("non-ASCII name links to a working blob", func(t *testing.T) { r := admin.get("/caps/tree/main/dir").mustStatus(200) if got := r.Text(".file-name a[href*='/blob/']"); got != "ä ö.txt" { t.Fatalf("tree name = %q", got) } admin.get(r.Attr(".file-name a[href*='/blob/']", "href")).mustStatus(200) }) t.Run("commit diff shows unquoted paths and binary sizes", func(t *testing.T) { r := admin.get("/caps/commit/" + small).mustStatus(200) if !r.Contains("ä ö.txt") || !r.Contains("bild ü.bin") || r.Contains(`\303`) { t.Fatal("diff paths are missing or C-quoted") } }) t.Run("oversized README shows a download notice", func(t *testing.T) { r := admin.get("/caps/tree/main/docs").mustStatus(200) if !r.Contains("README too large to display inline") || r.Contains("big readme line") { t.Fatal("oversized README was rendered") } if href := r.Attr(".readme-section .file-download-notice a", "href"); href != "/caps/raw/main/docs/README.md" { t.Fatalf("download href = %q", href) } if r := admin.get("/caps").mustStatus(200); !r.Has(".readme-section .markdown-body") { t.Fatal("small root README not rendered") } }) t.Run("oversized commit diff is not rendered", func(t *testing.T) { big := e.seedRepo("caps", map[string]string{"big.txt": strings.Repeat("line\n", 1000)}, "big") r := admin.get("/caps/commit/" + big).mustStatus(200) if !r.Contains("Diff is too large to render inline") || r.Has(".diff-file") { t.Fatal("oversized diff was rendered") } }) }