Path: blob/main/src/vs/workbench/test/browser/componentFixtures/chat/chatTerminalCollapsible.fixture.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as dom from '../../../../../base/browser/dom.js';6import { Event } from '../../../../../base/common/event.js';7import { observableValue } from '../../../../../base/common/observable.js';8import { mock, upcastPartial } from '../../../../../base/test/common/mock.js';9import type { IChatContentPartRenderContext, InlineTextModelCollection } from '../../../../contrib/chat/browser/widget/chatContentParts/chatContentParts.js';10import type { IChatResponseViewModel } from '../../../../contrib/chat/common/model/chatViewModel.js';11import { ChatTerminalThinkingCollapsibleWrapper } from '../../../../contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.js';12import { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup } from '../fixtureUtils.js';1314import '../../../../contrib/chat/browser/widget/media/chat.css';1516function createMockContext(): IChatContentPartRenderContext {17return {18element: new class extends mock<IChatResponseViewModel>() { }(),19elementIndex: 0,20container: document.createElement('div'),21content: [],22contentIndex: 0,23editorPool: undefined!,24codeBlockStartIndex: 0,25treeStartIndex: 0,26diffEditorPool: undefined!,27currentWidth: observableValue('currentWidth', 400),28onDidChangeVisibility: Event.None,29inlineTextModels: upcastPartial<InlineTextModelCollection>({}),30};31}3233function renderCollapsible(context: ComponentFixtureContext, commandText: string, isSandboxWrapped: boolean, isComplete: boolean): void {34const { container, disposableStore } = context;3536const instantiationService = createEditorServices(disposableStore, {37colorTheme: context.theme,38});3940container.style.width = '500px';41container.style.padding = '8px';42container.classList.add('monaco-workbench');4344const session = dom.$('.interactive-session');45container.appendChild(session);4647const contentElement = dom.$('.chat-terminal-output-placeholder');48contentElement.textContent = '(terminal output would appear here)';49contentElement.style.padding = '8px';50contentElement.style.color = 'var(--vscode-descriptionForeground)';5152const wrapper = disposableStore.add(instantiationService.createInstance(53ChatTerminalThinkingCollapsibleWrapper,54commandText,55isSandboxWrapped,56contentElement,57createMockContext(),58false,59isComplete,60));6162session.appendChild(wrapper.domNode);63}6465export default defineThemedFixtureGroup({ path: 'chat/terminalCollapsible/' }, {66'Ran - simple command': defineComponentFixture({67render: ctx => renderCollapsible(ctx, 'ls -lh', false, true),68}),69'Running - simple command': defineComponentFixture({70render: ctx => renderCollapsible(ctx, 'ls -lh', false, false),71}),72'Ran sandbox - simple command': defineComponentFixture({73render: ctx => renderCollapsible(ctx, 'ls -lh', true, true),74}),75'Running sandbox - simple command': defineComponentFixture({76render: ctx => renderCollapsible(ctx, 'ls -lh', true, false),77}),78'Ran - special chars': defineComponentFixture({79render: ctx => renderCollapsible(ctx, 'grep -rn "hello" ./src --include="*.ts"', false, true),80}),81'Ran sandbox - special chars': defineComponentFixture({82render: ctx => renderCollapsible(ctx, 'grep -rn "hello" ./src --include="*.ts"', true, true),83}),84'Ran - backticks': defineComponentFixture({85render: ctx => renderCollapsible(ctx, 'echo `date` && echo `hostname`', false, true),86}),87'Ran sandbox - backticks': defineComponentFixture({88render: ctx => renderCollapsible(ctx, 'echo `date` && echo `hostname`', true, true),89}),90'Ran sandbox - powershell backticks': defineComponentFixture({91render: ctx => renderCollapsible(ctx, 'Get-Process | Where-Object {$_.Name -eq `"notepad`"}', true, true),92}),93});949596