返回 DeepSeek-Reasonix
remote_tab_single_surface_extra_test.go
根目录 / desktop / remote_tab_single_surface_extra_test.go
1 package main
2
3 import (
4 "encoding/json"
5 "testing"
6 )
7
8 // singleSurfaceTabsFile rewrites the persisted layout. Every branch must carry
9 // the forward-compatibility keys of a newer build through untouched; the
10 // local-kept branch dropped them, so a downgrade-then-upgrade cycle lost them
11 // whenever a remote surface was active.
12 func TestSingleSurfaceLocalKeptBranchPreservesUnknownKeys(t *testing.T) {
13 extra := map[string]json.RawMessage{"futureKey": json.RawMessage(`{"a":1}`)}
14 out := singleSurfaceTabsFile(desktopTabsFile{
15 Tabs: []desktopTabEntry{{ID: "l1"}, {ID: "l2"}},
16 RemoteTabs: []desktopRemoteTabEntry{{ID: "r1", HostID: "h", Workspace: "~/a"}},
17 ActiveTab: "r1",
18 extra: extra,
19 })
20 if len(out.Tabs) != 1 || out.ActiveTab != "r1" {
21 t.Fatalf("collapse = %+v, want the remote surface with one dormant local tab", out)
22 }
23 if string(out.extra["futureKey"]) != `{"a":1}` {
24 t.Fatalf("collapsed extra = %v, want the forward-compatible key retained", out.extra)
25 }
26 extra["futureKey"] = json.RawMessage(`{"a":2}`)
27 if string(out.extra["futureKey"]) != `{"a":1}` {
28 t.Fatal("collapsed extra aliases the caller's map instead of cloning it")
29 }
30 }
31
31 lines GO