Skip to content

Add tests for describe-change.sh and installScripts #386

Description

@williamthorsen

Problem

Two new components introduced in #383 lack test coverage:

  1. describe-change.sh — the core prefix-resolution script with hand-rolled YAML parsing, a three-level resolution fallback chain, a FOUND: sentinel, JSON escaping, and a format_prefix function handling multiple convention formats.

  2. installScripts in install.ts — a new installer code path handling script copying, symlinking, chmod 0o755, drift detection, manifest tracking, and --force/--dry-run modes.

Context

These components were introduced in #383 (configurable change description prefixes). The review cycle identified the missing coverage as T-level findings deferred to keep the feature PR focused.

Solution

describe-change.sh — ShellSpec test suite

Add ShellSpec to the agents package and create content/scripts/__tests__/describe_change_test.sh. Source the script to test functions in isolation (parse_prefix, resolve_prefix, format_prefix, json_escape) and end-to-end for JSON output.

installScripts — Vitest additions

Add focused test cases to packages/agents/src/commands/__tests__/install.test.ts following existing patterns.

Acceptance criteria

describe-change.sh

  • All convention formats (type(scope), scope|type, type, '') with both scope and type provided
  • Type-only (no scope): all conventions produce {type}:
  • Scope-only (no type): all conventions produce empty
  • Neither scope nor type: all conventions produce empty
  • Empty convention (explicitly set to ''): all fields produce empty
  • No preferences file present: all fields produce empty
  • Project preferences override global preferences
  • Global preferences used when project file is absent
  • Project empty-string preference overrides global non-empty preference (FOUND: sentinel)
  • YAML values containing | are parsed correctly (quoted strings)
  • Inline YAML comments are stripped before processing
  • Output JSON is well-formed in all cases
  • JSON escaping handles " and \ in prefix values

installScripts

  • Script files appear in {platformHome}/scripts/ after install

  • Installed script has executable permissions (mode 0o755)

  • Script entries appear in the manifest with sha256: hash and linked: false for copy mode

  • Script entries appear in the manifest with linked: true for link mode

  • Modified script is skipped on re-install without --force

  • Modified script is overwritten on re-install with --force

  • Dry-run mode does not create scripts directory or write script files

  • New/modified behavior in this change is covered by tests

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions