Files
Mujoco_WASM/web_platform/e2e/lekiwi.agent.live.spec.ts
T
chenlin f3a8a38acd
web-platform-ci / Standalone decision service (no cloud credentials) (push) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled
lekiwi-compatibility / cpu-compatibility (push) Has been cancelled
web-platform-ci / Standalone decision service (no cloud credentials) (pull_request) Has been cancelled
web-platform-ci / TypeScript, lint, unit, build (pull_request) Has been cancelled
web-platform-ci / Playwright E2E (pull_request) Has been cancelled
lekiwi-compatibility / cpu-compatibility (pull_request) Has been cancelled
feat: release v1.0.1 CADWorld 网站与 LeKiwi 智能抓放
集成同源 BYOK 会话隔离、精简模型设置、官方订阅入口和 HTTPS 发布运维;保留本地训练/调参与控制能力。同步 npm 版本及 CHANGELOG,记录公网真实 API 验收仍待用户凭据。
2026-09-24 09:57:41 +08:00

80 lines
4.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { expect, test } from '@playwright/test';
import { resolve } from 'node:path';
import { readFile, writeFile } from 'node:fs/promises';
import { startLiveDecisionService } from './fixtures/decisionService';
test.use({ trace: 'off', video: 'off' });
test('显式 opt-in:主工作台 DeepSeek flash + OpenRouter Jev 真实物理回合', async ({
page,
}, info) => {
test.skip(
process.env.LEKIWI_LIVE_API !== '1',
'需明确授权 .env 两个角色与一次付费回合;不自动运行',
);
const service = await startLiveDecisionService();
try {
await page.goto('/');
await page
.locator('input[type="file"]')
.first()
.setInputFiles(resolve('build/lekiwi/lekiwi-v1.zip'));
const dialog = page.getByRole('dialog', { name: '配置 URDF 仿真组件' });
await expect(dialog).toBeVisible({ timeout: 30000 });
await dialog.getByLabel('URDF 机器人 profile').selectOption('lekiwi-v1');
await dialog.getByRole('button', { name: '转换并加载' }).click();
await expect(page.getByRole('button', { name: '▶ 播放' })).toBeEnabled({ timeout: 60000 });
await page.getByRole('tab', { name: '控制台', exact: true }).click();
await page.getByRole('button', { name: 'LeKiwi 智能抓放', exact: true }).click();
const panel = page.getByLabel('LeKiwi 智能抓放任务', { exact: true });
await panel.getByText('模型连接与官方订阅登录', { exact: true }).click();
await panel.getByLabel('本机模型服务', { exact: true }).fill(service.endpoint);
await panel.getByLabel('本机服务令牌', { exact: true }).fill(service.token);
await panel.getByRole('button', { name: '连接本机模型服务', exact: true }).click();
await expect(panel).toContainText('本机桥已连接');
await expect(panel.getByLabel('LLM 型号', { exact: true })).toHaveValue('deepseek-flash');
await expect(panel.getByLabel('JEV 型号', { exact: true })).toHaveValue('typesafe/jev-1.13');
await expect(panel.getByLabel('LLM Base URL', { exact: true })).toHaveValue(
'https://api.deepseek.com',
);
await expect(panel.getByLabel('JEV Base URL', { exact: true })).toHaveValue(
'https://openrouter.ai/api/alpha/decisions',
);
await panel.getByText('模型连接与官方订阅登录', { exact: true }).click();
await panel.getByLabel('智能任务决策模式').selectOption('api');
await panel.getByRole('button', { name: '开始任务(真实 API)', exact: true }).click();
const status = panel.getByTestId('agent-task-state');
await expect(status).toContainText(/物理验收成功|失败 \/ 安全停止|已取消/, { timeout: 240000 });
const pendingDownload = page.waitForEvent('download');
await panel.getByRole('button', { name: '导出任务证据', exact: true }).click();
const downloaded = await pendingDownload;
const data = JSON.parse(await readFile((await downloaded.path())!, 'utf8'));
const encoded = JSON.stringify(data, null, 2);
if (encoded.includes(service.token)) throw new Error('任务导出包含本机令牌');
await writeFile(info.outputPath('live-physical-evidence.json'), encoded);
console.log('真实 API 回合(非订阅)', {
state: data.state,
error: data.error,
llm: data.llmCalls,
jev: data.jevCalls,
simTime: data.sample.time,
transported: data.transported,
models: [...new Set(data.receipts.map((r: { model: string }) => r.model))],
});
expect(data.mode).toBe('api');
expect(data.state, data.error).toBe('succeeded');
expect(data.succeeded).toBe(true);
expect(data.transported).toBeGreaterThanOrEqual(0.5);
expect(data.llmCalls).toBe(1);
expect(data.jevCalls).toBe(11);
expect(data.receipts).toHaveLength(12);
await page.screenshot({ path: info.outputPath('live-workbench.png') });
} catch (error) {
// Playwright action errors may quote input values. Close before automatic DOM diagnostics.
await page.close().catch(() => undefined);
// eslint-disable-next-line preserve-caught-error -- The original cause may contain the private bridge token.
throw new Error(String(error).replaceAll(service.token, '[redacted]'));
} finally {
await service.stop();
}
});