Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

test(desktop): cover single-speaker group settings in ui:check

zqchrisd53744eaf06b
diff --git a/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx b/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
index f163fb2862..0f435ba8f7 100644
--- a/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
+++ b/apps/desktop/scripts/fixtures/group-control/group-control-fixture.tsx
@@ -1,6 +1,10 @@
-import { Route, Routes } from 'react-router-dom';
+import { useEffect } from 'react';
+import { Route, Routes, useSearchParams } from 'react-router-dom';
import { AppFrame, forbid, mountPage, subscription } from '../../ui-page/harness';
import { BotGroupChatView } from '../../../src/renderer/features/bots/BotGroupChatView';
+import { BotGroupSettingsDrawer } from '../../../src/renderer/features/bots/BotGroupSettingsDrawer';
+import { BOT_GROUP_SETTINGS_PARAM } from '../../../src/renderer/features/bots/botGroupPresentation';
+import { refreshBotGroups } from '../../../src/renderer/features/bots/botGroupStore';
import { ControlledBanner } from '../../../src/renderer/features/remote-device/ControlledBanner';
interface GroupData {
@@ -13,6 +17,8 @@ interface GroupData {
wrappedReactions?: boolean;
/** A single-speaker server group: the lead answered and lined up a discussion (bot-group-chat.md §4.0/§7.0). */
arrangement?: 'waiting' | 'auto';
+ /** Open the group settings drawer as its owner. */
+ settings?: boolean;
}
const T0 = 1700000000000;
@@ -133,12 +139,15 @@ function groupFrom(data: GroupData) {
name: data.name,
replyMode: 'all',
speakingMode: 'auto',
- members: data.members.map((member) => ({
+ members: [...(data.settings ? [{ botId: '', actorId: 'me', actorKind: 'user', name: 'You', isSelf: true, isOwned: true, role: 'owner', avatar: '', avatarColor: 'gray', status: 'active' }] : []),
+ ...data.members.map((member) => ({
...member,
+ ...(data.settings ? { actorId: `bot-${member.botId}`, actorKind: 'bot', isOwned: true, role: 'member' } : {}),
avatar: '',
avatarColor: 'gray',
status: 'active',
- })),
+ }))],
+ ...(data.settings ? { revision: 1 } : {}),
organizerBotId: data.members[0]?.botId ?? null,
projectDir: null,
lastMessage: null,
@@ -177,7 +186,7 @@ void mountPage({
const group = groupFrom(ctx.data as unknown as GroupData);
return {
maker: {
- listBotGroups: async () => ({ ok: true, groups: [] }),
+ listBotGroups: async () => ({ ok: true, groups: (ctx.data as unknown as GroupData).settings ? [group] : [] }),
getBotGroup: async () => ({ ok: true, group }),
onBotGroupChanged: subscription('botGroupChanged'),
sendBotGroupMessage: forbid('maker.sendBotGroupMessage'),
@@ -185,7 +194,10 @@ void mountPage({
chatServer: {
reactors: async () => ({ ok: true, reactors: [{ actorId: 'me', isSelf: true, name: 'You', formerMember: false }] }),
react: forbid('maker.chatServer.react'),
+ ownedBots: async () => ({ ok: true, bots: [] }),
+ manage: forbid('maker.chatServer.manage'),
},
+ updateBotGroup: forbid('maker.updateBotGroup'),
},
deviceLink: {
getState: async () => ({ controlledBy: [] }),
@@ -207,7 +219,16 @@ void mountPage({
</div>
</AppFrame>
<ControlledBanner />
+ {data.settings ? <OpenSettings /> : null}
</>
);
},
});
+
+/** The drawer is route-owned: open it the way the header button does. */
+function OpenSettings() {
+ const [, setSearchParams] = useSearchParams();
+ // The drawer reads the shared group list, which the sidebar normally loads.
+ useEffect(() => { refreshBotGroups(); setSearchParams({ [BOT_GROUP_SETTINGS_PARAM]: '1' }, { replace: true }); }, [setSearchParams]);
+ return <BotGroupSettingsDrawer />;
+}
diff --git a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
index 6f3273930c..6a803effbb 100644
--- a/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
+++ b/apps/desktop/scripts/fixtures/group-control/ui-page.mjs
@@ -41,6 +41,10 @@ export default {
about: 'The same discussion once every turn is done: no switch or 继续 row, the turn reply carries 第 2 步',
data: { ...base, arrangement: 'auto' },
},
+ settings: {
+ about: 'Single-speaker group settings: no 回复方式 or 发言方式; the 负责人 note says who answers un-addressed messages',
+ data: { ...base, arrangement: 'waiting', settings: true },
+ },
'bubbles-wrapped': {
about: 'PR #6549: wrapped reactions keep both toolbars level with their bubbles; server messages with empty mention ids still open unique member cards',
viewport: { width: 800, height: 800 },
@@ -76,6 +80,15 @@ export default {
await chip.waitFor();
};
+ if (ui.case === 'settings') {
+ const drawer = page.getByRole('dialog');
+ await drawer.getByText('负责人', { exact: true }).waitFor();
+ // Who answers follows @ and the lead; the old group modes are gone.
+ assert.equal(await drawer.getByText('发言方式').count(), 0);
+ assert.equal(await drawer.getByText('没有 @ 人的时候').count(), 0);
+ await drawer.getByText('没有 @ 人的消息由负责人回答', { exact: false }).waitFor();
+ return;
+ }
if (ui.case.startsWith('arrangement')) {
const card = page.getByTestId('bot-group-arrangement');
await card.waitFor();