fix: recover Robot configuration loading
This commit is contained in:
@@ -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: '重新指派' }));
|
||||
|
||||
Reference in New Issue
Block a user