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()