Put the Update and Packages pages on one Updates page
Router software and packages are two parts of one page, with one overlay, one confirmation banner and both logs. /upgrade redirects to it; the actions keep their addresses. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,25 @@ func TestReleaseOfAndChannelChoices(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOneUpdatesPage(t *testing.T) {
|
||||
a, _ := newTestApp(t)
|
||||
h := a.routes()
|
||||
cookie := login(t, h)
|
||||
// The old address of the packages leads to the page that has both parts.
|
||||
if rec := do(h, "GET", "/upgrade", nil, cookie); rec.Code != http.StatusSeeOther || rec.Header().Get("Location") != "/update#packages" {
|
||||
t.Fatalf("/upgrade: %d %q", rec.Code, rec.Header().Get("Location"))
|
||||
}
|
||||
body := do(h, "GET", "/update", nil, cookie).Body.String()
|
||||
for _, want := range []string{"Router software", "Install a bundle", "Update server", `id="packages"`, "Choose a channel", `aria-current="page">Updates`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("the page lacks %q", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(body, `href="/upgrade"`) {
|
||||
t.Error("the menu still links /upgrade")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReleaseNotice(t *testing.T) {
|
||||
seen := []string{"25.05", "25.11", "26.05", "26.11"}
|
||||
if got := supportedReleases(seen); strings.Join(got, ",") != "26.05,26.11" {
|
||||
@@ -69,16 +88,16 @@ func TestReleaseNoticeShows(t *testing.T) {
|
||||
}
|
||||
h := a.routes()
|
||||
cookie := do(h, "POST", "/login", url.Values{"password": {"hunter2hunter2"}}, nil).Result().Cookies()[0]
|
||||
if body := do(h, "GET", "/upgrade", nil, cookie).Body.String(); strings.Contains(body, "is out") {
|
||||
if body := do(h, "GET", "/update", nil, cookie).Body.String(); strings.Contains(body, "is out") {
|
||||
t.Fatalf("a notice before the channel server was asked:\n%s", body)
|
||||
}
|
||||
os.WriteFile(filepath.Join(sys.upgradeDir(), "releases.json"), []byte(`{"time":"2026-11-19T00:00:00Z","releases":["26.05","26.11"]}`), 0o644)
|
||||
for _, path := range []string{"/", "/upgrade"} {
|
||||
for _, path := range []string{"/", "/update"} {
|
||||
if body := do(h, "GET", path, nil, cookie).Body.String(); !strings.Contains(body, "NixOS 26.11 is out") {
|
||||
t.Errorf("%s has no notice:\n%s", path, body)
|
||||
}
|
||||
}
|
||||
if body := do(h, "GET", "/upgrade", nil, cookie).Body.String(); !strings.Contains(body, `<option value="26.11"`) {
|
||||
if body := do(h, "GET", "/update", nil, cookie).Body.String(); !strings.Contains(body, `<option value="26.11"`) {
|
||||
t.Errorf("26.11 is not offered:\n%s", body)
|
||||
}
|
||||
}
|
||||
@@ -128,7 +147,7 @@ func TestUpgradePage(t *testing.T) {
|
||||
defer func() { startUnit = orig }()
|
||||
h := a.routes()
|
||||
cookie := login(t, h)
|
||||
page := func() string { return do(h, "GET", "/upgrade", nil, cookie).Body.String() }
|
||||
page := func() string { return do(h, "GET", "/update", nil, cookie).Body.String() }
|
||||
post := func(path string, form url.Values) *http.Response {
|
||||
form.Set("csrf", csrfFrom(t, page()))
|
||||
return do(h, "POST", path, form, cookie).Result()
|
||||
@@ -226,7 +245,7 @@ func TestUpgradePage(t *testing.T) {
|
||||
|
||||
t.Run("the last run's output is shown", func(t *testing.T) {
|
||||
os.WriteFile(filepath.Join(a.sys.upgradeDir(), "last.log"), []byte("channel 26.11 (nixos-26.11)\nup to date\n"), 0o600)
|
||||
if body := page(); !strings.Contains(body, "Last run") || !strings.Contains(body, "nixos-26.11)") {
|
||||
if body := page(); !strings.Contains(body, "Last package run") || !strings.Contains(body, "nixos-26.11)") {
|
||||
t.Fatalf("no log:\n%s", body)
|
||||
}
|
||||
if got := tail("a\nbb\nccc\n", 6); got != "ccc\n" {
|
||||
|
||||
Reference in New Issue
Block a user