Files
mesh-sdk/go/catalogue/graphical_session_test.go
T
jochen 7c3e439e32 Copy node-uplink and node-display-session byte for byte from their contracts modules
Code review round 1 found the test copies were not copies: a reconstruction from the holders'
code drifted in a few fields and added ADR 0613 to the decision, which the real definitions do
not carry. node-uplink.json is copied byte for byte from mesh-networking
modules/mesh-connectivity-contracts/seats/node-uplink/seat.json (8d993ea), and
node-display-session.json from mesh-contracts seats/node-display-session/seat.json (3260a68a).
graphical_session_test.go's decision text now matches the real definition
("novox/hq ADR 0208, ADR 0687"). node-resolver.json and node_resolver_test.go wait for
mesh-networking's fix for outside_writes.

Builds: design 08 sign-in-page §1, §3; lead answer C-3
2026-11-24 21:48:49 +01:00

69 lines
2.4 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.
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"}
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)
}
}