Files
MyGoNavi/internal/nativewindow/dock_menu_test.go
Syngnat fda0733f11 ️ perf(native-window): 优化 AI 独立窗口启动与交互
- 关闭时隐藏保活,重开复用现有进程并通过可见性版本消除竞态
- 拆分 AI 与工作台资源,使用启动状态白名单减少序列化开销
- 修复设置中心层级、Windows 前台切换及独立窗口关闭交互
- 补齐状态同步、断线重放与窗口生命周期回归测试
2026-07-21 23:40:17 +08:00

45 lines
1.4 KiB
Go

package nativewindow
import (
"reflect"
"testing"
)
func TestBuildDockMenuSnapshotIncludesOnlyCurrentReadyWindows(t *testing.T) {
windows := []WindowInfo{
{ID: "closing", Title: "Closing", PID: 42, OpenedAt: 1, Ready: true, CloseSent: true},
{ID: "hidden", Title: "Hidden", PID: 48, OpenedAt: 3, Ready: true, Hidden: true},
{ID: "not-ready", Title: "Starting", PID: 43, OpenedAt: 2},
{ID: " result-2 ", Title: " Result 2 ", PID: 44, OpenedAt: 40, Ready: true},
{ID: "workbench-1", Title: "Workbench", PID: 45, OpenedAt: 20, Ready: true},
{ID: "", Title: "Missing ID", PID: 46, OpenedAt: 10, Ready: true},
{ID: "ai-chat", Title: " ", PID: 47, OpenedAt: 30, Ready: true},
}
got := buildDockMenuSnapshot(windows)
want := []dockMenuWindow{
{ID: "workbench-1", Title: "Workbench", PID: 45},
{ID: "ai-chat", Title: "GoNavi", PID: 47},
{ID: "result-2", Title: "Result 2", PID: 44},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("dock menu snapshot = %#v, want %#v", got, want)
}
}
func TestBuildDockMenuSnapshotUsesStableIDOrderForEqualOpenTimes(t *testing.T) {
windows := []WindowInfo{
{ID: "window-b", Title: "B", OpenedAt: 12, Ready: true},
{ID: "window-a", Title: "A", OpenedAt: 12, Ready: true},
}
got := buildDockMenuSnapshot(windows)
want := []dockMenuWindow{
{ID: "window-a", Title: "A"},
{ID: "window-b", Title: "B"},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("dock menu snapshot = %#v, want %#v", got, want)
}
}