2025-09-10 22:20:13 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { renderWithProviders } from '../../test-utils/render.js';
|
|
|
|
|
import { describe, it, expect, vi } from 'vitest';
|
|
|
|
|
import { LoopDetectionConfirmation } from './LoopDetectionConfirmation.js';
|
|
|
|
|
|
|
|
|
|
describe('LoopDetectionConfirmation', () => {
|
|
|
|
|
const onComplete = vi.fn();
|
|
|
|
|
|
2026-02-18 16:46:50 -08:00
|
|
|
it('renders correctly', async () => {
|
|
|
|
|
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
2025-09-10 22:20:13 -07:00
|
|
|
<LoopDetectionConfirmation onComplete={onComplete} />,
|
2025-10-31 07:43:12 -07:00
|
|
|
{ width: 101 },
|
2025-09-10 22:20:13 -07:00
|
|
|
);
|
2026-02-18 16:46:50 -08:00
|
|
|
await waitUntilReady();
|
2025-09-10 22:20:13 -07:00
|
|
|
expect(lastFrame()).toMatchSnapshot();
|
2026-02-18 16:46:50 -08:00
|
|
|
unmount();
|
2025-09-10 22:20:13 -07:00
|
|
|
});
|
|
|
|
|
|
2026-02-18 16:46:50 -08:00
|
|
|
it('contains the expected options', async () => {
|
|
|
|
|
const { lastFrame, waitUntilReady, unmount } = renderWithProviders(
|
2025-09-10 22:20:13 -07:00
|
|
|
<LoopDetectionConfirmation onComplete={onComplete} />,
|
2025-10-31 07:43:12 -07:00
|
|
|
{ width: 100 },
|
2025-09-10 22:20:13 -07:00
|
|
|
);
|
2026-02-18 16:46:50 -08:00
|
|
|
await waitUntilReady();
|
|
|
|
|
const output = lastFrame();
|
2025-09-10 22:20:13 -07:00
|
|
|
|
|
|
|
|
expect(output).toContain('A potential loop was detected');
|
|
|
|
|
expect(output).toContain('Keep loop detection enabled (esc)');
|
|
|
|
|
expect(output).toContain('Disable loop detection for this session');
|
|
|
|
|
expect(output).toContain(
|
|
|
|
|
'This can happen due to repetitive tool calls or other model behavior',
|
|
|
|
|
);
|
2026-02-18 16:46:50 -08:00
|
|
|
unmount();
|
2025-09-10 22:20:13 -07:00
|
|
|
});
|
|
|
|
|
});
|