fix(webui): simplify automation controls and disclosure cues

Keep search, status filters, and sorting directly available instead of requiring a sliders toggle. Distinguish task dialogs from inline disclosures by removing task-row arrows and using up/down disclosure cues.

Remove obsolete drawer state and grid columns, preserve focus restoration and system-task preferences, and update interaction regressions. Scheduling, persistence, and task actions remain unchanged.
This commit is contained in:
Xubin Ren authored and chengyongru committed 2026-09-13 05:43:05 +08:00
1 parent f8c1f2ede0
commit 5b2f21c431
5 files changed
+92 -163

No files matched your search

@@ -11,7 +11,6 @@ import {
Loader2, Loader2,
MoreHorizontal, MoreHorizontal,
Search, Search,
SlidersHorizontal,
} from "lucide-react"; } from "lucide-react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -88,8 +87,6 @@ export function AutomationsSettings({
const locale = i18n.resolvedLanguage || i18n.language; const locale = i18n.resolvedLanguage || i18n.language;
const [inspectedJob, setInspectedJob] = useState<SessionAutomationJob | null>(null); const [inspectedJob, setInspectedJob] = useState<SessionAutomationJob | null>(null);
const [detailOpen, setDetailOpen] = useState(false); const [detailOpen, setDetailOpen] = useState(false);
const [toolsOpen, setToolsOpen] = useState(Boolean(query) || filter !== "all" || sort !== "next");
const [sortMenuOpen, setSortMenuOpen] = useState(false);
const [systemOpen, setSystemOpen] = useState(() => { const [systemOpen, setSystemOpen] = useState(() => {
try { try {
return window.localStorage.getItem(SYSTEM_TASKS_OPEN_STORAGE_KEY) !== "false"; return window.localStorage.getItem(SYSTEM_TASKS_OPEN_STORAGE_KEY) !== "false";
@@ -98,11 +95,9 @@ export function AutomationsSettings({
} }
}); });
const searchInput = useRef<HTMLInputElement | null>(null); const searchInput = useRef<HTMLInputElement | null>(null);
const toolsToggle = useRef<HTMLButtonElement | null>(null);
const pageTitle = useRef<HTMLHeadingElement | null>(null); const pageTitle = useRef<HTMLHeadingElement | null>(null);
const selectedTrigger = useRef<HTMLButtonElement | null>(null); const selectedTrigger = useRef<HTMLButtonElement | null>(null);
const afterDetailClose = useRef<((job: SessionAutomationJob) => void) | null>(null); const afterDetailClose = useRef<((job: SessionAutomationJob) => void) | null>(null);
const toolsActive = Boolean(query) || filter !== "all" || sort !== "next";
const filtered = useMemo(() => { const filtered = useMemo(() => {
const searchTokens = parseAutomationSearchQuery(query); const searchTokens = parseAutomationSearchQuery(query);
return sortAutomationJobs(jobs, sort) return sortAutomationJobs(jobs, sort)
@@ -141,10 +136,6 @@ export function AutomationsSettings({
if (query) setSystemOpen(true); if (query) setSystemOpen(true);
}, [query]); }, [query]);
useEffect(() => {
if (toolsOpen) searchInput.current?.focus({ preventScroll: true });
}, [toolsOpen]);
const renderJob = (job: SessionAutomationJob) => ( const renderJob = (job: SessionAutomationJob) => (
<AutomationListItem <AutomationListItem
key={job.id} key={job.id}
@@ -171,89 +162,61 @@ export function AutomationsSettings({
<h1 ref={pageTitle} tabIndex={-1} className="text-[26px] font-semibold leading-tight tracking-[-0.025em] text-foreground outline-none sm:text-[30px]"> <h1 ref={pageTitle} tabIndex={-1} className="text-[26px] font-semibold leading-tight tracking-[-0.025em] text-foreground outline-none sm:text-[30px]">
{tx("settings.nav.automations", "Automations")} {tx("settings.nav.automations", "Automations")}
</h1> </h1>
{jobs.length ? (
<Button
ref={toolsToggle}
variant="ghost"
size="icon"
aria-label={tx("settings.automations.viewOptions", "Search and filter")}
title={tx("settings.automations.viewOptions", "Search and filter")}
aria-expanded={toolsOpen}
aria-controls="automation-view-options"
className={cn("h-9 w-9 shrink-0 rounded-full text-muted-foreground", toolsActive && "bg-muted text-foreground")}
onClick={() => {
setSortMenuOpen(false);
setToolsOpen((value) => !value);
}}
>
<SlidersHorizontal className="h-4 w-4" aria-hidden />
</Button>
) : null}
</header> </header>
{jobs.length ? ( {jobs.length ? (
<DisclosureContent <section
id="automation-view-options" aria-label={tx("settings.automations.viewOptions", "Search and filter")}
open={toolsOpen}
className="space-y-3 pb-5 pt-1" className="space-y-3 pb-5 pt-1"
onKeyDown={(event) => {
if (event.key !== "Escape" || event.defaultPrevented || event.nativeEvent.isComposing || sortMenuOpen) return;
event.preventDefault();
event.stopPropagation();
toolsToggle.current?.focus({ preventScroll: true });
setToolsOpen(false);
}}
> >
<div className="grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto]"> <div className="grid min-w-0 gap-2 sm:grid-cols-[minmax(0,1fr)_auto]">
<div className="relative min-w-0"> <div className="relative min-w-0">
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden /> <Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
<Input <Input
ref={searchInput} ref={searchInput}
disabled={!toolsOpen} value={query}
value={query} onChange={(event) => onQueryChange(event.target.value)}
onChange={(event) => onQueryChange(event.target.value)} aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")}
aria-label={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} placeholder={tx("settings.automations.search", "Search task, message, linked chat, or schedule")}
placeholder={tx("settings.automations.search", "Search task, message, linked chat, or schedule")} className={cn("h-9 w-full rounded-full pl-9 text-[13px]", SETTINGS_SEARCH_INPUT_CLASS)}
className={cn("h-9 w-full rounded-full pl-9 text-[13px]", SETTINGS_SEARCH_INPUT_CLASS)} />
/> </div>
</div> <DropdownMenu>
<DropdownMenu open={toolsOpen && sortMenuOpen} onOpenChange={setSortMenuOpen}> <DropdownMenuTrigger asChild>
<DropdownMenuTrigger asChild> <Button variant="ghost" className="h-9 gap-2 rounded-full text-[12px] text-muted-foreground">
<Button variant="ghost" disabled={!toolsOpen} className="h-9 gap-2 rounded-full text-[12px] text-muted-foreground"> <ArrowUpDown className="h-3.5 w-3.5" aria-hidden />
<ArrowUpDown className="h-3.5 w-3.5" aria-hidden /> {sortLabel[sort]}
{sortLabel[sort]} <ChevronDown className="h-3.5 w-3.5" aria-hidden />
<ChevronDown className="h-3.5 w-3.5" aria-hidden /> </Button>
</Button> </DropdownMenuTrigger>
</DropdownMenuTrigger> <DropdownMenuContent align="end">
<DropdownMenuContent align="end"> {(Object.keys(sortLabel) as AutomationSort[]).map((value) => (
{(Object.keys(sortLabel) as AutomationSort[]).map((value) => ( <DropdownMenuItem key={value} onClick={() => onSortChange(value)}>
<DropdownMenuItem key={value} onClick={() => onSortChange(value)}> <span>{sortLabel[value]}</span>
<span>{sortLabel[value]}</span> {sort === value ? <Check className="ml-auto h-3.5 w-3.5" aria-hidden /> : null}
{sort === value ? <Check className="ml-auto h-3.5 w-3.5" aria-hidden /> : null} </DropdownMenuItem>
</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</div>
<div role="group" aria-label={tx("settings.nav.automations", "Automations")} className="flex flex-wrap gap-1">
{summaryOptions.map((option) => (
<button
key={option.value}
type="button"
disabled={!toolsOpen}
aria-pressed={filter === option.value}
onClick={() => onFilterChange(option.value)}
className={cn(
"touch-target inline-flex min-h-8 max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",
filter === option.value && "bg-muted text-foreground",
)}
>
<span className="min-w-0 [overflow-wrap:anywhere]">{option.label}</span>
<span className="shrink-0 text-[11px] tabular-nums text-muted-foreground">{option.count}</span>
</button>
))} ))}
</div> </DropdownMenuContent>
</DisclosureContent> </DropdownMenu>
</div>
<div role="group" aria-label={tx("settings.nav.automations", "Automations")} className="flex flex-wrap gap-1">
{summaryOptions.map((option) => (
<button
key={option.value}
type="button"
aria-pressed={filter === option.value}
onClick={() => onFilterChange(option.value)}
className={cn(
"touch-target inline-flex min-h-8 max-w-full items-center gap-2 rounded-full px-3 py-1.5 text-[12px] text-muted-foreground transition-colors hover:text-foreground",
filter === option.value && "bg-muted text-foreground",
)}
>
<span className="min-w-0 [overflow-wrap:anywhere]">{option.label}</span>
<span className="shrink-0 text-[11px] tabular-nums text-muted-foreground">{option.count}</span>
</button>
))}
</div>
</section>
) : null} ) : null}
{error ? <AutomationError message={error} /> : null} {error ? <AutomationError message={error} /> : null}
@@ -314,7 +277,7 @@ export function AutomationsSettings({
{tx("settings.automations.filters.failed", "Needs attention")} {tx("settings.automations.filters.failed", "Needs attention")}
</span> </span>
) : null} ) : null}
<ChevronRight className={cn("ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", systemOpen && "rotate-90")} aria-hidden /> <ChevronDown className={cn("ml-auto h-4 w-4 shrink-0 text-muted-foreground transition-transform motion-reduce:transition-none", systemOpen && "rotate-180")} aria-hidden />
</button> </button>
<DisclosureContent <DisclosureContent
id="automation-system-tasks" id="automation-system-tasks"
@@ -347,7 +310,7 @@ export function AutomationsSettings({
if (detailOpen) return; if (detailOpen) return;
setInspectedJob(null); setInspectedJob(null);
const target = selectedTrigger.current?.isConnected const target = selectedTrigger.current?.isConnected
? selectedTrigger.current : toolsToggle.current ?? pageTitle.current; ? selectedTrigger.current : searchInput.current ?? pageTitle.current;
target?.focus({ preventScroll: true }); target?.focus({ preventScroll: true });
const next = afterDetailClose.current; const next = afterDetailClose.current;
afterDetailClose.current = null; afterDetailClose.current = null;
@@ -393,7 +356,7 @@ function AutomationListItem({ job, locale, disabled, onSelect }: {
aria-haspopup="dialog" aria-haspopup="dialog"
onClick={(event) => onSelect(event.currentTarget)} onClick={(event) => onSelect(event.currentTarget)}
className={cn( className={cn(
"automation-task-row group grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-2 text-left transition-colors", "automation-task-row grid w-full grid-cols-1 items-center gap-x-4 gap-y-2 text-left transition-colors",
compact ? "settings-list-row py-3 settings-hover" : "min-h-[92px] rounded-lg py-5 hover:bg-muted/35", compact ? "settings-list-row py-3 settings-hover" : "min-h-[92px] rounded-lg py-5 hover:bg-muted/35",
formControlFocusClassName, formControlFocusClassName,
)} )}
@@ -420,7 +383,6 @@ function AutomationListItem({ job, locale, disabled, onSelect }: {
<span title={formatAutomationNextTitle(job, locale, tx)}>{formatAutomationNext(job, tx)}</span> <span title={formatAutomationNextTitle(job, locale, tx)}>{formatAutomationNext(job, tx)}</span>
)} )}
</span> </span>
<ChevronRight className="automation-task-chevron h-4 w-4 text-muted-foreground/70" aria-hidden />
</button> </button>
</li> </li>
); );
@@ -536,7 +498,7 @@ function AutomationDetailPanel({
summaryClassName={cn("flex cursor-pointer items-center justify-between gap-3 rounded-lg py-4 text-[13px] text-muted-foreground", job.protected && "py-3", formControlFocusClassName)} summaryClassName={cn("flex cursor-pointer items-center justify-between gap-3 rounded-lg py-4 text-[13px] text-muted-foreground", job.protected && "py-3", formControlFocusClassName)}
summary={<> summary={<>
{tx("settings.automations.moreDetails", "More details")} {tx("settings.automations.moreDetails", "More details")}
<ChevronRight className="h-3.5 w-3.5 transition-transform duration-200 group-data-[state=open]/disclosure:rotate-90 motion-reduce:transition-none" aria-hidden /> <ChevronDown className="h-3.5 w-3.5 transition-transform duration-200 group-data-[state=open]/disclosure:rotate-180 motion-reduce:transition-none" aria-hidden />
</>} </>}
> >
<dl className="divide-y divide-border/45"> <dl className="divide-y divide-border/45">
+1 -6
View File
@@ -1029,19 +1029,14 @@
grid-column: 1; grid-column: 1;
grid-row: 2; grid-row: 2;
} }
.automation-task-chevron {
grid-column: 2;
grid-row: 1 / span 2;
}
@container automations (min-width: 36rem) { @container automations (min-width: 36rem) {
.automation-task-row { grid-template-columns: minmax(0, 1fr) auto auto; } .automation-task-row { grid-template-columns: minmax(0, 1fr) auto; }
.automation-task-state { .automation-task-state {
grid-column: 2; grid-column: 2;
grid-row: 1; grid-row: 1;
max-width: 18rem; max-width: 18rem;
justify-content: flex-end; justify-content: flex-end;
} }
.automation-task-chevron { grid-column: 3; grid-row: 1; }
} }
.settings-stack > :not([hidden]) ~ :not([hidden]) { .settings-stack > :not([hidden]) ~ :not([hidden]) {
margin-block-start: var(--settings-module-gap, 20px); margin-block-start: var(--settings-module-gap, 20px);
-1
View File
@@ -1466,7 +1466,6 @@ describe("App layout", () => {
); );
expect(document.title).toBe("Automations · nanobot"); expect(document.title).toBe("Automations · nanobot");
fireEvent.click(screen.getByRole("button", { name: "Search and filter" }));
const searchInput = within(automationsMain as HTMLElement).getByPlaceholderText( const searchInput = within(automationsMain as HTMLElement).getByPlaceholderText(
"Search task, message, linked chat, or schedule", "Search task, message, linked chat, or schedule",
); );
+37 -62
View File
@@ -133,8 +133,8 @@ describe("Automation task list and detail sheet", () => {
const user = userEvent.setup(); const user = userEvent.setup();
render(<Harness />); render(<Harness />);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
expect(screen.queryByRole("textbox")).not.toBeInTheDocument(); expect(screen.getByRole("textbox")).toBeVisible();
expect(screen.queryByRole("button", { name: /^Active/ })).not.toBeInTheDocument(); expect(screen.getByRole("button", { name: /^Active/ })).toBeVisible();
expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible(); expect(screen.getByRole("button", { name: /heartbeat/ })).toBeVisible();
expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument();
const row = screen.getByRole("button", { name: /PR watch/ }); const row = screen.getByRole("button", { name: /PR watch/ });
@@ -162,7 +162,7 @@ describe("Automation task list and detail sheet", () => {
expect(screen.getByText("Tell nanobot in a chat what you'd like it to do on a schedule.")).toBeVisible(); expect(screen.getByText("Tell nanobot in a chat what you'd like it to do on a schedule.")).toBeVisible();
expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Create in chat" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Open a chat" })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: "Open a chat" })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Search and filter" })).toBeVisible(); expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: /heartbeat/ })); fireEvent.click(screen.getByRole("button", { name: /heartbeat/ }));
const dialog = screen.getByRole("dialog", { name: "heartbeat" }); const dialog = screen.getByRole("dialog", { name: "heartbeat" });
expect(within(dialog).queryByRole("button", { name: "Edit" })).not.toBeInTheDocument(); expect(within(dialog).queryByRole("button", { name: "Edit" })).not.toBeInTheDocument();
@@ -288,11 +288,13 @@ describe("Automation task list and detail sheet", () => {
expect(screen.getByRole("button", { name: /heartbeat/ })).toBe(row); expect(screen.getByRole("button", { name: /heartbeat/ })).toBe(row);
}); });
it("keeps search, status filters and sorting available on demand", async () => { it("keeps search, status filters and sorting immediately available", async () => {
const user = userEvent.setup(); const user = userEvent.setup();
render(<Harness payload={{ jobs: [task, { ...task, id: "paused", name: "Weekly review", enabled: false }, systemTask] }} />); render(<Harness payload={{ jobs: [task, { ...task, id: "paused", name: "Weekly review", enabled: false }, systemTask] }} />);
await user.click(screen.getByRole("button", { name: "Search and filter" }));
const search = screen.getByRole("textbox"); const search = screen.getByRole("textbox");
expect(search).toBeVisible();
expect(search).toBeEnabled();
expect(screen.queryByRole("button", { name: "Search and filter" })).not.toBeInTheDocument();
await user.type(search, "chat:nanobot"); await user.type(search, "chat:nanobot");
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
await user.clear(search); await user.clear(search);
@@ -303,9 +305,7 @@ describe("Automation task list and detail sheet", () => {
await user.click(screen.getByRole("button", { name: "Paused 1" })); await user.click(screen.getByRole("button", { name: "Paused 1" }));
expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument(); expect(screen.queryByRole("button", { name: /PR watch/ })).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: /Weekly review/ })).toBeVisible(); expect(screen.getByRole("button", { name: /Weekly review/ })).toBeVisible();
await user.click(screen.getByRole("button", { name: "Search and filter" })); expect(search).toBeVisible();
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "Search and filter" }));
expect(screen.getByRole("button", { name: "Paused 1" })).toHaveAttribute("aria-pressed", "true"); expect(screen.getByRole("button", { name: "Paused 1" })).toHaveAttribute("aria-pressed", "true");
await user.click(screen.getByRole("button", { name: "All 2" })); await user.click(screen.getByRole("button", { name: "All 2" }));
await user.click(screen.getByRole("button", { name: "Next run" })); await user.click(screen.getByRole("button", { name: "Next run" }));
@@ -334,7 +334,6 @@ describe("Automation task list and detail sheet", () => {
})); }));
expect(task.origin?.title).toBe("nanobot-development"); expect(task.origin?.title).toBe("nanobot-development");
await user.click(within(dialog).getByRole("button", { name: "Done" })); await user.click(within(dialog).getByRole("button", { name: "Done" }));
await user.click(screen.getByRole("button", { name: "Search and filter" }));
await user.type(screen.getByRole("textbox"), "chat:新会话名称"); await user.type(screen.getByRole("textbox"), "chat:新会话名称");
expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible(); expect(screen.getByRole("button", { name: /PR watch/ })).toBeVisible();
rerender(<Harness payload={payload} titleOverrides={{}} />); rerender(<Harness payload={payload} titleOverrides={{}} />);
@@ -358,42 +357,36 @@ describe("Automation task list and detail sheet", () => {
expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
}); });
it("focuses search on expansion and restores the toggle on Escape without clearing filters", async () => { it("keeps controls visible and preserves search when Escape dismisses sorting", async () => {
const user = userEvent.setup(); const user = userEvent.setup();
render(<Harness />); render(<Harness />);
const toggle = screen.getByRole("button", { name: "Search and filter" });
await user.click(toggle);
const search = screen.getByRole("textbox"); const search = screen.getByRole("textbox");
expect(search).not.toHaveFocus();
await user.tab();
expect(search).toHaveFocus(); expect(search).toHaveFocus();
await user.keyboard("PR"); await user.type(search, "PR");
await user.keyboard("{Escape}"); await user.keyboard("{Escape}");
expect(toggle).toHaveAttribute("aria-expanded", "false");
expect(toggle).toHaveFocus();
expect(search).toHaveValue("PR"); expect(search).toHaveValue("PR");
expect(search).toBeDisabled();
await user.keyboard("{Enter}");
expect(search).toHaveFocus(); expect(search).toHaveFocus();
expect(search).toHaveValue("PR"); expect(search).toBeEnabled();
fireEvent.keyDown(search, { key: "Escape", isComposing: true }); fireEvent.keyDown(search, { key: "Escape", isComposing: true });
expect(toggle).toHaveAttribute("aria-expanded", "true"); expect(search).toBeVisible();
await user.click(screen.getByRole("button", { name: "Next run", exact: true })); await user.click(screen.getByRole("button", { name: "Next run", exact: true }));
await user.keyboard("{Escape}"); await user.keyboard("{Escape}");
expect(screen.queryByRole("menu")).not.toBeInTheDocument(); expect(screen.queryByRole("menu")).not.toBeInTheDocument();
expect(toggle).toHaveAttribute("aria-expanded", "true");
expect(screen.getByRole("button", { name: "Next run", exact: true })).toHaveFocus(); expect(screen.getByRole("button", { name: "Next run", exact: true })).toHaveFocus();
await user.keyboard("{Escape}"); await user.keyboard("{Escape}");
expect(toggle).toHaveAttribute("aria-expanded", "false"); expect(screen.getByRole("region", { name: "Search and filter" })).toBeVisible();
expect(toggle).toHaveFocus(); expect(search).toHaveValue("PR");
}); });
it("returns focus to the filter or page heading when the inspected row is no longer present", async () => { it("returns focus to search or the page heading when the inspected row is no longer present", async () => {
const user = userEvent.setup(); const user = userEvent.setup();
const { rerender } = render(<Harness filter="active" />); const { rerender } = render(<Harness filter="active" />);
await user.click(screen.getByRole("button", { name: /PR watch/ })); await user.click(screen.getByRole("button", { name: /PR watch/ }));
rerender(<Harness payload={{ jobs: [{ ...task, enabled: false }] }} filter="active" />); rerender(<Harness payload={{ jobs: [{ ...task, enabled: false }] }} filter="active" />);
await user.click(screen.getByRole("button", { name: "Done" })); await user.click(screen.getByRole("button", { name: "Done" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Search and filter" })).toHaveFocus()); await waitFor(() => expect(screen.getByRole("textbox")).toHaveFocus());
rerender(<Harness payload={{ jobs: [task] }} filter="all" />); rerender(<Harness payload={{ jobs: [task] }} filter="all" />);
await user.click(screen.getByRole("button", { name: /PR watch/ })); await user.click(screen.getByRole("button", { name: /PR watch/ }));
@@ -404,46 +397,28 @@ describe("Automation task list and detail sheet", () => {
expect(screen.queryByRole("button")).not.toBeInTheDocument(); expect(screen.queryByRole("button")).not.toBeInTheDocument();
}); });
it("keeps the filter drawer mounted for both transitions and disables hidden controls", async () => { it("uses chevrons only for disclosures, while task rows open dialogs", async () => {
const user = userEvent.setup(); const user = userEvent.setup();
render(<Harness />); render(<Harness />);
const toggle = screen.getByRole("button", { name: "Search and filter" }); const toggle = screen.getByRole("button", { name: "System tasks 1" });
const drawer = document.getElementById(toggle.getAttribute("aria-controls")!)!; const chevron = toggle.querySelector("svg");
const search = within(drawer).getByRole("textbox", { hidden: true }); expect(chevron).toHaveClass("lucide-chevron-down", "rotate-180");
expect(drawer).toHaveClass("inline-disclosure"); await user.click(toggle);
expect(drawer).toHaveAttribute("data-state", "closed"); expect(chevron).not.toHaveClass("rotate-180");
expect(drawer).toHaveAttribute("aria-hidden", "true"); expect(toggle).toHaveAttribute("aria-expanded", "false");
expect(drawer.firstElementChild).toHaveClass("inline-disclosure-clip"); await user.click(toggle);
expect(drawer.firstElementChild?.firstElementChild).toHaveClass("inline-disclosure-content"); for (const name of [/PR watch/, /heartbeat/]) {
for (const control of [search, ...within(drawer).getAllByRole("button", { hidden: true })]) { const row = screen.getByRole("button", { name });
expect(control).toBeDisabled(); expect(row).toHaveAttribute("aria-haspopup", "dialog");
expect(row.querySelector(".lucide-chevron-right, .lucide-chevron-down")).toBeNull();
await user.click(row);
const details = screen.getByRole("button", { name: "More details" });
expect(details.querySelector("svg")).toHaveClass("lucide-chevron-down");
await user.click(details);
expect(details).toHaveAttribute("aria-expanded", "true");
expect(screen.getByRole("dialog")).toBeVisible();
await user.click(screen.getByRole("button", { name: "Done" }));
} }
await user.click(toggle);
expect(drawer).toHaveAttribute("data-state", "open");
expect(drawer).not.toHaveAttribute("aria-hidden");
expect(screen.getByRole("textbox")).toBe(search);
await user.type(search, "PR");
await user.click(toggle);
expect(document.getElementById("automation-view-options")).toBe(drawer);
expect(drawer).toHaveAttribute("data-state", "closed");
expect(search).toHaveValue("PR");
expect(search).toBeDisabled();
await user.tab();
expect(screen.getByRole("button", { name: /PR watch/ })).toHaveFocus();
await user.click(toggle);
await user.dblClick(toggle);
expect(drawer).toHaveAttribute("data-state", "open");
expect(screen.getByRole("textbox")).toBe(search);
expect(search).toHaveValue("PR");
await user.click(screen.getByRole("button", { name: "Next run", exact: true }));
expect(screen.getByRole("menu")).toBeVisible();
fireEvent.click(toggle);
await waitFor(() => expect(screen.queryByRole("menu")).not.toBeInTheDocument());
expect(drawer).toHaveAttribute("data-state", "closed");
await user.click(toggle);
expect(screen.queryByRole("menu")).not.toBeInTheDocument();
}); });
it("hands off editing and deletion without leaving a second modal open", async () => { it("hands off editing and deletion without leaving a second modal open", async () => {
+1 -3
View File
@@ -213,7 +213,6 @@ describe("Settings system domains", () => {
}); });
expect(await screen.findByRole("button", { name: /Daily summary/ })).toBeInTheDocument(); expect(await screen.findByRole("button", { name: /Daily summary/ })).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Search and filter" }));
fireEvent.click(screen.getByRole("button", { name: "Paused 0" })); fireEvent.click(screen.getByRole("button", { name: "Paused 0" }));
expect(await screen.findByText("No automations match this view.")).toBeInTheDocument(); expect(await screen.findByText("No automations match this view.")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Clear filters" })); fireEvent.click(screen.getByRole("button", { name: "Clear filters" }));
@@ -241,8 +240,7 @@ describe("Settings system domains", () => {
})); }));
renderSettingsView({ initialSection: "automations", initialSettings: settingsPayload(), showSidebar: false }); renderSettingsView({ initialSection: "automations", initialSettings: settingsPayload(), showSidebar: false });
fireEvent.click(await screen.findByRole("button", { name: "Search and filter" })); const filters = await screen.findByRole("group", { name: "Automations" });
const filters = screen.getByRole("group", { name: "Automations" });
expect(filters).toHaveClass("flex-wrap"); expect(filters).toHaveClass("flex-wrap");
expect(within(filters).getAllByRole("button")).toHaveLength(4); expect(within(filters).getAllByRole("button")).toHaveLength(4);
expect(within(filters).getByRole("button", { name: "All 1" })).toHaveAttribute("aria-pressed", "true"); expect(within(filters).getByRole("button", { name: "All 1" })).toHaveAttribute("aria-pressed", "true");