feat: prepare Zhinian desktop client for pilot release
This commit is contained in:
@@ -489,6 +489,101 @@ describe('agent config lifecycle', () => {
|
||||
expect(snapshot.channelAccountOwners['telegram:default']).toBe('main');
|
||||
});
|
||||
|
||||
it('creates and binds a dedicated channel agent for a default account', async () => {
|
||||
await writeOpenClawJson({
|
||||
agents: {
|
||||
list: [{ id: 'main', name: 'Main', default: true }],
|
||||
},
|
||||
channels: {
|
||||
feishu: { enabled: true },
|
||||
},
|
||||
});
|
||||
await mkdir(join(testHome, '.openclaw', 'workspace'), { recursive: true });
|
||||
await writeFile(join(testHome, '.openclaw', 'workspace', 'AGENTS.md'), 'main instructions', 'utf8');
|
||||
|
||||
const { ensureChannelAgentForAccount, listAgentsSnapshot } = await import('@electron/utils/agent-config');
|
||||
|
||||
await ensureChannelAgentForAccount('feishu', 'default');
|
||||
|
||||
const snapshot = await listAgentsSnapshot();
|
||||
expect(snapshot.agents).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: 'channel-feishu',
|
||||
name: '飞书助手',
|
||||
channelTypes: ['feishu'],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(snapshot.channelAccountOwners['feishu:default']).toBe('channel-feishu');
|
||||
await expect(access(join(testHome, '.openclaw', 'workspace-channel-feishu', 'AGENTS.md'))).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('creates separate channel agents for multiple accounts on the same channel', async () => {
|
||||
await writeOpenClawJson({
|
||||
agents: {
|
||||
list: [{ id: 'main', name: 'Main', default: true }],
|
||||
},
|
||||
channels: {
|
||||
telegram: {
|
||||
enabled: true,
|
||||
accounts: {
|
||||
'telegram-a1b2c3d4': { enabled: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const { ensureChannelAgentForAccount, listAgentsSnapshot } = await import('@electron/utils/agent-config');
|
||||
|
||||
await ensureChannelAgentForAccount('telegram', 'telegram-a1b2c3d4');
|
||||
|
||||
const snapshot = await listAgentsSnapshot();
|
||||
expect(snapshot.agents).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: 'channel-telegram-telegram-a1b2c3d4',
|
||||
name: 'Telegram助手 telegram-a1b2c3d4',
|
||||
channelTypes: ['telegram'],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(snapshot.channelAccountOwners['telegram:telegram-a1b2c3d4']).toBe('channel-telegram-telegram-a1b2c3d4');
|
||||
});
|
||||
|
||||
it('creates an AgentBus channel agent with a readable name', async () => {
|
||||
await writeOpenClawJson({
|
||||
agents: {
|
||||
list: [{ id: 'main', name: 'Main', default: true }],
|
||||
},
|
||||
channels: {
|
||||
agentbus: {
|
||||
enabled: true,
|
||||
accounts: {
|
||||
'acct-20260427-070043-65935ec0': { enabled: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const { ensureChannelAgentForAccount, listAgentsSnapshot } = await import('@electron/utils/agent-config');
|
||||
|
||||
await ensureChannelAgentForAccount('agentbus', 'acct-20260427-070043-65935ec0');
|
||||
|
||||
const snapshot = await listAgentsSnapshot();
|
||||
expect(snapshot.agents).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: 'channel-agentbus-acct-20260427-070043-65935ec0',
|
||||
name: 'AgentBus助手 acct-20260427-070043-65935ec0',
|
||||
channelTypes: ['agentbus'],
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(snapshot.channelAccountOwners['agentbus:acct-20260427-070043-65935ec0'])
|
||||
.toBe('channel-agentbus-acct-20260427-070043-65935ec0');
|
||||
});
|
||||
|
||||
it('avoids numeric-only ids when creating agents from CJK names', async () => {
|
||||
await writeOpenClawJson({
|
||||
agents: {
|
||||
|
||||
Reference in New Issue
Block a user