CI / test (push) Successful in 7m15s
Pages are served at /resources, /sites, /domains, /mail-egress, /alerts, /access, /logs, /apps, /account and /server/*, with working links, reloads and back button. Mail egress, alerts, access, users, organizations, SSO and DKIM follow the same header-button and dialog pattern as the other pages. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
910 B
Go
35 lines
910 B
Go
package hammerhead
|
|
|
|
import (
|
|
"os"
|
|
"regexp"
|
|
"testing"
|
|
)
|
|
|
|
// Every address the dashboard JavaScript navigates to must be served by the server, or a
|
|
// reload on that page would 404.
|
|
func TestDashboardPathsMatchThePage(t *testing.T) {
|
|
src, err := os.ReadFile("web/index.html")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m := regexp.MustCompile(`TAB_PATH = \{([^}]*)\}`).FindSubmatch(src)
|
|
if m == nil {
|
|
t.Fatal("TAB_PATH not found in web/index.html")
|
|
}
|
|
paths := regexp.MustCompile(`'(/[a-z/-]+)'`).FindAllSubmatch(m[1], -1)
|
|
if len(paths) < 10 {
|
|
t.Fatalf("found only %d page paths", len(paths))
|
|
}
|
|
for _, p := range paths {
|
|
if !isDashboardPath(string(p[1])) {
|
|
t.Errorf("%s is a dashboard page but the server doesn't serve it", p[1])
|
|
}
|
|
}
|
|
for _, p := range []string{"/api/me", "/nope", "/server", "/server/nope"} {
|
|
if isDashboardPath(p) {
|
|
t.Errorf("%s should not serve the dashboard", p)
|
|
}
|
|
}
|
|
}
|