refactor: drive real prompts in tests; extract prompt & view abstractions#8
Draft
PascalSenn wants to merge 1 commit into
Draft
refactor: drive real prompts in tests; extract prompt & view abstractions#8PascalSenn wants to merge 1 commit into
PascalSenn wants to merge 1 commit into
Conversation
…ions Replace the IInteractionService test seam by driving the real Spectre prompt widgets over a scriptable TestConsole, and pull console-interaction logic into small, independently-tested abstractions. Prompts - IPrompt<T> over a single Spectre widget shape, with composable decorators WithDefault<T> (degrade to a default when the console can't prompt) and RequireNonEmpty<T> (re-show until non-empty), exposed as chainable extensions. - WithDefault gates on BOTH Interactive and Ansi capabilities, so redirected and TERM=dumb runs degrade instead of throwing from Spectre. - Empty-choices guards on the multi-select prompts. Views - IView : IRenderable base with a static factory per view; views hold no console/service and render via console.Write(view). Converted Banner (split into Logo/Banner/CuratedHelp), Error, InstallationReport, SkillList, and added InstallPlan, UpdateNotice, and InstalledSkills views. A Stacked/BlankLine primitive composes box renderables without Rows' extra line break. - Views are no longer registered in DI. Commands - Inlined AddCommandExecutor into AddCommand to match the other commands. - Selectors expose only SelectAsync; row/order/group logic is inline. Misc - TimeProvider for InstallRecorder; monotonic Stopwatch + TimeProvider.System in FileLock instead of DateTime.UtcNow. Tests: 763 passing; selectors and commands are exercised through the real prompts and views (keystrokes + rendered output) rather than a hand-written double. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the
IInteractionServicetest seam by driving the real Spectre prompt widgets over a scriptableTestConsole, and pulls console-interaction logic out of the commands into small, independently-tested abstractions. It's a console app, so it's now tested the way it runs — press keys, read rendered output.Prompts
IPrompt<T>over a single Spectre widget shape, with composable decoratorsWithDefault<T>(return a default when the console can't show a prompt) andRequireNonEmpty<T>(re-show until at least one item is picked), exposed as chainable extensions:picker.RequireNonEmpty().WithDefault(empty).WithDefaultgates on bothInteractiveandAnsicapabilities — redirected streams andTERM=dumbterminals degrade gracefully instead of throwing from Spectre.Views
IView : IRenderablebase with a static factory per view; a view holds no console or service and is rendered withconsole.Write(view)— not DI'd.BannerView(split intoLogo/Banner/CuratedHelp),ErrorView,InstallationReportView,SkillListView; addedInstallPlanView,UpdateNoticeView, andInstalledSkillsView.Stacked+BlankLineprimitive composes box renderables without the extra line breakRowsinserts, so multi-panel output stays byte-identical.Commands
AddCommandExecutorintoAddCommandso it matches the other (fat) commands.SelectAsync; row/order/group logic is inline. No structured renderable or raw Spectre prompt is built in a command anymore.Misc
TimeProviderforInstallRecorder; monotonicStopwatch+TimeProvider.SysteminFileLockinstead ofDateTime.UtcNow.Tests
763 passing. Selectors and commands are exercised through the real prompts and views (keystrokes + rendered output) rather than a hand-written service double; net −1900 LOC.
🤖 Generated with Claude Code