test: comprehensive unit tests for single-pane layout strategies#324707
test: comprehensive unit tests for single-pane layout strategies#324707sandy081 wants to merge 2 commits into
Conversation
Add singlePaneStrategies.test.ts covering each composed single-pane strategy in isolation (NewSessionRules, QuickChatEditorHide, DetailVisibility, DetailPanel, ManagedTabs, EditorAreaCollapse, ResponsiveSidebar) via a hand-built ISinglePaneLayoutContext backed by the shared test harness. Focuses on the bug-prone edges surfaced during the refactor: intrinsic submit detection, D3c leave-as-is with no saved state, empty-group Preserve during restore, R1 editor re-hide, managed tab dismissal memory, and responsive sidebar auto-hide/restore. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @benibenjMatched files:
|
There was a problem hiding this comment.
Pull request overview
This is a test-only PR that adds singlePaneStrategies.test.ts, providing focused unit coverage for each of the eight composed single-pane layout strategy objects introduced in #324657 (contrib/layout/browser/singlePane/). Rather than exercising behavior only through the controller integration tests, each real strategy class is instantiated in isolation via createInstance(StrategyClass, ctx, …) against the shared createTestHarness service doubles and a hand-built ISinglePaneLayoutContext (createStrategyTestContext) that exposes the coordination flags (isRestoringSessionLayout, togglingSidePane, hidingAuxiliaryBarForRestore) and viewStateBySession map the controller normally owns. A companion note is added to the sessions SKILL doc describing this per-strategy testing approach and its two gotchas.
Changes:
- Adds 46 unit tests across the seven single-pane strategies (new-session rules, quick-chat editor hide, detail visibility, detail panel, managed tabs, editor-area collapse, responsive sidebar), including bug-prone edges (D3c leave-as-is, intrinsic submit detection, empty-group→Preserve during restore).
- Introduces
createStrategyTestContext, a lightweightISinglePaneLayoutContextdouble with mutable coordination flags plus asettle()sequencer-flush helper. - Documents the isolated per-strategy testing pattern in
.github/skills/sessions/SKILL.md.
Show a summary per file
| File | Description |
|---|---|
src/vs/sessions/contrib/layout/test/browser/singlePaneStrategies.test.ts |
New 837-line test suite instantiating each single-pane strategy directly and asserting its isolated behavior; verified to align with each strategy's implementation and to reuse the existing harness/disposable conventions. |
.github/skills/sessions/SKILL.md |
Adds an accurate learnings bullet describing how to unit-test single-pane strategies in isolation, including the direct-construction of SinglePaneDockedTabsCoordinator and the sequencer settle() caveat. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
Address CCR feedback: the restoreCalls field was never read or asserted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Adds
singlePaneStrategies.test.ts— focused unit tests for each composed single-pane layout strategy in isolation, complementing the existing controller-level integration tests indesktopSessionLayoutController.test.ts.The single-pane layout (shipped in #324657) is composed from eight strategy objects under
contrib/layout/browser/singlePane/. These tests instantiate each real strategy class directly viacreateInstance(StrategyClass, ctx, ...)— driving the actual constructor autoruns, event listeners, and private sync logic — with the sharedcreateTestHarnessservice doubles and a hand-builtISinglePaneLayoutContext(createStrategyTestContext) that exposes the coordination flags (isRestoringSessionLayout,togglingSidePane,hidingAuxiliaryBarForRestore) and theviewStateBySessionmap the controller normally owns.Coverage (46 tests)
NewSessionRulesStrategy(R1)QuickChatEditorHideStrategyDetailVisibilityStrategy(D1-D4)DetailPanelStrategyManagedTabsStrategy+ Filescontext, reopen clears dismissal, workspace-file collapseEditorAreaCollapseStrategyResponsiveSidebarStrategy(D7)toggleDetailsopen+auto-hide / close+restore, restore on full side-pane hide, manual toggle hands backValidation
valid-layers-check, eslint: cleanTest-only change; no production code modified.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com