feat(web-platform): release V0.8.1 常规地图优化
web-platform-ci / TypeScript, lint, unit, build (push) Has been cancelled
web-platform-ci / Playwright E2E (push) Has been cancelled

This commit is contained in:
2026-09-03 13:18:35 +08:00
parent deead17a9a
commit a9b07e0abf
49 changed files with 4987 additions and 569 deletions
+71 -3
View File
@@ -1,8 +1,10 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import type { EditableMapDocument } from './editor/types';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import type { EditableMapDocument, MapEditorInteractionCallbacks } from './editor/types';
import { MapEditorPanel } from './MapEditorPanel';
const interactionProps = {
descriptorPath: 'maps/map/map.json',
onDraftChange: () => {},
onConvert: async () => true,
canConvert: true,
onBindInteraction: () => {},
@@ -34,18 +36,84 @@ describe('MapEditorPanel', () => {
);
fireEvent.click(screen.getByRole('button', { name: '新增' }));
fireEvent.change(screen.getByLabelText('对象位置X'), { target: { value: '2' } });
fireEvent.change(screen.getByLabelText('对象滑动摩擦'), { target: { value: '0.8' } });
fireEvent.change(screen.getByLabelText('对象颜色'), { target: { value: '#ff0000' } });
fireEvent.click(screen.getByRole('button', { name: '应用并重新编译' }));
await waitFor(() => expect(apply).toHaveBeenCalled());
expect(preview).not.toHaveBeenLastCalledWith(null);
expect(apply.mock.calls[0][0]).toEqual(
expect.objectContaining({
revision: 1,
objects: [
expect.objectContaining({ pose: expect.objectContaining({ position: [2, 0, 0.5] }) }),
expect.objectContaining({
pose: expect.objectContaining({ position: [2, 0, 0.5] }),
friction: [0.8, 0.005, 0.0001],
rgba: [1, 0, 0, 1],
}),
],
}),
);
});
it('把认证资产编辑实时上报为场景级草稿', () => {
const onDraftChange = vi.fn();
render(
<MapEditorPanel
{...interactionProps}
document={document}
loading={false}
onPreview={() => {}}
onDraftChange={onDraftChange}
onApply={async () => true}
onExport={() => {}}
/>,
);
fireEvent.click(screen.getByRole('button', { name: '新增' }));
expect(onDraftChange).toHaveBeenLastCalledWith(
'maps/map/map.json',
expect.objectContaining({ objects: [expect.objectContaining({ type: 'box' })] }),
true,
);
});
it('把外部拾取同步到属性表单和视口操纵器', async () => {
const onSelectPreview = vi.fn();
let interaction: MapEditorInteractionCallbacks | null = null;
render(
<MapEditorPanel
{...interactionProps}
document={{
...document,
objects: [
{
id: 'box_1',
name: '认证方盒',
type: 'box',
pose: { position: [0, 0, 0.5], quaternion: [1, 0, 0, 0] },
parameters: { sizeX: 1, sizeY: 1, sizeZ: 1 },
friction: [1, 0.005, 0.0001],
rgba: [0.55, 0.6, 0.68, 1],
placementMode: 'auto_ground',
enabled: true,
},
],
}}
loading={false}
onPreview={() => {}}
onSelectPreview={onSelectPreview}
onBindInteraction={(callbacks) => {
interaction = callbacks;
}}
onApply={async () => true}
onExport={() => {}}
/>,
);
act(() => interaction?.onSelect('box_1'));
await waitFor(() => expect(onSelectPreview).toHaveBeenLastCalledWith('box_1'));
expect(screen.getByLabelText('对象名称')).toHaveValue('认证方盒');
});
it('锁定放置方式后禁用位姿编辑', () => {
render(
<MapEditorPanel