Files
Mujoco_WASM/web_platform/e2e/website.spec.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

54 lines
3.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { writeFile } from 'node:fs/promises';
import { loadWebsiteRobot, runWebsiteCommand, readRobotResult } from './website.helpers';
test('服务器内置设置+假 HTTP 上游:不同语言改变真实 WASM 位移与角度,不重载机器人', async ({
page,
}, info) => {
const panel = await loadWebsiteRobot(page);
const forward = await runWebsiteCommand(page, '前进0.5米', info, 'forward');
expect(forward.distance).toBeGreaterThan(0.49);
expect(forward.distance).toBeLessThan(0.51);
const turn = await runWebsiteCommand(page, '左转90度', info, 'turn');
expect(turn.turnDegrees).toBeGreaterThan(89);
expect(turn.turnDegrees).toBeLessThan(91);
expect(turn.start.x).toBeCloseTo(forward.sample.x, 2);
const next = await runWebsiteCommand(page, '前进0.2米', info, 'forward-new-heading');
expect(next.sample.y - next.start.y).toBeGreaterThan(0.19);
const right = await runWebsiteCommand(page, '右转90度', info, 'turn-right');
expect(right.turnDegrees).toBeGreaterThan(-91);
expect(right.turnDegrees).toBeLessThan(-89);
const back = await runWebsiteCommand(page, '后退0.2米', info, 'backward');
expect(back.sample.x - back.start.x).toBeLessThan(-0.19);
await panel.getByRole('textbox', { name: '机器人指令' }).fill('转动90度');
await panel.getByRole('button', { name: '执行指令', exact: true }).click();
await expect(panel.getByRole('status')).toContainText('请说明左转还是右转');
await expect(panel.getByTestId('robot-command-state')).toHaveCount(0);
await expect(page.getByRole('button', { name: '▶ 播放' })).toBeVisible();
});
test('内置设置+假 HTTP 上游:保留完整单方块真实物理抓放,不手填密钥', async ({ page }, info) => {
const panel = await loadWebsiteRobot(page);
await panel.getByRole('button', { name: '载入预设场景' }).click();
await expect(panel.getByRole('status')).toContainText('预设已载入', { timeout: 90000 });
const data = await runWebsiteCommand(page, '把方块搬到 B 区', info, 'pick-place');
expect(data.transported).toBeGreaterThanOrEqual(0.5);
expect(data.sample.onGoalSupport).toBe(true);
expect(data.receipts).toHaveLength(14);
});
test('正在运动时停止:撤销控制权并暂停物理,不把中断当成功', async ({ page }, info) => {
const panel = await loadWebsiteRobot(page);
await panel.getByRole('textbox', { name: '机器人指令' }).fill('前进0.5米');
await panel.getByRole('button', { name: '执行指令', exact: true }).click();
await expect(panel.getByTestId('robot-command-state')).toContainText('执行中', {
timeout: 30000,
});
await panel.getByRole('button', { name: '停止', exact: true }).click();
await expect(panel.getByTestId('robot-command-state')).toContainText('已停止');
await expect(page.getByRole('button', { name: '▶ 播放' })).toBeVisible();
const data = await readRobotResult(page);
expect(data.state).toBe('cancelled');
expect(data.succeeded).toBe(false);
expect(data.distance).toBeLessThan(0.1);
await writeFile(info.outputPath('cancelled-motion.json'), JSON.stringify(data, null, 2));
});