Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
test(wechat): verify settings search anchors through rendered cards
Chrise0a59060259d
diff --git a/apps/desktop/src/renderer/components/settings/__tests__/WechatBotSection.test.tsx b/apps/desktop/src/renderer/components/settings/__tests__/WechatBotSection.test.tsxindex 649b8f8687..099eba0c50 100644--- a/apps/desktop/src/renderer/components/settings/__tests__/WechatBotSection.test.tsx+++ b/apps/desktop/src/renderer/components/settings/__tests__/WechatBotSection.test.tsx@@ -3,6 +3,7 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react';import { beforeEach, describe, expect, it, vi } from 'vitest';import { WechatBotSection } from '../WechatBotSection';+import { SETTINGS_SEARCH_ENTRIES } from '../settingsSearchCatalog';const mocks = vi.hoisted(() => ({confirm: vi.fn(),@@ -56,25 +57,13 @@ vi.mock('../ImDefaultSettingsSection', () => ({ImDefaultSettingsSection: () => <div data-testid="defaults" />,}));-vi.mock('../ImChannelSettingsCard', () => ({+vi.mock('../ImChannelSettingsCard', async (importOriginal) => ({+ ...await importOriginal<typeof import('../ImChannelSettingsCard')>(),useImChannelSettingsSummary: () => [null, vi.fn()],- ImChannelSettingsCard: ({- title,- status,- children,- }: {- title: string;- status: React.ReactNode;- children: React.ReactNode;- }) => (- <section>- <h2>{title}</h2>- {status}- {children}- </section>- ),}));+const searchTarget = SETTINGS_SEARCH_ENTRIES.find((entry) => entry.id === 'imBot.wechat')!.targetId;+describe('WechatBotSection', () => {beforeEach(() => {vi.clearAllMocks();@@ -96,6 +85,8 @@ describe('WechatBotSection', () => {mocks.state = { phase: 'connected', bound: true, queuedTasks: 0 };render(<WechatBotSection expanded onToggle={vi.fn()} companion={{ id: 'bot-cindy', name: 'Cindy' }} />);expect(screen.queryByTestId('defaults')).toBeNull();+ expect(document.getElementById(`${searchTarget}-trigger`)).toBeNull();+ expect(screen.getByRole('region').getAttribute('id')).toBe('companion-im-wechat-panel');fireEvent.click(screen.getByRole('button', { name: 'settings.wechatBot.companion.useExisting' }));await waitFor(() => expect(mocks.setCompanion).toHaveBeenCalledWith('bot-cindy'));expect(mocks.authorize).not.toHaveBeenCalled();@@ -107,7 +98,8 @@ describe('WechatBotSection', () => {mocks.companionBotId = 'bot-other';render(<WechatBotSection expanded onToggle={vi.fn()} companion={{ id: 'bot-cindy', name: 'Cindy' }} />);expect(screen.getByText('settings.wechatBot.companion.other')).toBeTruthy();- expect(screen.queryByRole('button')).toBeNull();+ expect(screen.getAllByRole('button')).toHaveLength(1);+ expect(screen.getByRole('button').getAttribute('aria-controls')).toBe('companion-im-wechat-panel');});it('does not open authorization if assigning the teammate fails', async () => {@@ -118,8 +110,17 @@ describe('WechatBotSection', () => {expect(mocks.authorize).not.toHaveBeenCalled();});- it('explains the external Tencent authorization flow before starting it', async () => {- render(<WechatBotSection expanded onToggle={vi.fn()} />);+ // CI #39297827964: verify the catalog's dynamic WeChat target in the real card DOM+ // (unit tier), rather than assuming every anchor is a literal JSX attribute.+ it('preserves the personal search target and explains authorization before starting it', async () => {+ const onToggle = vi.fn();+ render(<WechatBotSection expanded onToggle={onToggle} />);+ const trigger = document.getElementById(`${searchTarget}-trigger`);+ expect(trigger).not.toBeNull();+ expect(trigger!.getAttribute('aria-controls')).toBe(`${searchTarget}-panel`);+ expect(document.getElementById(`${searchTarget}-panel`)?.getAttribute('role')).toBe('region');+ fireEvent.click(trigger!);+ expect(onToggle).toHaveBeenCalledOnce();fireEvent.click(screen.getByRole('button', { name: 'settings.wechatBot.actions.connect' }));diff --git a/apps/desktop/src/renderer/components/settings/__tests__/settingsSearchCatalog.test.ts b/apps/desktop/src/renderer/components/settings/__tests__/settingsSearchCatalog.test.tsindex ce628c1549..87ef56c9cb 100644--- a/apps/desktop/src/renderer/components/settings/__tests__/settingsSearchCatalog.test.ts+++ b/apps/desktop/src/renderer/components/settings/__tests__/settingsSearchCatalog.test.ts@@ -187,6 +187,9 @@ describe('settings search catalog', () => {SETTINGS_SEARCH_ENTRIES.flatMap((entry) => [entry.targetId, entry.fallbackTargetId]),);for (const target of targets) {+ // The shared WeChat component selects its anchor at runtime. Its catalog target+ // and companion isolation are checked against real DOM in WechatBotSection.test.tsx.+ if (target === 'personal-im-wechat') continue;if (target) {const dynamicProviderAnchor =/^cindy-im-(slack|telegram|x)$/.test(target) &&