package thintest import ( "net/http" "strings" "testing" ) // TestPagesSettingsSections: Paul, 2026-11-09: Settings split into // sections, each at its own URL with the menu of all of them, the current // one marked; Connections and the Notebook moved under it; the old URLs // lead to their sections; the conversation's header leads there too. func TestPagesSettingsSections(t *testing.T) { r := newToolRig(t) owner := r.inst.Cookie() links := []string{`data-settings-link="thinking"`, `data-settings-link="connections"`, `data-settings-link="machines"`, `data-settings-link="housekeeping"`, `data-settings-link="notebook"`, `data-settings-link="teams"`} for _, tc := range []struct{ path, current, want string }{ {"/conversation/settings", "thinking", `data-root`}, {"/conversation/settings/thinking", "thinking", `data-thinking-words`}, {"/conversation/settings/connections", "connections", `data-connections`}, {"/conversation/settings/machines", "machines", `data-machines`}, {"/runners/enrol", "machines", `data-my-machines`}, {"/conversation/settings/housekeeping", "housekeeping", `data-hk-settings`}, {"/conversation/settings/notebook", "notebook", `data-notebook-reset`}, } { page := r.get(owner, tc.path, 200) for _, l := range links { if !strings.Contains(page, l) { t.Fatalf("%s: the menu lacks %s", tc.path, l) } } if strings.Count(page, `aria-current="page" `) > 0 || !strings.Contains(page, `data-settings-link="`+tc.current+`" aria-current="page"`) { t.Fatalf("%s: %s is not the one current section", tc.path, tc.current) } if !strings.Contains(page, tc.want) { t.Fatalf("%s lacks %s", tc.path, tc.want) } if tc.path != "/conversation/settings" && (!strings.Contains(page, `href="/conversation/settings" rel="up"`) || strings.Contains(page, `data-root`)) { t.Fatalf("%s: no way back to Settings", tc.path) } } // Usage is a page of the app's sidebar (connectors spec S4), not a // Settings section. if strings.Contains(r.get(owner, "/conversation/settings", 200), `data-settings-link="usage"`) { t.Fatal("a usage section appeared") } noFollow := &http.Client{CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }} for old, to := range map[string]string{"/conversation/connections": "/conversation/settings/connections", "/conversation/notebook": "/conversation/settings/notebook", "/settings/thinking": "/conversation/settings/thinking"} { req, _ := http.NewRequest("GET", r.inst.URL+old, nil) req.AddCookie(owner) res, err := noFollow.Do(req) if err != nil { t.Fatal(err) } res.Body.Close() if res.StatusCode != http.StatusSeeOther || res.Header.Get("Location") != to { t.Fatalf("%s: %d to %q, want %s", old, res.StatusCode, res.Header.Get("Location"), to) } } chat := r.get(owner, "/conversation", 200) if !strings.Contains(chat, `href="/conversation/settings/connections" equipo-header-button`) || !strings.Contains(chat, `href="/conversation/settings/notebook" equipo-header-button`) { t.Fatal("the conversation's header does not lead to the sections") } }