[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DNC657H6KDYQP9GWCNTJZ1":3,"skill-same:01M7DNC657H6KDYQP9GWCNTJZ1":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7DNC657H6KDYQP9GWCNTJZ1","component-fixtures",null,"Use when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, theming, service setup, CSS scoping, async rendering, and common pitfalls.","DragonBallerZ\u002Fdragon-ide","DragonBallerZ","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F199459338?v=4","01M7DN83GSDPNQH3ACEV21SKTQ","Z McDragon","01M7DN83HDR4KMJAMTCB5S4DCJ",12,"MIT","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcomponent-fixtures\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: component-fixtures\ndescription: Use when creating or updating component fixtures for screenshot testing, or when designing UI components to be fixture-friendly. Covers fixture file structure, theming, service setup, CSS scoping, async rendering, and common pitfalls.\n---\n\n# Component Fixtures\n\nComponent fixtures render isolated UI components for visual screenshot testing via the component explorer. Fixtures live in `src\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F` and are auto-discovered by the Vite dev server using the glob `src\u002F**\u002F*.fixture.ts`.\n\nUse tools `mcp_component-exp_`* to list and screenshot fixtures. If you cannot see these tools, inform the user to them on.\n\n## Running Fixtures Locally\n\n1. Start the component explorer server: run the **Component Explorer Server** task\n2. Use the `mcp_component-exp_list_fixtures` tool to see all available fixtures and their URLs\n3. Use the `mcp_component-exp_screenshot` tool to capture screenshots programmatically\n\n## File Structure\n\nEach fixture file exports a default `defineThemedFixtureGroup(...)`. The file must end with `.fixture.ts`.\n\n```\nsrc\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F\n  fixtureUtils.ts              # Shared helpers (DO NOT import @vscode\u002Fcomponent-explorer elsewhere)\n  myComponent.fixture.ts       # Your fixture file\n```\n\n## Basic Pattern\n\n```typescript\nimport { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup } from '.\u002FfixtureUtils.js';\n\nexport default defineThemedFixtureGroup({ path: 'myFeature\u002F' }, {\n    Default: defineComponentFixture({ render: renderMyComponent }),\n    AnotherVariant: defineComponentFixture({ render: renderMyComponent }),\n});\n\nfunction renderMyComponent({ container, disposableStore, theme }: ComponentFixtureContext): void {\n    container.style.width = '400px';\n\n    const instantiationService = createEditorServices(disposableStore, {\n        colorTheme: theme,\n        additionalServices: (reg) => {\n            \u002F\u002F Register additional services the component needs\n            reg.define(IMyService, MyServiceImpl);\n            reg.defineInstance(IMockService, mockInstance);\n        },\n    });\n\n    const widget = disposableStore.add(\n        instantiationService.createInstance(MyWidget, \u002F* constructor args *\u002F)\n    );\n    container.appendChild(widget.domNode);\n}\n```\n\nKey points:\n- **`defineThemedFixtureGroup`** automatically creates Dark and Light variants for each fixture\n- **`defineComponentFixture`** wraps your render function with theme setup and shadow DOM isolation\n- **`createEditorServices`** provides a `TestInstantiationService` with base editor services pre-registered\n- Always register created widgets with `disposableStore.add(...)` to prevent leaks\n- Pass `colorTheme: theme` to `createEditorServices` so theme colors render correctly\n\n### File icon themes\n\nFixtures use Seti file icons by default. Select another built-in theme, or disable file icons, on the individual fixture:\n\n```typescript\ndefineComponentFixture({ fileIconTheme: 'vs-minimal', render: renderMyComponent });\ndefineComponentFixture({ fileIconTheme: 'none', render: renderMyComponent });\n```\n\nWhen the rendered component reads `IThemeService`, pass the selected theme from `ComponentFixtureContext` to `createEditorServices`:\n\n```typescript\nfunction renderMyComponent({ disposableStore, theme, fileIconTheme }: ComponentFixtureContext): void {\n\tconst instantiationService = createEditorServices(disposableStore, {\n\t\tcolorTheme: theme,\n\t\tfileIconTheme,\n\t});\n}\n```\n\n## Utilities from fixtureUtils.ts\n\n| Export | Purpose |\n|---|---|\n| `defineComponentFixture` | Creates Dark\u002FLight themed fixture variants from a render function |\n| `defineThemedFixtureGroup` | Groups multiple themed fixtures into a named fixture group |\n| `createEditorServices` | Creates `TestInstantiationService` with all base editor services |\n| `registerWorkbenchServices` | Registers additional workbench services (context menu, label, etc.) |\n| `createTextModel` | Creates a text model via `ModelService` for editor fixtures |\n| `setupTheme` | Applies theme CSS to a container (called automatically by `defineComponentFixture`) |\n| `darkTheme` \u002F `lightTheme` | Pre-loaded `ColorThemeData` instances |\n\n**Important:** Only `fixtureUtils.ts` may import from `@vscode\u002Fcomponent-explorer`. All fixture files must go through the helpers in `fixtureUtils.ts`.\n\n## CSS Scoping\n\nFixtures render inside shadow DOM. The component-explorer automatically adopts the global VS Code stylesheets and theme CSS.\n\n### Matching production CSS selectors\n\nMany VS Code components have CSS rules scoped to deep ancestor selectors (e.g., `.interactive-session .interactive-input-part > .widget-container .my-element`). In fixtures, you must recreate the required ancestor DOM structure for these selectors to match:\n\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    container.classList.add('interactive-session');\n\n    \u002F\u002F Recreate ancestor structure that CSS selectors expect\n    const inputPart = dom.$('.interactive-input-part');\n    const widgetContainer = dom.$('.widget-container');\n    inputPart.appendChild(widgetContainer);\n    container.appendChild(inputPart);\n\n    widgetContainer.appendChild(myWidget.domNode);\n}\n```\n\n**Design recommendation for new components:** Avoid deeply nested CSS selectors that require specific ancestor elements. Use self-contained class names (e.g., `.my-widget .my-element` rather than `.parent-view .parent-part > .wrapper .my-element`). This makes components easier to fixture and reuse.\n\n## Services\n\n### Using createEditorServices\n\n`createEditorServices` pre-registers these services: `IAccessibilityService`, `IKeybindingService`, `IClipboardService`, `IOpenerService`, `INotificationService`, `IDialogService`, `IUndoRedoService`, `ILanguageService`, `IConfigurationService`, `IStorageService`, `IThemeService`, `IModelService`, `ICodeEditorService`, `IContextKeyService`, `ICommandService`, `ITelemetryService`, `IHoverService`, `IUserInteractionService`, and more.\n\n### Additional services\n\nRegister extra services via `additionalServices`:\n\n```typescript\ncreateEditorServices(disposableStore, {\n    additionalServices: (reg) => {\n        \u002F\u002F Class-based (instantiated by DI):\n        reg.define(IMyService, MyServiceImpl);\n        \u002F\u002F Instance-based (pre-constructed):\n        reg.defineInstance(IMyService, myMockInstance);\n    },\n});\n```\n\n### Mocking services\n\nUse the `mock\u003CT>()` helper from `base\u002Ftest\u002Fcommon\u002Fmock.js` to create mock service instances:\n\n```typescript\nimport { mock } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Fmock.js';\n\nconst myService = new class extends mock\u003CIMyService>() {\n    override someMethod(): string { return 'test'; }\n    override onSomeEvent = Event.None;\n};\nreg.defineInstance(IMyService, myService);\n```\n\nFor mock view models or data objects:\n```typescript\nconst element = new class extends mock\u003CIChatRequestViewModel>() { }();\n```\n\n## Async Rendering\n\nThe component explorer waits **2 animation frames** after the synchronous render function returns. For most components, this is sufficient.\n\nIf your render function returns a `Promise`, the component explorer waits for the promise to resolve.\n\n### Pitfall: DOM reparenting causes flickering\n\nAvoid moving rendered widgets between DOM parents after initial render. This causes:\n- Layout recalculation (the widget jumps as `position: absolute` coordinates become invalid)\n- Focus loss (blur events can trigger hide logic in widgets like QuickInput)\n- Screenshot instability (the component explorer may capture an intermediate layout state)\n\n**Bad pattern — reparenting a widget after async wait:**\n```typescript\nasync function render({ container }: ComponentFixtureContext): Promise\u003Cvoid> {\n    const host = document.createElement('div');\n    container.appendChild(host);\n    \u002F\u002F ... create widget inside host ...\n    await waitForWidget();\n    container.appendChild(widget);  \u002F\u002F BAD: reparenting causes flicker\n    host.remove();\n}\n```\n\n**Better pattern — render in-place with the correct DOM structure from the start:**\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    \u002F\u002F Set up the correct DOM structure first, then create the widget inside it\n    const widget = createWidget(container);\n    container.appendChild(widget.domNode);\n}\n```\n\nIf the component absolutely requires async setup (e.g., QuickInput which renders internally), minimize DOM manipulation after the widget appears by structuring the host container to match the final layout from the beginning.\n\n## Adapting Existing Components for Fixtures\n\nExisting components often need small changes to become fixturable. When writing a fixture reveals friction, fix the component — don't work around it in the fixture. Common adaptations:\n\n### Decouple CSS from ancestor context\n\nIf a component's CSS only works inside a deeply nested selector like `.workbench .sidebar .my-view .my-widget`, refactor the CSS to be self-contained. Move the styles so they're scoped to the component's own root class:\n\n```css\n\u002F* Before: requires specific ancestors *\u002F\n.workbench .sidebar .my-view .my-widget .header { font-weight: bold; }\n\n\u002F* After: self-contained *\u002F\n.my-widget .header { font-weight: bold; }\n```\n\nIf the component shares styles with its parent (e.g., inheriting background color), use CSS custom properties rather than relying on ancestor selectors.\n\n### Extract hard-coded service dependencies\n\nIf a component reaches into singletons or global state instead of using DI, refactor it to accept services through the constructor:\n\n```typescript\n\u002F\u002F Before: hard to mock in fixtures\nclass MyWidget {\n    private readonly config = getSomeGlobalConfig();\n}\n\n\u002F\u002F After: injectable and testable\nclass MyWidget {\n    constructor(@IConfigurationService private readonly configService: IConfigurationService) { }\n}\n```\n\n### Add options to control auto-focus and animation\n\nComponents that auto-focus on creation or run animations cause flaky screenshots. Add an options parameter:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;\n}\n```\n\nThe fixture passes `shouldAutoFocus: false`. The production call site keeps the default behavior.\n\n### Expose internal state for \"already completed\" rendering\n\nMany components have lifecycle states (loading → active → completed). If the component can only reach the \"completed\" state through user interaction, add support for initializing directly into that state via constructor data:\n\n```typescript\n\u002F\u002F The fixture can pass pre-filled data to render the summary\u002Fcompleted state\n\u002F\u002F without simulating the full user interaction flow.\nconst carousel: IChatQuestionCarousel = {\n    questions,\n    allowSkip: true,\n    kind: 'questionCarousel',\n    isUsed: true,           \u002F\u002F Already completed\n    data: { 'q1': 'answer' }, \u002F\u002F Pre-filled answers\n};\n```\n\n### Make DOM node accessible\n\nIf a component builds its DOM internally and doesn't expose the root element, add a public `readonly domNode: HTMLElement` property so fixtures can append it to the container.\n\n## Writing Fixture-Friendly Components\n\nWhen designing new UI components, follow these practices to make them easy to fixture:\n\n### 1. Accept a container element in the constructor\n\n```typescript\n\u002F\u002F Good: container is passed in\nclass MyWidget {\n    constructor(container: HTMLElement, @IFoo foo: IFoo) {\n        this.domNode = dom.append(container, dom.$('.my-widget'));\n    }\n}\n\n\u002F\u002F Also good: widget creates its own domNode for the caller to place\nclass MyWidget {\n    readonly domNode: HTMLElement;\n    constructor(@IFoo foo: IFoo) {\n        this.domNode = dom.$('.my-widget');\n    }\n}\n```\n\n### 2. Use dependency injection for all services\n\nAll external dependencies should come through DI so fixtures can provide test implementations:\n\n```typescript\n\u002F\u002F Good: services injected\nconstructor(@IThemeService private readonly themeService: IThemeService) { }\n\n\u002F\u002F Bad: reaching into globals\nconstructor() { this.theme = getGlobalTheme(); }\n```\n\n### 3. Keep CSS selectors shallow\n\n```css\n\u002F* Good: self-contained, easy to fixture *\u002F\n.my-widget .my-header { ... }\n.my-widget .my-list-item { ... }\n\n\u002F* Bad: requires deep ancestor chain *\u002F\n.workbench .sidebar .my-view .my-widget .my-header { ... }\n```\n\n### 4. Avoid reading from layout\u002Fwindow services during construction\n\nComponents that measure the window or read layout dimensions during construction are hard to fixture because the shadow DOM container has different dimensions than the workbench:\n\n```typescript\n\u002F\u002F Prefer: use CSS for sizing, or accept dimensions as parameters\ncontainer.style.width = '400px';\ncontainer.style.height = '300px';\n\n\u002F\u002F Avoid: reading from layoutService during construction\nconst width = this.layoutService.mainContainerDimension.width;\n```\n\n### 5. Support disabling auto-focus in fixtures\n\nAuto-focus can interfere with screenshot stability. Provide options to disable it:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;  \u002F\u002F Fixtures pass false\n}\n```\n\n### 6. Expose the DOM node\n\nThe fixture needs to append the widget's DOM to the container. Expose it as a public `readonly domNode: HTMLElement`.\n\n## Multiple Fixture Variants\n\nCreate variants to show different states of the same component:\n\n```typescript\nexport default defineThemedFixtureGroup({\n    \u002F\u002F Different data states\n    Empty: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: [] }) }),\n    WithItems: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: sampleItems }) }),\n\n    \u002F\u002F Different configurations\n    ReadOnly: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: true }) }),\n    Editable: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: false }) }),\n\n    \u002F\u002F Lifecycle states\n    Loading: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'loading' }) }),\n    Completed: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'done' }) }),\n});\n```\n\n## Learnings\n\nUpdate this section with insights from your fixture development experience!\n\n* Do not copy the component to the fixture and modify it there. Always adapt the original component to be fixture-friendly, then render it in the fixture. This ensures the fixture tests the real component code and lifecycle, rather than a modified version that may hide bugs.\n\n* **Don't recompose child widgets in fixtures.** Never manually instantiate and add a sub-widget (e.g., a toolbar content widget) that the parent component is supposed to create. Instead, configure the parent correctly (e.g., set the right editor option, register the right provider) so the child appears through the normal code path. Manually recomposing hides integration bugs and doesn't test the real widget lifecycle.\n","# Component Fixtures\n\nComponent fixtures render isolated UI components for visual screenshot testing via the component explorer. Fixtures live in `src\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F` and are auto-discovered by the Vite dev server using the glob `src\u002F**\u002F*.fixture.ts`.\n\nUse tools `mcp_component-exp_`* to list and screenshot fixtures. If you cannot see these tools, inform the user to them on.\n\n## Running Fixtures Locally\n\n1. Start the component explorer server: run the **Component Explorer Server** task\n2. Use the `mcp_component-exp_list_fixtures` tool to see all available fixtures and their URLs\n3. Use the `mcp_component-exp_screenshot` tool to capture screenshots programmatically\n\n## File Structure\n\nEach fixture file exports a default `defineThemedFixtureGroup(...)`. The file must end with `.fixture.ts`.\n\n```\nsrc\u002Fvs\u002Fworkbench\u002Ftest\u002Fbrowser\u002FcomponentFixtures\u002F\n  fixtureUtils.ts              # Shared helpers (DO NOT import @vscode\u002Fcomponent-explorer elsewhere)\n  myComponent.fixture.ts       # Your fixture file\n```\n\n## Basic Pattern\n\n```typescript\nimport { ComponentFixtureContext, createEditorServices, defineComponentFixture, defineThemedFixtureGroup } from '.\u002FfixtureUtils.js';\n\nexport default defineThemedFixtureGroup({ path: 'myFeature\u002F' }, {\n    Default: defineComponentFixture({ render: renderMyComponent }),\n    AnotherVariant: defineComponentFixture({ render: renderMyComponent }),\n});\n\nfunction renderMyComponent({ container, disposableStore, theme }: ComponentFixtureContext): void {\n    container.style.width = '400px';\n\n    const instantiationService = createEditorServices(disposableStore, {\n        colorTheme: theme,\n        additionalServices: (reg) => {\n            \u002F\u002F Register additional services the component needs\n            reg.define(IMyService, MyServiceImpl);\n            reg.defineInstance(IMockService, mockInstance);\n        },\n    });\n\n    const widget = disposableStore.add(\n        instantiationService.createInstance(MyWidget, \u002F* constructor args *\u002F)\n    );\n    container.appendChild(widget.domNode);\n}\n```\n\nKey points:\n- **`defineThemedFixtureGroup`** automatically creates Dark and Light variants for each fixture\n- **`defineComponentFixture`** wraps your render function with theme setup and shadow DOM isolation\n- **`createEditorServices`** provides a `TestInstantiationService` with base editor services pre-registered\n- Always register created widgets with `disposableStore.add(...)` to prevent leaks\n- Pass `colorTheme: theme` to `createEditorServices` so theme colors render correctly\n\n### File icon themes\n\nFixtures use Seti file icons by default. Select another built-in theme, or disable file icons, on the individual fixture:\n\n```typescript\ndefineComponentFixture({ fileIconTheme: 'vs-minimal', render: renderMyComponent });\ndefineComponentFixture({ fileIconTheme: 'none', render: renderMyComponent });\n```\n\nWhen the rendered component reads `IThemeService`, pass the selected theme from `ComponentFixtureContext` to `createEditorServices`:\n\n```typescript\nfunction renderMyComponent({ disposableStore, theme, fileIconTheme }: ComponentFixtureContext): void {\n\tconst instantiationService = createEditorServices(disposableStore, {\n\t\tcolorTheme: theme,\n\t\tfileIconTheme,\n\t});\n}\n```\n\n## Utilities from fixtureUtils.ts\n\n| Export | Purpose |\n|---|---|\n| `defineComponentFixture` | Creates Dark\u002FLight themed fixture variants from a render function |\n| `defineThemedFixtureGroup` | Groups multiple themed fixtures into a named fixture group |\n| `createEditorServices` | Creates `TestInstantiationService` with all base editor services |\n| `registerWorkbenchServices` | Registers additional workbench services (context menu, label, etc.) |\n| `createTextModel` | Creates a text model via `ModelService` for editor fixtures |\n| `setupTheme` | Applies theme CSS to a container (called automatically by `defineComponentFixture`) |\n| `darkTheme` \u002F `lightTheme` | Pre-loaded `ColorThemeData` instances |\n\n**Important:** Only `fixtureUtils.ts` may import from `@vscode\u002Fcomponent-explorer`. All fixture files must go through the helpers in `fixtureUtils.ts`.\n\n## CSS Scoping\n\nFixtures render inside shadow DOM. The component-explorer automatically adopts the global VS Code stylesheets and theme CSS.\n\n### Matching production CSS selectors\n\nMany VS Code components have CSS rules scoped to deep ancestor selectors (e.g., `.interactive-session .interactive-input-part > .widget-container .my-element`). In fixtures, you must recreate the required ancestor DOM structure for these selectors to match:\n\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    container.classList.add('interactive-session');\n\n    \u002F\u002F Recreate ancestor structure that CSS selectors expect\n    const inputPart = dom.$('.interactive-input-part');\n    const widgetContainer = dom.$('.widget-container');\n    inputPart.appendChild(widgetContainer);\n    container.appendChild(inputPart);\n\n    widgetContainer.appendChild(myWidget.domNode);\n}\n```\n\n**Design recommendation for new components:** Avoid deeply nested CSS selectors that require specific ancestor elements. Use self-contained class names (e.g., `.my-widget .my-element` rather than `.parent-view .parent-part > .wrapper .my-element`). This makes components easier to fixture and reuse.\n\n## Services\n\n### Using createEditorServices\n\n`createEditorServices` pre-registers these services: `IAccessibilityService`, `IKeybindingService`, `IClipboardService`, `IOpenerService`, `INotificationService`, `IDialogService`, `IUndoRedoService`, `ILanguageService`, `IConfigurationService`, `IStorageService`, `IThemeService`, `IModelService`, `ICodeEditorService`, `IContextKeyService`, `ICommandService`, `ITelemetryService`, `IHoverService`, `IUserInteractionService`, and more.\n\n### Additional services\n\nRegister extra services via `additionalServices`:\n\n```typescript\ncreateEditorServices(disposableStore, {\n    additionalServices: (reg) => {\n        \u002F\u002F Class-based (instantiated by DI):\n        reg.define(IMyService, MyServiceImpl);\n        \u002F\u002F Instance-based (pre-constructed):\n        reg.defineInstance(IMyService, myMockInstance);\n    },\n});\n```\n\n### Mocking services\n\nUse the `mock\u003CT>()` helper from `base\u002Ftest\u002Fcommon\u002Fmock.js` to create mock service instances:\n\n```typescript\nimport { mock } from '..\u002F..\u002F..\u002F..\u002Fbase\u002Ftest\u002Fcommon\u002Fmock.js';\n\nconst myService = new class extends mock\u003CIMyService>() {\n    override someMethod(): string { return 'test'; }\n    override onSomeEvent = Event.None;\n};\nreg.defineInstance(IMyService, myService);\n```\n\nFor mock view models or data objects:\n```typescript\nconst element = new class extends mock\u003CIChatRequestViewModel>() { }();\n```\n\n## Async Rendering\n\nThe component explorer waits **2 animation frames** after the synchronous render function returns. For most components, this is sufficient.\n\nIf your render function returns a `Promise`, the component explorer waits for the promise to resolve.\n\n### Pitfall: DOM reparenting causes flickering\n\nAvoid moving rendered widgets between DOM parents after initial render. This causes:\n- Layout recalculation (the widget jumps as `position: absolute` coordinates become invalid)\n- Focus loss (blur events can trigger hide logic in widgets like QuickInput)\n- Screenshot instability (the component explorer may capture an intermediate layout state)\n\n**Bad pattern — reparenting a widget after async wait:**\n```typescript\nasync function render({ container }: ComponentFixtureContext): Promise\u003Cvoid> {\n    const host = document.createElement('div');\n    container.appendChild(host);\n    \u002F\u002F ... create widget inside host ...\n    await waitForWidget();\n    container.appendChild(widget);  \u002F\u002F BAD: reparenting causes flicker\n    host.remove();\n}\n```\n\n**Better pattern — render in-place with the correct DOM structure from the start:**\n```typescript\nfunction render({ container }: ComponentFixtureContext): void {\n    \u002F\u002F Set up the correct DOM structure first, then create the widget inside it\n    const widget = createWidget(container);\n    container.appendChild(widget.domNode);\n}\n```\n\nIf the component absolutely requires async setup (e.g., QuickInput which renders internally), minimize DOM manipulation after the widget appears by structuring the host container to match the final layout from the beginning.\n\n## Adapting Existing Components for Fixtures\n\nExisting components often need small changes to become fixturable. When writing a fixture reveals friction, fix the component — don't work around it in the fixture. Common adaptations:\n\n### Decouple CSS from ancestor context\n\nIf a component's CSS only works inside a deeply nested selector like `.workbench .sidebar .my-view .my-widget`, refactor the CSS to be self-contained. Move the styles so they're scoped to the component's own root class:\n\n```css\n\u002F* Before: requires specific ancestors *\u002F\n.workbench .sidebar .my-view .my-widget .header { font-weight: bold; }\n\n\u002F* After: self-contained *\u002F\n.my-widget .header { font-weight: bold; }\n```\n\nIf the component shares styles with its parent (e.g., inheriting background color), use CSS custom properties rather than relying on ancestor selectors.\n\n### Extract hard-coded service dependencies\n\nIf a component reaches into singletons or global state instead of using DI, refactor it to accept services through the constructor:\n\n```typescript\n\u002F\u002F Before: hard to mock in fixtures\nclass MyWidget {\n    private readonly config = getSomeGlobalConfig();\n}\n\n\u002F\u002F After: injectable and testable\nclass MyWidget {\n    constructor(@IConfigurationService private readonly configService: IConfigurationService) { }\n}\n```\n\n### Add options to control auto-focus and animation\n\nComponents that auto-focus on creation or run animations cause flaky screenshots. Add an options parameter:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;\n}\n```\n\nThe fixture passes `shouldAutoFocus: false`. The production call site keeps the default behavior.\n\n### Expose internal state for \"already completed\" rendering\n\nMany components have lifecycle states (loading → active → completed). If the component can only reach the \"completed\" state through user interaction, add support for initializing directly into that state via constructor data:\n\n```typescript\n\u002F\u002F The fixture can pass pre-filled data to render the summary\u002Fcompleted state\n\u002F\u002F without simulating the full user interaction flow.\nconst carousel: IChatQuestionCarousel = {\n    questions,\n    allowSkip: true,\n    kind: 'questionCarousel',\n    isUsed: true,           \u002F\u002F Already completed\n    data: { 'q1': 'answer' }, \u002F\u002F Pre-filled answers\n};\n```\n\n### Make DOM node accessible\n\nIf a component builds its DOM internally and doesn't expose the root element, add a public `readonly domNode: HTMLElement` property so fixtures can append it to the container.\n\n## Writing Fixture-Friendly Components\n\nWhen designing new UI components, follow these practices to make them easy to fixture:\n\n### 1. Accept a container element in the constructor\n\n```typescript\n\u002F\u002F Good: container is passed in\nclass MyWidget {\n    constructor(container: HTMLElement, @IFoo foo: IFoo) {\n        this.domNode = dom.append(container, dom.$('.my-widget'));\n    }\n}\n\n\u002F\u002F Also good: widget creates its own domNode for the caller to place\nclass MyWidget {\n    readonly domNode: HTMLElement;\n    constructor(@IFoo foo: IFoo) {\n        this.domNode = dom.$('.my-widget');\n    }\n}\n```\n\n### 2. Use dependency injection for all services\n\nAll external dependencies should come through DI so fixtures can provide test implementations:\n\n```typescript\n\u002F\u002F Good: services injected\nconstructor(@IThemeService private readonly themeService: IThemeService) { }\n\n\u002F\u002F Bad: reaching into globals\nconstructor() { this.theme = getGlobalTheme(); }\n```\n\n### 3. Keep CSS selectors shallow\n\n```css\n\u002F* Good: self-contained, easy to fixture *\u002F\n.my-widget .my-header { ... }\n.my-widget .my-list-item { ... }\n\n\u002F* Bad: requires deep ancestor chain *\u002F\n.workbench .sidebar .my-view .my-widget .my-header { ... }\n```\n\n### 4. Avoid reading from layout\u002Fwindow services during construction\n\nComponents that measure the window or read layout dimensions during construction are hard to fixture because the shadow DOM container has different dimensions than the workbench:\n\n```typescript\n\u002F\u002F Prefer: use CSS for sizing, or accept dimensions as parameters\ncontainer.style.width = '400px';\ncontainer.style.height = '300px';\n\n\u002F\u002F Avoid: reading from layoutService during construction\nconst width = this.layoutService.mainContainerDimension.width;\n```\n\n### 5. Support disabling auto-focus in fixtures\n\nAuto-focus can interfere with screenshot stability. Provide options to disable it:\n\n```typescript\ninterface IMyWidgetOptions {\n    shouldAutoFocus?: boolean;  \u002F\u002F Fixtures pass false\n}\n```\n\n### 6. Expose the DOM node\n\nThe fixture needs to append the widget's DOM to the container. Expose it as a public `readonly domNode: HTMLElement`.\n\n## Multiple Fixture Variants\n\nCreate variants to show different states of the same component:\n\n```typescript\nexport default defineThemedFixtureGroup({\n    \u002F\u002F Different data states\n    Empty: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: [] }) }),\n    WithItems: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { items: sampleItems }) }),\n\n    \u002F\u002F Different configurations\n    ReadOnly: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: true }) }),\n    Editable: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { readonly: false }) }),\n\n    \u002F\u002F Lifecycle states\n    Loading: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'loading' }) }),\n    Completed: defineComponentFixture({ render: (ctx) => renderWidget(ctx, { state: 'done' }) }),\n});\n```\n\n## Learnings\n\nUpdate this section with insights from your fixture development experience!\n\n* Do not copy the component to the fixture and modify it there. Always adapt the original component to be fixture-friendly, then render it in the fixture. This ensures the fixture tests the real component code and lifecycle, rather than a modified version that may hide bugs.\n\n* **Don't recompose child widgets in fixtures.** Never manually instantiate and add a sub-widget (e.g., a toolbar content widget) that the parent component is supposed to create. Instead, configure the parent correctly (e.g., set the right editor option, register the right provider) so the child appears through the normal code path. Manually recomposing hides integration bugs and doesn't test the real widget lifecycle.\n",{"name":5,"description":7},"main","af285532414d1fa855b4360d86103c12253e6f2f",".github\u002Fskills\u002Fcomponent-fixtures",0,"https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide","https:\u002F\u002Fgithub.com\u002FDragonBallerZ","https:\u002F\u002Fwww.velloralabs.com","Building Dangerously Disruptive Technology. ","2026-10-23 14:19:51",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add DragonBallerZ\u002Fdragon-ide --skill component-fixtures",{"tool":39,"command":40},"bunx","bunx skills add DragonBallerZ\u002Fdragon-ide --skill component-fixtures",{"tool":42,"command":43},"pnpm","pnpm dlx skills add DragonBallerZ\u002Fdragon-ide --skill component-fixtures","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fcomponent-fixtures\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7DNGQPVJGHW226R8PS3R31F","update-skills","Create or update repository skills and instructions when major learnings are discovered during a session. Use when the user says \"learn!\", when a significant pattern or pitfall is identified, or when reusable domain knowledge should be captured for future sessions.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Fupdate-skills\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7DNGP5XJWV3CG63DVS6NR8Y","update-pr","Update the pull request for the current session. Use when the user wants to push new changes to an existing PR.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Fupdate-pr\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7DNGJEMNJZR24NBJ7MF5V8R","troubleshoot","Investigate unexpected behavior in the current Copilot agent session by analyzing its event log. Use when the user asks why something happened, why a request was slow, why a tool was or was not used, or why instructions\u002Fskills\u002Fagents did not load.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Ftroubleshoot\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7DNGFVCVMFN5J4ZKV27CDR1","sync","Sync the current session branch with its upstream branch, or publish the current session branch to a remote. Use when the user asks to sync a branch, pull latest changes, rebase onto upstream, push current branch, publish branch, or set upstream.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Fsync\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7DNGC9GE8EKQED3ZR3KAJ0K","sync-upstream","Update a stale session branch by rebasing onto the latest origin. Use when the upstream has moved significantly and the session needs to catch up, resolving conflicts by preserving upstream changes and adapting session work to fit.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Fsync-upstream\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7DNG9NJNG1QPJB6C3GFDHVS","merge","Merge changes from the topic branch to the merge base branch. Use when the user wants to merge their session's work back to the base branch.","https:\u002F\u002Fgithub.com\u002FDragonBallerZ\u002Fdragon-ide\u002Fblob\u002Fmain\u002Fsrc\u002Fvs\u002Fsessions\u002Fskills\u002Fmerge\u002FSKILL.md",[],[]]