Skip to content

Add unit test: show --json includes structured audit (present & absent) #1254

@SorraTheOrc

Description

@SorraTheOrc

Headline
Ensure wl show --json includes an audit object only when audit data exists, and add unit tests for presence and absence cases.

Problem statement
Ensure wl show --json returns a stable, typed JSON object that always contains a workItem object and conditionally includes an audit object only when audit data exists. Add unit tests that verify both the presence and absence cases so automation can rely on the shape without additional heuristics.

Users

  • Test authors and maintainers of the Worklog CLI who rely on stable, predictable JSON output from wl show --json for automation and tooling.

Example user stories

  • As a test author, I want wl show --json to include an audit key only when audit data exists so downstream consumers can parse the output without extra heuristics.
  • As an automation consumer, I want a typed/structured JSON output so I can reliably read workItem and optional audit fields in scripts.

Success criteria

  • Unit tests added that assert wl show --json returns a JSON object with workItem and when audit data is present includes an audit object with time, author, and text fields.
  • Unit tests added that assert when audit is absent the audit property is not present in the JSON output (not null or empty object).
  • The new tests are run in CI and pass locally; full project test suite passes with the new changes.
  • Related documentation (README or CLI docs) updated to document the --json output shape.

Constraints

  • Do not change existing public JSON keys other than adding/omitting audit as specified (backwards compatibility required for other fields).
  • Tests should be hermetic and not rely on external services; use in-repo fixtures or mocks.

Existing state

  • Current work item: WL-0MN7ZP9GX001XJE4 (title: "Add unit test: show --json includes structured audit (present & absent)") exists and is assigned to Map at stage idea / status in-progress.
  • Parent: WL-0MMRJM03Q0BG25IG appears related per the work item metadata.

Desired change

  • Implement unit tests that cover both presence and absence of audit in the wl show --json output and ensure tests are added to the appropriate test files and run as part of the test suite.
  • Update CLI documentation to describe the --json output shape and the conditional audit field.

Related work

  • Parent work item: WL-0MMRJM03Q0BG25IG (related epic/feature).
  • Evidence from repository/worklog: work item WL-0MN7ZP9GX001XJE4 comments indicate a PR was opened (PR WL-0MN7ZP9GX001XJE4: add show --json audit presence/absence test #1167) and commits e1996ff and 5544bc9 reference tests and helpers updates. A test file tests/cli/show-json-audit.test.ts is referenced in the work item comments. (Source: wl show WL-0MN7ZP9GX001XJE4 --json comments.)

Appendix: Clarifying questions & answers

  • Q: "Should I ask any clarifying questions about the work?" — Answer (user instruction): "do not ask questions". Source: seed input. Final: yes.
  • Q: "Are there mandatory formatting or additional JSON keys required by downstream consumers?" — Answer (agent inference): Not provided by the user or repo artifacts; assume only the audit key behaviour described in the seed context is required. Source: agent inference from WL-0MN7ZP9GX001XJE4 work item description and comments. Final: yes.

Risks & assumptions

  • Risk: The tests or implementation may already exist (PR opened per comments). Mitigation: verify the mentioned PR/commits (e1996ff, 5544bc9) and, if merged, mark this intake as already implemented or adjust to coverage/regression tests as needed.
  • Risk: Changing wl show output shape could break downstream automation. Mitigation: tests must assert backward compatibility for existing fields and only validate the presence/absence behaviour of audit.
  • Assumption: Downstream consumers expect the audit key to be omitted entirely when absent (not present as null). If this is incorrect, request clarification. (Current answer: user did not provide - agent inference used.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions