7ebe9092ba
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
53 lines
2.5 KiB
TypeScript
53 lines
2.5 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import { resolve } from 'node:path';
|
|
|
|
for (const kind of ['URDF', 'ZIP'] as const) {
|
|
test(`网站 ${kind} 导入不显示移动操作训练场景,普通导入仍可用`, async ({ page }, info) => {
|
|
let inference = 0;
|
|
const errors: string[] = [];
|
|
page.on('pageerror', (error) => errors.push(error.message));
|
|
await page.route('**/api/decision/v1/**', async (route) => {
|
|
if (/\/(command|plan|decide|test)$/.test(new URL(route.request().url()).pathname)) {
|
|
inference++;
|
|
await route.abort();
|
|
} else await route.continue();
|
|
});
|
|
expect((await page.goto('/'))?.status()).toBe(200);
|
|
await page
|
|
.locator('input[type=file]')
|
|
.first()
|
|
.setInputFiles(
|
|
kind === 'ZIP'
|
|
? resolve('web_platform/assets/robots/lekiwi-v1.zip')
|
|
: {
|
|
name: 'robot.urdf',
|
|
mimeType: 'application/xml',
|
|
buffer: Buffer.from(`<robot name="import-test"><link name="base">
|
|
<inertial><mass value="1"/><inertia ixx=".1" iyy=".1" izz=".1" ixy="0" ixz="0" iyz="0"/></inertial>
|
|
<visual><geometry><box size=".4 .4 .2"/></geometry></visual>
|
|
</link></robot>`),
|
|
},
|
|
);
|
|
const dialog = page.getByRole('dialog', { name: '配置 URDF 仿真组件' });
|
|
await expect(dialog).toBeVisible({ timeout: 30000 });
|
|
const profile = dialog.getByLabel('URDF 机器人 profile');
|
|
await expect(profile).toHaveValue('');
|
|
await expect(profile.locator('option')).toHaveText([
|
|
'不启用(通用转换)',
|
|
'LeKiwi v1(仿真专用)',
|
|
]);
|
|
await expect(dialog.getByText(/移动操作训练场景|强化学习任务即可一键训练/)).toHaveCount(0);
|
|
await expect(dialog.getByRole('checkbox', { name: /为关节添加驱动器/ })).toBeEnabled();
|
|
await page.screenshot({ path: info.outputPath('import-options.png') });
|
|
if (kind === 'ZIP') await profile.selectOption('lekiwi-v1');
|
|
await dialog.getByRole('button', { name: '转换并加载' }).click();
|
|
await expect(dialog).not.toBeVisible();
|
|
await expect(page.getByRole('button', { name: '▶ 播放' })).toBeEnabled({ timeout: 90000 });
|
|
await page.getByRole('tab', { name: '控制台', exact: true }).click();
|
|
await expect(page.getByRole('button', { name: '强化学习任务', exact: true })).toHaveCount(0);
|
|
await expect(page.getByRole('button', { name: '机器人语言控制', exact: true })).toBeVisible();
|
|
expect(inference).toBe(0);
|
|
expect(errors).toEqual([]);
|
|
});
|
|
}
|