mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
- Replace ConsolePatcher with centralized debugLogger utility - Refactor errorReporting to use debugLogger instead of file-based reporting - Remove user-facing console message components: - Delete ConsolePatcher.ts, useConsoleMessages.ts/hook - Delete ConsoleSummaryDisplay.tsx, DetailedMessagesDisplay.tsx - Update all tests in packages/core and packages/cli: - Mock debugLogger where needed - Remove assertions for console output on non-critical errors - Keep debugLogger assertions for fatal/network errors - Use HOME directory mocking for hermetic file system tests Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
85 lines
2.5 KiB
TypeScript
85 lines
2.5 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { vi, describe, it, expect, beforeEach } from 'vitest';
|
|
import * as processUtils from '../../utils/processUtils.js';
|
|
import { renderWithProviders } from '../../test-utils/render.js';
|
|
import { IdeTrustChangeDialog } from './IdeTrustChangeDialog.js';
|
|
|
|
describe('IdeTrustChangeDialog', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('renders the correct message for CONNECTION_CHANGE', () => {
|
|
const { lastFrame } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="CONNECTION_CHANGE" />,
|
|
);
|
|
|
|
const frameText = lastFrame();
|
|
expect(frameText).toContain(
|
|
'Workspace trust has changed due to a change in the IDE connection.',
|
|
);
|
|
expect(frameText).toContain("Press 'r' to restart Gemini");
|
|
});
|
|
|
|
it('renders the correct message for TRUST_CHANGE', () => {
|
|
const { lastFrame } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="TRUST_CHANGE" />,
|
|
);
|
|
|
|
const frameText = lastFrame();
|
|
expect(frameText).toContain(
|
|
'Workspace trust has changed due to a change in the IDE trust.',
|
|
);
|
|
expect(frameText).toContain("Press 'r' to restart Gemini");
|
|
});
|
|
|
|
it('renders a generic message for NONE reason', () => {
|
|
const { lastFrame } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="NONE" />,
|
|
);
|
|
|
|
const frameText = lastFrame();
|
|
expect(frameText).toContain('Workspace trust has changed.');
|
|
});
|
|
|
|
it('calls relaunchApp when "r" is pressed', () => {
|
|
const relaunchAppSpy = vi.spyOn(processUtils, 'relaunchApp');
|
|
const { stdin } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="NONE" />,
|
|
);
|
|
|
|
stdin.write('r');
|
|
|
|
expect(relaunchAppSpy).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('calls relaunchApp when "R" is pressed', () => {
|
|
const relaunchAppSpy = vi.spyOn(processUtils, 'relaunchApp');
|
|
const { stdin } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="CONNECTION_CHANGE" />,
|
|
);
|
|
|
|
stdin.write('R');
|
|
|
|
expect(relaunchAppSpy).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('does not call relaunchApp when another key is pressed', async () => {
|
|
const relaunchAppSpy = vi.spyOn(processUtils, 'relaunchApp');
|
|
const { stdin } = renderWithProviders(
|
|
<IdeTrustChangeDialog reason="CONNECTION_CHANGE" />,
|
|
);
|
|
|
|
stdin.write('a');
|
|
|
|
// Give it a moment to ensure no async actions are triggered
|
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
|
|
expect(relaunchAppSpy).not.toHaveBeenCalled();
|
|
});
|
|
});
|