Add API policy pickers and contextual search labels

This commit is contained in:
Joe Julian
2026-04-03 10:55:17 -07:00
parent eebb270158
commit 05f43aa7bb
3 changed files with 183 additions and 8 deletions
+65 -1
View File
@@ -973,7 +973,7 @@ func TestUIAPIAuditMessagesGuideQuickFilters(t *testing.T) {
if got := u.listEmptyState(); got.Title != "No API audit events yet" || got.Body != "Connect a trusted client, respond to approval prompts, or issue a token to start recording activity." {
t.Fatalf("listEmptyState() = %#v, want updated API audit guidance", got)
}
if got := u.detailPlaceholderMessage(); got != "Select an audit event to inspect it, or use Search vault or the quick filters above." {
if got := u.detailPlaceholderMessage(); got != "Select an audit event to inspect it, or use Search audit log or the quick filters above." {
t.Fatalf("detailPlaceholderMessage() = %q, want quick-filter guidance", got)
}
@@ -5217,6 +5217,70 @@ func TestUIListEmptyStateProvidesSectionSpecificGuidance(t *testing.T) {
})
}
func TestUISearchPlaceholderIsContextual(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{})
if got := u.searchPlaceholder(); got != "Search vault" {
t.Fatalf("default searchPlaceholder() = %q, want %q", got, "Search vault")
}
u.showRecycleBinSection()
if got := u.searchPlaceholder(); got != "Search recycle bin" {
t.Fatalf("recycle searchPlaceholder() = %q, want %q", got, "Search recycle bin")
}
u.showAPITokensSection()
if got := u.searchPlaceholder(); got != "Search API tokens" {
t.Fatalf("api token searchPlaceholder() = %q, want %q", got, "Search API tokens")
}
u.showAPIAuditSection()
if got := u.searchPlaceholder(); got != "Search audit log" {
t.Fatalf("api audit searchPlaceholder() = %q, want %q", got, "Search audit log")
}
}
func TestUIAPIPolicyTargetActionsUseCurrentContext(t *testing.T) {
t.Parallel()
u := newUIWithModel("desktop", vault.Model{
Entries: []vault.Entry{
{ID: "lights", Title: "Home Assistant", Path: []string{"Crew", "codex"}},
},
})
u.state.NavigateToPath([]string{"Crew", "codex"})
u.filter()
u.state.SelectedEntryID = "lights"
if err := u.useCurrentGroupForPolicyAction(); err != nil {
t.Fatalf("useCurrentGroupForPolicyAction() error = %v", err)
}
if got := u.apiPolicyPath.Text(); got != "codex" {
t.Fatalf("apiPolicyPath.Text() = %q, want %q", got, "codex")
}
if !u.apiPolicyGroupScopeW.Value {
t.Fatal("apiPolicyGroupScopeW.Value = false, want true")
}
if err := u.useSelectedEntryForPolicyAction(); err != nil {
t.Fatalf("useSelectedEntryForPolicyAction() error = %v", err)
}
if got := u.apiPolicyEntryID.Text(); got != "lights" {
t.Fatalf("apiPolicyEntryID.Text() = %q, want %q", got, "lights")
}
if u.apiPolicyGroupScopeW.Value {
t.Fatal("apiPolicyGroupScopeW.Value = true, want false")
}
if err := u.clearAPIPolicyTargetAction(); err != nil {
t.Fatalf("clearAPIPolicyTargetAction() error = %v", err)
}
if got := u.apiPolicyPath.Text(); got != "" {
t.Fatalf("apiPolicyPath.Text() = %q, want empty", got)
}
if got := u.apiPolicyEntryID.Text(); got != "" {
t.Fatalf("apiPolicyEntryID.Text() = %q, want empty", got)
}
}
func TestUIVisibleBreadcrumbsCompressesAggressivelyOnPhone(t *testing.T) {
t.Parallel()