Files
Mujoco_WASM/web_platform/src/mobile/agent/LanguageScene.test.ts
T
chenlin 0d986f60bd
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
feat: release v1.0.2 LeKiwi 语言控制与网站嵌入
集成服务器托管模型、自然语言移动与有界抓放、内置 LeKiwi URL 导入和双摄像头;同步部署契约与指定域名 iframe 白名单,保留原有物理安全、会话及调用预算防护。

更新 npm 包及锁文件版本、CHANGELOG 与发布文档。提交前 typecheck、120 项定向前端测试和 44 项后端测试通过(3 项可选跳过);真实 v2 云模型抓放仍待单独验收,不包含运行密钥或构建产物。
2026-09-24 15:29:49 +08:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { LANGUAGE_VERSION, resolveTarget } from './LanguageScene';
import { validateRobotCommand } from './RobotCommand';
describe('语言任务目标', () => {
it('命名区与连续坐标使用同一支撑面,不修改场景', () => {
expect(resolveTarget('B')).toEqual({ position: [0.257, 0.75, 0.128], supportId: 'table' });
expect(resolveTarget('coordinates', [0.25, 0.5])).toEqual({
position: [0.25, 0.5, 0.128],
supportId: 'table',
});
expect(resolveTarget('coordinates', [0.257, 0.015, 0.128]).supportId).toBe('source');
});
it.each([
[0.2, 0.5],
[0.25, 0.9],
[0.25, 0.5, 0.3],
[NaN, 0.5],
[Infinity, 0.5],
])('rejects unsafe %s', (...p) => {
expect(() => resolveTarget('coordinates', p)).toThrow();
});
it('拒绝模型覆盖命名区、未知目标与不匹配支撑', () => {
const c = {
version: LANGUAGE_VERSION,
action: 'pick_place',
value: 0,
summary: '搬运',
objectId: 'block',
targetId: 'B',
position: [],
supportId: 'table',
};
expect(validateRobotCommand(c).targetId).toBe('B');
for (const invalid of [
{ position: [0.25, 0.5] },
{ targetId: 'C' },
{ supportId: 'source' },
{ code: 'run()' },
])
expect(() => validateRobotCommand({ ...c, ...invalid })).toThrow();
});
});