fix(ui): restore brand across anonymous and error pages
giteabot / giteabot (push) Canceled after 0s
giteabot backport / giteabot (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s

Assisted-by: Codex:GPT-5
This commit is contained in:
2026-08-29 19:14:04 +08:00
parent ab55a432ec
commit 9860c79986
8 changed files with 62 additions and 16 deletions
+22
View File
@@ -25,6 +25,7 @@ func TestView(t *testing.T) {
t.Run("SecurityHeadersDefaults", testSecurityHeadersDefaults)
t.Run("SiteManifest", testSiteManifest)
t.Run("CurrentURL", testViewPageCurrentURL)
t.Run("NavbarBrandVisibility", testNavbarBrandVisibility)
}
func testRenderFileSVGIsInImgTag(t *testing.T) {
@@ -129,3 +130,24 @@ func testViewPageCurrentURL(t *testing.T) {
MakeRequest(t, NewRequest(t, "GET", "/any-page?k=v"), http.StatusNotFound)
assert.Equal(t, "/subpath/any-page?k=v", currentURL)
}
func testNavbarBrandVisibility(t *testing.T) {
assertBrand := func(t *testing.T, session *TestSession, uri string, status int, visible bool) {
t.Helper()
resp := session.MakeRequest(t, NewRequest(t, "GET", uri), status)
doc := NewHTMLParser(t, resp.Body)
brand := strings.Join(strings.Fields(doc.doc.Find("#navbar-logo .navbar-brand-copy").Text()), " ")
if visible {
assert.Equal(t, "荣刻科技 RONCARVE TECHNOLOGY", brand)
} else {
assert.Empty(t, brand)
}
}
assertBrand(t, emptyTestSession(t), "/user/login", http.StatusOK, true)
assertBrand(t, emptyTestSession(t), "/brand-page-does-not-exist", http.StatusNotFound, true)
session := loginUser(t, "user2")
assertBrand(t, session, "/user2", http.StatusOK, false)
assertBrand(t, session, "/brand-page-does-not-exist", http.StatusNotFound, true)
}