test(11.2): cover site_url and site_label and gate the framework, app and site stages

- TestCheckSiteURL (21 accepted and rejected values), TestSiteLabel and
  TestSiteURLPrecedence (option over site.yaml, label-without-URL and
  invalid option errors); new TestParseSite rows for blank and two-line labels
- TestSiteLink: escaped label, section page and 404 page, exact unset header
  bytes
- TestDocsSiteFlagsInHelp and the --site-label-without-URL error
- check-phase11.2.sh --framework, --app and --site
This commit is contained in:
Jakub Zych
2026-10-01 16:35:09 +02:00
parent 18fe100113
commit f5f9387ac9
4 changed files with 222 additions and 11 deletions

View File

@@ -104,6 +104,38 @@ func TestDocsBuildSiteFlags(t *testing.T) {
if err := root.Execute(); err == nil || !strings.Contains(err.Error(), "--site-url") {
t.Fatalf("docs:build --site-url javascript:alert(1): err = %v, want a --site-url error", err)
}
// The framework's own site.yaml sets no site_url, so a label alone fails.
buf.Reset()
root, err = bonfire.NewRoot("summer", toolCommands(), &buf)
if err != nil {
t.Fatal(err)
}
root.SetArgs([]string{"docs:build", "--root", repoRoot, "--out", filepath.Join(t.TempDir(), "nolabel"), "--site-label", "x"})
if err := root.Execute(); err == nil || !strings.Contains(err.Error(), "--site-label needs --site-url") {
t.Fatalf("docs:build --site-label x: err = %v, want a --site-label needs --site-url error", err)
}
}
// TestDocsSiteFlagsInHelp checks that docs:build and docs:serve list the
// --site-url and --site-label flags in their help.
func TestDocsSiteFlagsInHelp(t *testing.T) {
for _, cmd := range []string{"docs:build", "docs:serve"} {
var buf bytes.Buffer
root, err := bonfire.NewRoot("summer", toolCommands(), &buf)
if err != nil {
t.Fatal(err)
}
root.SetArgs([]string{cmd, "--help"})
if err := root.Execute(); err != nil {
t.Fatalf("%s --help: %v", cmd, err)
}
for _, want := range []string{"--site-url", "--site-label", "overrides site.yaml site_url", "overrides site.yaml site_label"} {
if !strings.Contains(buf.String(), want) {
t.Errorf("%s help lacks %q:\n%s", cmd, want, buf.String())
}
}
}
}
// requiredPages lists the guide pages the docs must keep. Each content plan