package thintest import ( "regexp" "strings" "testing" ) // TestPagesMachines: Machines in Settings (Paul, 2026-11-11) on a real // instance. The owner's own machines are rows (the online primary and // Mac, the Mac that never connected saying what to check); a member's // machine is folded under Other people's machines, closed, with its // count; the details and the quiet, confirmed Revoke and Remove now are // behind a click. The member sees only their own. /runners/enrol, the // address a runner prints, still serves the list, and with a code the // Add a machine page; Add a machine lists the new machine. func TestPagesMachines(t *testing.T) { r := newMachinesRig(t) owner := r.inst.Cookie() row := func(page, id string) string { t.Helper() m := regexp.MustCompile(`(?s)
.*?`).FindString(page) if m == "" { t.Fatalf("no row %s", id) } return m } for _, path := range []string{"/conversation/settings/machines", "/runners/enrol"} { page := r.get(owner, path, 200) mine, others, ok := strings.Cut(page, "data-other-machines") if !ok || !strings.Contains(mine, "data-my-machines") { t.Fatalf("%s: no folded others after the person's own", path) } if !regexp.MustCompile(`
Other people's machines 1`).MatchString(page) { t.Fatalf("%s: others not folded, closed, with a count", path) } for id, state := range map[string]string{r.worker: "online", r.never: "never"} { if got := row(mine, id); !strings.Contains(got, `data-state="`+state+`"`) { t.Fatalf("%s: %s is not %s: %s", path, id, state, got) } } if !strings.Contains(row(mine, r.worker), ">Tito Studio<") || !strings.Contains(row(mine, r.worker), ">Runs checks<") { t.Fatalf("%s: the Mac's row: %s", path, row(mine, r.worker)) } never := row(mine, r.never) if !strings.Contains(never, "Never connected") || !strings.Contains(never, "Check that the runner is running on it.") { t.Fatalf("%s: never connected unclear: %s", path, never) } if !strings.Contains(row(others, r.others), "ana@example.com") || strings.Contains(mine, r.others) { t.Fatalf("%s: the member's machine is not folded with whose it is", path) } for _, id := range []string{r.worker, r.never} { if !strings.Contains(page, `
`) || !strings.Contains(page, `action="/runners/`+id+`/remove-now"`) { t.Fatalf("%s: %s has no confirmed Revoke and Remove now", path, id) } } if strings.Count(page, "
") < 4 { t.Fatalf("%s: destructive actions are not quiet confirmations", path) } } // A member sees only their own machine, and no fold. member := r.get(r.inst.SessionFor(t, machinesMember), "/conversation/settings/machines", 200) if strings.Contains(member, "data-other-machines") || !strings.Contains(member, r.others) || strings.Contains(member, r.never) { t.Fatal("a member's Machines shows other people's machines") } // Add a machine: the code, and the new machine waiting to connect. add := r.get(owner, "/conversation/settings/machines/add", 200) if !strings.Contains(add, "data-add-machine-steps") || !strings.Contains(add, `name="action" value="inspect"`) || !strings.Contains(row(add, r.never), `data-state="never"`) || !strings.Contains(add, `href="/conversation/settings/machines" rel="up"`) { t.Fatal("Add a machine lacks its steps, its new machine or its way back") } if strings.Contains(add, "ana@example.com") { t.Fatal("another person's machine on Add a machine") } }