Path: blob/main/src/vs/sessions/contrib/agentFeedback/test/browser/agentFeedbackEditorOverlayWidget.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 { DisposableStore } from '../../../../../base/common/lifecycle.js';6import { toAction } from '../../../../../base/common/actions.js';7import { Event } from '../../../../../base/common/event.js';8import { IMenu, IMenuActionOptions, IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from '../../../../../platform/actions/common/actions.js';9import { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup, registerWorkbenchServices } from '../../../../../workbench/test/browser/componentFixtures/fixtureUtils.js';10import { AgentFeedbackOverlayWidget } from '../../browser/agentFeedbackEditorOverlay.js';11import { clearAllFeedbackActionId, navigateNextFeedbackActionId, navigatePreviousFeedbackActionId, navigationBearingFakeActionId, submitFeedbackActionId } from '../../browser/agentFeedbackEditorActions.js';1213interface INavigationBearings {14readonly activeIdx: number;15readonly totalCount: number;16}1718interface IFixtureOptions {19readonly navigationBearings: INavigationBearings;20readonly hasAgentFeedbackActions?: boolean;21}2223class FixtureMenuService implements IMenuService {24constructor(private readonly _hasAgentFeedbackActions: boolean) {25}2627declare readonly _serviceBrand: undefined;2829createMenu(_id: MenuId): IMenu {30const navigateActions = [31toAction({ id: navigationBearingFakeActionId, label: 'Navigation Status', run: () => { } }),32toAction({ id: navigatePreviousFeedbackActionId, label: 'Previous', class: 'codicon codicon-arrow-up', run: () => { } }),33toAction({ id: navigateNextFeedbackActionId, label: 'Next', class: 'codicon codicon-arrow-down', run: () => { } }),34] as unknown as (MenuItemAction | SubmenuItemAction)[];3536const submitActions = this._hasAgentFeedbackActions37? [38toAction({ id: submitFeedbackActionId, label: 'Submit', class: 'codicon codicon-send', run: () => { } }),39toAction({ id: clearAllFeedbackActionId, label: 'Clear', class: 'codicon codicon-clear-all', run: () => { } }),40] as unknown as (MenuItemAction | SubmenuItemAction)[]41: [];4243return {44onDidChange: Event.None,45dispose: () => { },46getActions: () => submitActions.length > 047? [48['navigate', navigateActions],49['a_submit', submitActions],50]51: [52['navigate', navigateActions],53],54};55}5657getMenuActions(_id: MenuId, _contextKeyService: unknown, _options?: IMenuActionOptions) { return []; }58getMenuContexts() { return new Set<string>(); }59resetHiddenStates() { }60}6162function renderWidget(context: ComponentFixtureContext, options: IFixtureOptions): void {63const scopedDisposables = context.disposableStore.add(new DisposableStore());64context.container.classList.add('monaco-workbench');65context.container.style.width = '420px';66context.container.style.height = '64px';67context.container.style.padding = '12px';68context.container.style.background = 'var(--vscode-editor-background)';6970const instantiationService = createEditorServices(scopedDisposables, {71colorTheme: context.theme,72additionalServices: reg => {73registerWorkbenchServices(reg);74reg.defineInstance(IMenuService, new FixtureMenuService(options.hasAgentFeedbackActions ?? true));75},76});7778const widget = scopedDisposables.add(instantiationService.createInstance(AgentFeedbackOverlayWidget));79widget.show(options.navigationBearings);80context.container.appendChild(widget.getDomNode());81}8283export default defineThemedFixtureGroup({ path: 'sessions/agentFeedback/' }, {84ZeroOfZero: defineComponentFixture({85labels: { kind: 'screenshot' },86render: context => renderWidget(context, {87navigationBearings: { activeIdx: -1, totalCount: 0 },88hasAgentFeedbackActions: false,89}),90}),9192SingleFeedback: defineComponentFixture({93labels: { kind: 'screenshot' },94render: context => renderWidget(context, {95navigationBearings: { activeIdx: 0, totalCount: 1 },96}),97}),9899FirstOfThree: defineComponentFixture({100labels: { kind: 'screenshot' },101render: context => renderWidget(context, {102navigationBearings: { activeIdx: -1, totalCount: 3 },103}),104}),105106ReviewOnlyTwoComments: defineComponentFixture({107labels: { kind: 'screenshot' },108render: context => renderWidget(context, {109navigationBearings: { activeIdx: 0, totalCount: 2 },110hasAgentFeedbackActions: false,111}),112}),113114MiddleOfThree: defineComponentFixture({115labels: { kind: 'screenshot' },116render: context => renderWidget(context, {117navigationBearings: { activeIdx: 1, totalCount: 3 },118}),119}),120121MixedFourComments: defineComponentFixture({122labels: { kind: 'screenshot' },123render: context => renderWidget(context, {124navigationBearings: { activeIdx: 2, totalCount: 4 },125hasAgentFeedbackActions: true,126}),127}),128129LastOfThree: defineComponentFixture({130labels: { kind: 'screenshot' },131render: context => renderWidget(context, {132navigationBearings: { activeIdx: 2, totalCount: 3 },133}),134}),135});136137138