Skip to content

script-utils/demo-vault-buttons

A vitest suite that opens every note of a plugin’s in-repo demo-vault/, clicks each code-button in it against a real Obsidian, and fails on any button that errors or never reports a result.

A demo vault’s buttons are the one part of it no other gate can check. lint:md reads the markdown, the coverage suite (registerDemoVaultCoverageSuite) checks the authoring conventions, and neither executes anything — a button whose require('/demoSetup.ts') path is wrong, or that calls an API that has since changed shape, fails at click time and nowhere else.

The companion half — seeding the temp vault with the demo-vault tree, its .obsidian config, and the CodeScript Toolkit binary that turns ```code-button fences into buttons — is buildDemoVaultPopulate in obsidian-integration-testing; hand its result to the project’s globalSetup and name CodeScript Toolkit in enableCommunityPlugins.

InterfaceDescription
DemoVaultButtonResultThe outcome of clicking one button.
DemoVaultNoteOne demo-vault note and how many buttons its source declares.
RegisterDemoVaultButtonSuiteOptionsThe options for registerDemoVaultButtonSuite.
FunctionDescription
formatFailuresBuilds the assertion message for a note’s failing buttons. The captured output is included because a button’s failure is a runtime one — the stack CodeScript Toolkit prints under it is the only diagnosis there is.
listNotesWithButtonsLists the demo vault’s notes that declare at least one code-button, walking group folders too. A vault big enough to need grouping puts its walkthroughs in numbered folders — and a root-only walk finds NONE of them, which is worse than it sounds: a vault whose notes are all grouped reports zero notes, and one that is partly grouped silently gates only the ungrouped part. Fixture and asset folders are still skipped, so what is walked is walkthroughs and nothing else.
registerDemoVaultButtonSuiteRegisters a vitest suite that clicks every code-button in the repo’s demo vault. One it per note, and one evalInObsidian per button: a single closure runs as one CDP Runtime.evaluate, which the harness caps at 30 s, so a note with a dozen buttons would otherwise time out as a whole rather than reporting which button failed.
VariableDescription
CODE_SCRIPT_TOOLKIT_PLUGIN_IDCodeScript Toolkit’s manifest id. It is still the plugin’s original fix-require-modules id, which no longer matches its name — the id is published, so it cannot be changed.