fix: recover Robot configuration loading

This commit is contained in:
2026-08-15 20:05:16 +08:00
parent a4050f0a65
commit 1bcd51964d
5 changed files with 238 additions and 19 deletions

View File

@@ -366,6 +366,32 @@ describe('AI hardware page', () => {
expect(screen.getByText('正在读取配置')).toBeInTheDocument();
});
it('stops loading and lets the user retry after configuration loading fails', async () => {
api.getAiHardwareOverview.mockResolvedValueOnce({
status: 'active',
agents: [agentOne],
devices: [device],
});
api.getAiHardwareAgentConfiguration
.mockRejectedValueOnce(new AiHardwareApiError({
status: 502,
code: 'xiaozhi_hardware_unavailable',
message: 'private provider details',
retryable: true,
}))
.mockResolvedValueOnce({ data: configuration, revision: 4 });
render(<AiHardware />);
expect(await screen.findByRole('alert')).toHaveTextContent('无法读取智能体配置');
expect(screen.queryByText('正在读取配置')).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '重试读取配置' }));
await waitFor(() => expect(api.getAiHardwareAgentConfiguration).toHaveBeenCalledTimes(2));
expect(await screen.findByText('保持简洁')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '编辑配置' })).toBeEnabled();
});
it('loads the current assignment revision before reassigning a device', async () => {
render(<AiHardware />);
fireEvent.click(await screen.findByRole('button', { name: '重新指派' }));