Close WeChat QR flow when binding is confirmed

This commit is contained in:
2026-09-20 10:36:29 +08:00
parent e04787763b
commit c953126284
5 changed files with 160 additions and 14 deletions

View File

@@ -95,7 +95,7 @@ test('own WeChat conversation approval and generated PPT delivery in the desktop
expect(calls.find(call => call.operation === 'channelConversationControl')?.input).toMatchObject({ session_id: 'self-session', run_id: 'channel-run', action: 'resume', decision: { decisions: [{ type: 'approve' }] } });
expect(calls.find(call => call.operation === 'downloadChannelArtifact')?.input).toEqual({ session_id: 'self-session', path: '/outputs/创作建议.pptx' });
expect(calls.some(call => call.operation === 'resume' || call.operation === 'submit')).toBe(false);
await page.getByRole('button', { name: '发布与访问', exact: true }).click();
await page.getByRole('button', { name: '使用与接入', exact: true }).click();
const linked = page.getByRole('region', { name: '已关联渠道', exact: true });
await expect(linked.getByText('创作微信', { exact: true })).toBeVisible();
await expect(page.getByRole('region', { name: '个人微信渠道', exact: true })).toHaveCount(0);
@@ -115,12 +115,20 @@ test('own WeChat conversation approval and generated PPT delivery in the desktop
await page.getByLabel('微信验证码', { exact: true }).fill('123456');
await page.getByRole('button', { name: '提交验证码', exact: true }).click();
await expect.poll(async () => app.evaluate(() => (globalThis as typeof globalThis & { cloudChannelFixtureCalls: { operation: string; input: unknown }[] }).cloudChannelFixtureCalls.some(call => call.operation === 'channelAccountWechatBindVerification'))).toBe(true);
if (await page.getByRole('button', { name: '关闭二维码', exact: true }).count()) await page.getByRole('button', { name: '关闭二维码', exact: true }).click();
await expect(page.getByRole('img', { name: '个人微信登录二维码', exact: true })).toHaveCount(0);
await expect(page.getByLabel('微信验证码', { exact: true })).toHaveCount(0);
await expect(spareDetail.getByRole('status')).toContainText('微信已连接');
await expect(spareDetail.getByRole('status')).toContainText('选择目标智能体');
await spareDetail.getByRole('status').scrollIntoViewIfNeeded();
await page.screenshot({ path: testInfo.outputPath('wechat-binding-completed.png'), fullPage: true });
await spareDetail.getByLabel('目标智能体', { exact: true }).selectOption(agentSlug);
await spareDetail.getByRole('button', { name: '保存目标', exact: true }).click();
await expect.poll(async () => app.evaluate(() => (globalThis as typeof globalThis & { cloudChannelFixtureCalls: { operation: string; input: Record<string, unknown> }[] }).cloudChannelFixtureCalls
.filter(call => call.operation === 'routeChannelAccount').some(call => call.input.channel_account_id === 'wechat-b' && call.input.target_agent_slug === 'ml-' + 'a'.repeat(32)))).toBe(true);
await expect(page.getByRole('button', { name: /备用微信.*我的创作助手/ })).toBeVisible();
await expect(spareDetail.getByRole('status')).toContainText('点击“启用”');
await spareDetail.getByRole('button', { name: '启用', exact: true }).click();
await expect(spareDetail.getByRole('status')).toContainText('返回微信与智能体对话');
await page.getByRole('button', { name: /创作微信.*我的创作助手/ }).click();
const legacyDetail = page.getByRole('article', { name: '创作微信账号详情', exact: true });
const qrStartsBeforeSwitch = await app.evaluate(() => (globalThis as typeof globalThis & { cloudChannelFixtureCalls: { operation: string }[] }).cloudChannelFixtureCalls.filter(call => call.operation === 'channelAccountWechatBindStart').length);