feat: add user-level WeChat channel accounts
This commit is contained in:
@@ -201,6 +201,24 @@ describe('Main cloud Agents boundary', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('routes user-level channel accounts without requiring an Agent slug', () => {
|
||||
const list = operationPlan({ operation: 'channelAccounts', input: {} });
|
||||
expect(list.path).toBe('/api/makelore/channel-accounts');
|
||||
expect(list.project({ items: [{ id: 'wechat-1', display_name: '工作微信', revision: 2, enabled: false, status: 'paused', health: 'connected',
|
||||
blockers: ['target_required'], target_agent_slug: null, target_agent_name: null, target_agent_published_version: null, access_token: 'private' }] })).toEqual({
|
||||
items: [{ id: 'wechat-1', display_name: '工作微信', revision: 2, enabled: false, status: 'paused', health: 'connected',
|
||||
blockers: ['target_required'], target_agent_slug: null, target_agent_name: null, target_agent_published_version: null }],
|
||||
});
|
||||
const route = operationPlan({ operation: 'routeChannelAccount', input: { channel_account_id: 'wechat-1', operation_id: 'op-route',
|
||||
target_agent_slug: draft.slug, expected_revision: 2, enabled: true } });
|
||||
expect(route.path).toBe('/api/makelore/channel-accounts/wechat-1/route');
|
||||
expect(route.body).toEqual({ operation_id: 'op-route', target_agent_slug: draft.slug, expected_revision: 2, enabled: true });
|
||||
expect(() => operationPlan({ operation: 'routeChannelAccount', input: { channel_account_id: 'wechat-1', operation_id: 'op-route',
|
||||
target_agent_slug: null, expected_revision: 2, enabled: true } })).toThrow('invalid_input');
|
||||
expect(operationPlan({ operation: 'channelAccountOperation', input: { operation_id: 'op-route' } }).path)
|
||||
.toBe('/api/makelore/channel-operations/op-route');
|
||||
});
|
||||
|
||||
it('recovers a completed WeChat verification from its receipt without replaying the code', async () => {
|
||||
const fetchImpl = vi.fn().mockResolvedValueOnce(session()).mockRejectedValueOnce(new Error('lost response'))
|
||||
.mockResolvedValueOnce(json({ operation_id: input.operation_id, status: 'completed', result: { channel: { id: 'channel-1' } } }));
|
||||
@@ -216,6 +234,19 @@ describe('Main cloud Agents boundary', () => {
|
||||
expect(fetchImpl.mock.calls[2][0]).toContain(`/api/makelore/channel-operations/${input.operation_id}?agent_slug=${draft.slug}`);
|
||||
});
|
||||
|
||||
it('recovers user-level WeChat verification without an Agent slug', async () => {
|
||||
const fetchImpl = vi.fn().mockResolvedValueOnce(session()).mockRejectedValueOnce(new Error('lost response'))
|
||||
.mockResolvedValueOnce(json({ operation_id: input.operation_id, status: 'completed', result: { channel: { id: 'channel-1' } } }));
|
||||
const module = moduleFor(fetchImpl);
|
||||
const verification = { channel_account_id: 'channel-1', operation_id: input.operation_id, session_key: 'session-1', verify_code: 'secret-code-123' };
|
||||
await expect(module.execute({ operation: 'channelAccountWechatBindVerification', input: verification })).rejects.toMatchObject({ code: 'cloud_service_unavailable' });
|
||||
const pending = (await module.recovery()).pending[0];
|
||||
expect(pending.input).not.toHaveProperty('verify_code');
|
||||
expect(await module.resolvePending({ id: pending.id })).toMatchObject({ operation: 'channelAccountWechatBindVerification', result: { status: 'completed' } });
|
||||
expect(fetchImpl.mock.calls[2][0]).toContain(`/api/makelore/channel-operations/${input.operation_id}`);
|
||||
expect(fetchImpl.mock.calls[2][0]).not.toContain('agent_slug');
|
||||
});
|
||||
|
||||
it('asks for a new WeChat verification code only when its receipt is absent', async () => {
|
||||
const fetchImpl = vi.fn().mockResolvedValueOnce(session()).mockRejectedValueOnce(new Error('lost response'))
|
||||
.mockResolvedValueOnce(json({ detail: { code: 'operation_not_found' } }, 404));
|
||||
|
||||
Reference in New Issue
Block a user