internal/httpd/footer_test.go

28e72be7ab6bc96868893853fd8d210c3656960f
gitbay/internal/httpd/footer_test.go

26 lines · 1001 bytes

 1package httpd
 2
 3import (
 4	"strings"
 5	"testing"
 6)
 7
 8// The footer links the operator's terms and abuse pages only when
 9// configured, on a page with no viewer and on the 404 page.
10func TestFooterOperatorLinks(t *testing.T) {
11	s, _, _ := newTokenTestServer(t)
12	for _, path := range []string{"/privacy", "/no-such-owner"} {
13		if body := get(t, s.Handler(), path, nil).Body.String(); strings.Contains(body, "Report abuse") || strings.Contains(body, ">Terms<") {
14			t.Errorf("%s: footer links with nothing configured", path)
15		}
16	}
17	s.cfg.Web.AbuseURL = "https://example.test/wiki/Abuse"
18	s.cfg.Web.TermsURL = "https://example.test/wiki/Terms"
19	for _, path := range []string{"/privacy", "/no-such-owner"} {
20		body := get(t, s.Handler(), path, nil).Body.String()
21		if !strings.Contains(body, `<a href="https://example.test/wiki/Abuse">Report abuse</a>`) ||
22			!strings.Contains(body, `<a href="https://example.test/wiki/Terms">Terms</a>`) {
23			t.Errorf("%s: footer lacks the configured links", path)
24		}
25	}
26}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form