Skip to content

test(todos): guard todos show --json surfaces SDK fields (Refs #449) - #564

Merged
jeremy merged 1 commit into
mainfrom
test/todos-json-sdk-fields-449
Jul 25, 2026
Merged

test(todos): guard todos show --json surfaces SDK fields (Refs #449)#564
jeremy merged 1 commit into
mainfrom
test/todos-json-sdk-fields-449

Conversation

@jeremy

@jeremy jeremy commented Jul 25, 2026

Copy link
Copy Markdown
Member

What

Adds TestTodosShowJSONSurfacesSDKFields, a regression guard for #449: the fields that issue reported as missing from todos show --jsondue_on, starts_on, comments_count, boosts_count, completion_subscribers, description_attachments — must all surface in the JSON output.

Why this is Refs, not Fixes

The implementation already landed on main (unreleased — latest published CLI is v0.7.2, which predates it). Provenance chain:

todos show emits the SDK Todo object directly (todos.go data := any(todo)), so all six fields surface today. The remaining work is coverage, not a fix.

The test

Serves a fully-populated todo from a focused GET transport (nonzero due_on/starts_on/comments_count/boosts_count so the omitempty fields are actually exercised, plus a non-empty completion_subscribers and description_attachments), runs todos show 999 with JSON output, and asserts both the presence and the values of all six fields. This keeps a future SDK bump from silently dropping any of them.

Deliberately does not add a CLI presenter/model wrapper to force stable zero-valued keys — that would fork the SDK contract; a stable-zero-key policy, if ever wanted, is a separate upstream SDK-model decision.

bin/ci green.

Refs #449


Summary by cubic

Add a regression test (TestTodosShowJSONSurfacesSDKFields) to ensure todos show --json includes due_on, starts_on, comments_count, boosts_count, completion_subscribers, and description_attachments (Refs #449). The test serves a fully populated todo and asserts presence and values; this is coverage only since the behavior already exists on main via recent SDK bumps.

Written for commit 98fe6e0. Summary will update on new commits.

Review in cubic

Copilot AI review requested due to automatic review settings July 25, 2026 07:37
@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) bug Something isn't working labels Jul 25, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression test to ensure basecamp todos show (JSON output mode) continues to surface specific SDK-backed fields that were reported missing in #449, guarding against future SDK bumps or serialization changes that silently drop those keys/values.

Changes:

  • Add a focused test (TestTodosShowJSONSurfacesSDKFields) asserting presence (and some values) for due_on, starts_on, comments_count, boosts_count, completion_subscribers, and description_attachments.
  • Introduce a dedicated http.RoundTripper that serves a fully-populated todo payload for the show path.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Comments suppressed due to low confidence (1)

internal/commands/todos_test.go:3025

  • The description_attachments assertion only checks the filename. Since this test’s goal is to guard that the SDK field is surfaced correctly, it would be stronger to also assert a couple of other expected attachment fields (e.g., id and download_url) so shape/value regressions are caught.
	var attachments []struct {
		Filename string `json:"filename"`
	}
	require.NoError(t, json.Unmarshal(resp.Data["description_attachments"], &attachments))
	require.Len(t, attachments, 1)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/commands/todos_test.go
Comment thread internal/commands/todos_test.go
Copilot AI review requested due to automatic review settings July 25, 2026 07:41
@jeremy
jeremy force-pushed the test/todos-json-sdk-fields-449 branch from 3235c18 to f32e91d Compare July 25, 2026 07:41
Add TestTodosShowJSONSurfacesSDKFields, a regression guard for #449: the
fields that report (due_on, starts_on, comments_count, boosts_count,
completion_subscribers, description_attachments) must all surface in the
--json output of `todos show`.

The implementation already landed on main via the SDK model — SDK #375
added completion_subscribers/comments_count, SDK #400 added
description_attachments, absorbed by CLI #552/#554's SDK bumps; due_on,
starts_on and boosts_count already existed with omitempty. `todos show`
emits the SDK Todo object directly, so the fields surface today. This is
coverage, not a fix (hence Refs, not Fixes).

The test serves a fully-populated todo and asserts both the presence and
the values of all six fields, keeping the omitempty date/count fields
exercised with nonzero values so a future SDK bump can't silently drop
them.
@jeremy
jeremy force-pushed the test/todos-json-sdk-fields-449 branch from f32e91d to 98fe6e0 Compare July 25, 2026 07:42
@github-actions github-actions Bot added enhancement New feature or request and removed bug Something isn't working labels Jul 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

internal/commands/todos_test.go:2936

  • populatedTodoTransport.RoundTrip returns a successful 200 response for any request, which makes this regression test less precise and could allow future changes (additional SDK calls or different paths/methods) to slip through without being detected. Guard the transport to only accept the expected GET for this todo ID and fail fast on anything else.
func (populatedTodoTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	// Fail closed: this transport only knows how to answer the todo GET. Any
	// other route or method means `todos show` took an unexpected path, which
	// should fail the test rather than silently pass on the canned body.

Copilot AI review requested due to automatic review settings July 25, 2026 07:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

internal/commands/todos_test.go:2939

  • The RoundTrip route guard is still too permissive: strings.Contains(req.URL.Path, "/todos/999") will also match unexpected paths like "/todos/9999.json" or "/todos/999/comments.json". That can let the test pass even if the command hits the wrong endpoint/ID. Tighten the match to the expected todo GET path suffix so unexpected requests fail closed.
	if req.Method != http.MethodGet || !strings.Contains(req.URL.Path, "/todos/999") {
		return nil, fmt.Errorf("unexpected request: %s %s", req.Method, req.URL.Path)
	}

@jeremy
jeremy merged commit 142c990 into main Jul 25, 2026
27 checks passed
@jeremy
jeremy deleted the test/todos-json-sdk-fields-449 branch July 25, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations enhancement New feature or request tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants