feat(tuning): release V0.8.2 Agent 界面重构
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 16:25:53 +08:00
parent a9b07e0abf
commit 63d67a645b
35 changed files with 4847 additions and 811 deletions
@@ -3,6 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { LocalTrainingPanel } from './LocalTrainingPanel';
beforeEach(() => {
vi.restoreAllMocks();
localStorage.clear();
sessionStorage.clear();
vi.unstubAllGlobals();
@@ -101,4 +102,60 @@ describe('LocalTrainingPanel', () => {
expect(await screen.findByRole('button', { name: '发起本地训练' })).toBeInTheDocument();
expect(sessionStorage.getItem('mujoco-local-training-token')).toBe('new-secret-token');
});
it('接收调参窗口传回的策略文件,无需主工作台重复持有令牌', async () => {
const onPolicyReady = vi.fn();
const reply = vi.spyOn(window, 'postMessage').mockImplementation(() => undefined);
render(<LocalTrainingPanel onPolicyReady={onPolicyReady} />);
const policy = new File([new Uint8Array([1, 2, 3])], 'best-policy.onnx', {
type: 'application/octet-stream',
});
window.dispatchEvent(
new MessageEvent('message', {
origin: window.location.origin,
source: window,
data: {
type: 'mujoco-tuning-import-policy',
sessionId: 'a'.repeat(32),
policy,
},
}),
);
await waitFor(() => expect(onPolicyReady).toHaveBeenCalledWith(policy));
expect(reply).toHaveBeenCalledWith(
expect.objectContaining({
type: 'mujoco-tuning-import-policy-result',
ok: true,
}),
window.location.origin,
);
});
it('旧调参消息缺少主工作台令牌时显示错误而不是抛出未处理异常', async () => {
const reply = vi.spyOn(window, 'postMessage').mockImplementation(() => undefined);
render(<LocalTrainingPanel onPolicyReady={vi.fn()} />);
window.dispatchEvent(
new MessageEvent('message', {
origin: window.location.origin,
source: window,
data: {
type: 'mujoco-tuning-import-policy',
sessionId: 'a'.repeat(32),
},
}),
);
expect(await screen.findByRole('alert')).toHaveTextContent('请输入训练服务访问令牌');
expect(reply).toHaveBeenCalledWith(
expect.objectContaining({
type: 'mujoco-tuning-import-policy-result',
ok: false,
error: '请输入训练服务访问令牌',
}),
window.location.origin,
);
});
});