Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test: 用组件渲染验证归档提醒点与设置按钮显隐
Dash55fde4e14cec
diff --git a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.tsindex f990a0e598..11457ae28a 100644--- a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts+++ b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts@@ -94,11 +94,7 @@ describe('Projects sidebar section', () => {expect(headerSource).not.toContain('group-focus-within/sidebar-header:pointer-events-auto',);- // 折叠按钮始终只在 hover 时出现;筛选(整理侧边栏)按钮仅在查看「已归档」时常驻。- expect(headerSource).toContain('<div className={HEADER_HOVER_ACTION_CLASS}>');- expect(headerSource).toContain(- "filter.status === 'archived' ? undefined : HEADER_HOVER_ACTION_CLASS",- );+ // 各按钮在 hover/归档下的显隐由 MainListScopeHeader.test.tsx 通过组件渲染验证。});it('the project tree renders unconditionally (section collapse removed)', () => {diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/MainListScopeHeader.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/MainListScopeHeader.test.tsxnew file mode 100644index 0000000000..6a3856c4b8--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/MainListScopeHeader.test.tsx@@ -0,0 +1,49 @@+// @vitest-environment jsdom+import React from 'react';+import { cleanup, render, screen } from '@testing-library/react';+import { ChevronsUpDown } from 'lucide-react';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { MainListScopeHeader } from '../MainListScopeHeader';+import type { UseSidebarFilterReturn } from '../../hooks/useSidebarFilter';++vi.mock('@/components/ui/tooltip', () => ({+ Tip: ({ children }: { children: React.ReactNode }) => <>{children}</>,+}));+vi.mock('../MachineSwitcherMenu', () => ({ MachineSwitcherMenu: () => null }));+vi.mock('../SidebarFilterPopover', () => ({+ SidebarFilterPopover: () => <button type="button">display-settings</button>,+}));++afterEach(cleanup);++// 段头操作默认只在 hover/focus 时出现(用 opacity-0 + pointer-events-none 隐藏)。+// 查看「已归档」时设置按钮必须常驻,否则看不到提醒点;折叠按钮不受影响。+function hiddenUntilHover(element: HTMLElement): boolean {+ return element.closest('.opacity-0') !== null;+}+function renderHeader(status: 'active' | 'archived' | 'all') {+ render(+ <MainListScopeHeader+ filter={{ status } as UseSidebarFilterReturn}+ allKnownProjects={[]}+ hasRemoteDevices={false}+ fold={{ label: 'fold', Icon: ChevronsUpDown, onClick: vi.fn(), disabled: false }}+ />,+ );+ return {+ settings: screen.getByRole('button', { name: 'display-settings' }),+ fold: screen.getByRole('button', { name: 'fold' }),+ };+}++describe('MainListScopeHeader actions visibility', () => {+ it.each([+ ['active', true],+ ['archived', false],+ ['all', true],+ ] as const)('with the %s filter the settings button hides until hover: %s', (status, hidden) => {+ const { settings, fold } = renderHeader(status);+ expect(hiddenUntilHover(settings)).toBe(hidden);+ expect(hiddenUntilHover(fold)).toBe(true);+ });+});diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SidebarFilterPopover.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SidebarFilterPopover.test.tsxindex 153dab90b8..7a152da6a6 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SidebarFilterPopover.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SidebarFilterPopover.test.tsx@@ -168,6 +168,21 @@ describe('sidebar display settings menu', () => {expect(screen.getAllByRole('menu').length).toBeGreaterThan(1);});+ it('marks the trigger with a dot only while the list shows archived tasks', () => {+ // Dash 反馈:切到「已归档」后列表和平常几乎一样,误以为内容没更新。+ // 「全部」不提醒,所以不能用 status !== 'active' 代替。+ const dot = (status: 'active' | 'archived' | 'all') => {+ const { unmount } = render(+ <SidebarFilterPopover filter={makeFilter({ status })} allKnownProjects={[]} open={false} />,+ );+ const trigger = screen.getByRole('button', { name: /^侧边栏显示设置/ });+ const found = trigger.querySelector('span[aria-hidden]') !== null;+ unmount();+ return found;+ };+ expect([dot('active'), dot('archived'), dot('all')]).toEqual([false, true, false]);+ });+it('hides unavailable grouping choices and their summary without clearing saved device preference', async () => {const filter = makeFilter({ groupBy: 'flat' });render(<Preview filter={filter} remote={false} />);