Files
mesh-sdk/go/catalogue/graphical_session_test.go
T
jochen 18c68fda5a Refresh the test copies of node-uplink, node-resolver and node-display-session to their whole definitions
mesh-sdk joins the sign-in-page milestone only to replace its seatlisttest copies with the three
seats' whole definitions, and to update the two tests that assert today's verbs; the seat-name
constants and the package's own code stay untouched (ADR 0613 §5: nothing seat-specific is added
to mesh-sdk).

Builds: design 08 sign-in-page §1, §2, §3, §4
2026-11-24 21:13:21 +01:00

69 lines
2.5 KiB
Go

package catalogue
import (
"encoding/json"
"reflect"
"testing"
)
// Defends novox/hq ADR 0208: the graphical session is one module per piece, on the mesh's seats.
// §2: the eleven roles are the mesh's own node seats, each with the verbs it starts with. Defends design 08
// sign-in-page §3 (novox/hq ADR 0687 §4): the display session gains the required verb `open`, and its decision
// gains ADR 0687 and ADR 0613.
func TestTheGraphicalSessionsSeatsAreTheMeshsOwnWithTheirVerbs(t *testing.T) {
want := map[string][]string{
LoginManagerSeat: {"sessions"},
DisplayServerSeat: {"displays", "layout"},
DisplaySessionSeat: {"reload", "workspaces", "windows", "open"},
TerminalEmulatorSeat: {"open"},
LauncherSeat: {"menu", "secret"},
NotifierSeat: {"send", "history"},
LockScreenSeat: {"lock"},
ClipboardSeat: {"history", "copy"},
BarSeat: nil,
CompositorSeat: nil,
SecretServiceSeat: nil,
}
decisions := map[string]string{DisplaySessionSeat: "novox/hq ADR 0208, ADR 0687, ADR 0613"}
for name, verbs := range want {
s, ok := SeatNamed(name)
if !ok {
t.Errorf("%s is not in the mesh's set", name)
continue
}
wantDecision := decisions[name]
if wantDecision == "" {
wantDecision = "novox/hq ADR 0208"
}
if s.Scope != ScopeNode || s.Decision != wantDecision {
t.Errorf("%s is %s-scoped under %q, want %q", name, s.Scope, s.Decision, wantDecision)
}
var got []string
for _, v := range s.Serves {
got = append(got, v.Name)
if v.Description == "" || v.Input["type"] != "object" {
t.Errorf("%s.%s has no description or no object schema", name, v.Name)
}
}
if !reflect.DeepEqual(got, verbs) {
t.Errorf("%s serves %v, want %v", name, got, verbs)
}
}
// The launcher's menu takes a list, and the layout verb says its actions.
menu, _ := SeatNamed(LauncherSeat)
choices := menu.Serves[0].Input["properties"].(map[string]any)["choices"].(map[string]any)
if choices["type"] != "array" {
t.Errorf("menu's choices are %v, not a list", choices["type"])
}
display, _ := SeatNamed(DisplayServerSeat)
action := display.Serves[1].Input["properties"].(map[string]any)["action"].(map[string]any)
if !reflect.DeepEqual(action["enum"], []string{"list", "save", "apply"}) {
t.Errorf("layout's actions are %v", action["enum"])
}
// And they survive the store's JSON, which is where the live set comes from.
if _, err := json.Marshal(DefaultSeats()); err != nil {
t.Fatal(err)
}
}