Cover the page while looking at the repository

The look for a newer release shows the same box as an update, and the page
reloads when it is done.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 10:46:55 +01:00
co-authored by Claude Sonnet 5.5
parent 3881c623cf
commit da206a5237
3 changed files with 49 additions and 1 deletions
+37
View File
@@ -11,6 +11,43 @@ import (
const testRepository = "https://git.example.org/me/nixos-router"
// While the look at the repository runs, the page is covered by the same kind
// of box as an update, and keeps asking for itself until it is done.
func TestLookingAtTheRepositoryShowsABox(t *testing.T) {
a, sys := newTestApp(t)
sys.RepositoryFile = filepath.Join(t.TempDir(), "router-update-repository")
os.WriteFile(sys.RepositoryFile, []byte(testRepository), 0o644)
a.sys = sys
orig := unitProperty
state := "inactive"
unitProperty = func(unit, prop string) string {
if unit == gitCheckUnit && prop == "ActiveState" {
return state
}
return ""
}
defer func() { unitProperty = orig }()
h := a.routes()
cookie := login(t, h)
body := do(h, "GET", "/update", nil, cookie).Body.String()
if strings.Contains(body, "Looking at the repository…") || strings.Contains(body, "data-live") {
t.Fatalf("a box with nothing running:\n%s", body)
}
if !strings.Contains(body, "Look for a newer release") {
t.Fatalf("no button:\n%s", body)
}
state = "activating"
body = do(h, "GET", "/update", nil, cookie).Body.String()
if !strings.Contains(body, "Looking at the repository…") || !strings.Contains(body, `class="upload-overlay"`) || !strings.Contains(body, "data-live") {
t.Fatalf("no box while looking:\n%s", body)
}
if !strings.Contains(body, testRepository) {
t.Fatalf("the box does not say where it looks:\n%s", body)
}
}
func TestUpdatesFromGit(t *testing.T) {
a, sys := newTestApp(t)
dir := t.TempDir()
+2 -1
View File
@@ -49,7 +49,8 @@ func command(name string, args ...string) (string, error) {
return strings.TrimSpace(string(out)), err
}
func unitProperty(unit, prop string) string {
// unitProperty is a property of a systemd unit (replaced in tests).
var unitProperty = func(unit, prop string) string {
out, _ := command("systemctl", "show", "--value", "-p", prop, unit)
return out
}
+10
View File
@@ -22,6 +22,16 @@
<p class="muted">The page reloads when it is done. The web UI restarts when an upgrade is switched on, and you log in again.</p>
</div>
</div>
{{else if $u.GitRun.Running}}
<div class="upload-overlay" role="dialog" aria-modal="true">
<div class="upload-card wide">
<h2>Looking at the repository…</h2>
<progress max="100"></progress>
<p>Reading the release tags of <code>{{$u.Repository}}</code>.</p>
{{if $u.GitRun.Log}}<pre class="log">{{$u.GitRun.Log}}</pre>{{end}}
<p class="muted">The page reloads when it is done.</p>
</div>
</div>
{{else if $u.Pending}}
<section class="pending"><h2>Waiting for confirmation</h2>
<p>A new system is active and not confirmed yet. Confirm it on the <a href="/">Overview</a>, or the router goes back to the