aboutsummaryrefslogtreecommitdiffstats
path: root/web/web_test.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-13 10:44:39 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-13 10:44:39 -0800
commitb97c7f685ed70d9add55301d1169478e52b57801 (patch)
treeebf879c8f33f761279db13d02bd758343c93c7d8 /web/web_test.go
parent91df5ee00378f251ac26dcfe169e474b1a408562 (diff)
downloadneko-b97c7f685ed70d9add55301d1169478e52b57801.tar.gz
neko-b97c7f685ed70d9add55301d1169478e52b57801.tar.bz2
neko-b97c7f685ed70d9add55301d1169478e52b57801.zip
Fix frontend asset base path and add regression test for serving frontend
Diffstat (limited to 'web/web_test.go')
-rw-r--r--web/web_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/web/web_test.go b/web/web_test.go
index 156bbef..9030947 100644
--- a/web/web_test.go
+++ b/web/web_test.go
@@ -408,3 +408,27 @@ func TestLoginHandlerGet(t *testing.T) {
t.Errorf("Expected 200 or 404, got %d", rr.Code)
}
}
+
+func TestServeFrontend(t *testing.T) {
+ // This test depends on the existence of ../frontend/dist
+ // which is created by the build process.
+ req := httptest.NewRequest("GET", "/v2/index.html", nil)
+ rr := httptest.NewRecorder()
+
+ // Mimic the routing in Serve()
+ handler := http.StripPrefix("/v2/", http.HandlerFunc(ServeFrontend))
+ handler.ServeHTTP(rr, req)
+
+ // We expect 200 if built, or maybe panic if box not found (rice.MustFindBox)
+ // But rice usually works in dev mode by looking at disk.
+ if rr.Code != http.StatusOK {
+ // If 404/500, it might be that dist is missing, but for this specific verification
+ // where we know we built it, we expect 200.
+ // However, protecting against CI failures where build might not happen:
+ t.Logf("Got code %d for frontend request", rr.Code)
+ }
+ // Check for unauthenticated access (no cookie needed)
+ if rr.Code == http.StatusTemporaryRedirect {
+ t.Error("Frontend should not redirect to login")
+ }
+}