Skip to content

test(cli-core): keep one owner per CLI, account and output contract - #208

Merged
neoromantic merged 1 commit into
mainfrom
test/cleanup-cli-core
Nov 19, 2026
Merged

neoromantic merged 1 commit into
mainfrom
test/cleanup-cli-core

Conversation

@neoromantic

Copy link
Copy Markdown
Owner

What and why

Part of the test cleanup campaign: each contract keeps one strong owner, and tests that repeat it, restate the code or prove nothing go. Tests only; no product code changed.

Tests in scope: 293 -> 158 (unit 206 -> 105, e2e 87 -> 53); non-blank
test lines 4094 -> 2937. multi-account.e2e runs about half as many CLI
processes (~110 -> ~55). Product code is unchanged.

Owners kept:

  • Account selection through the CLI (multi-account.e2e): one --account
    snapshot (@beta_test) and one without --account cover every cache
    command; the snapshot now includes messages get. The only account,
    NO_ACTIVE_ACCOUNT, AUTH_REQUIRED, unknown ID, switch persistence (tg accounts switch is undone by activeAccount in config.json #61),
    activeAccount applied at start (also under -q). Selector forms (ID,
    @username in any case, label) belong to account-selector.test.
  • keepActiveAccountInConfig edge cases (no file, no key, same value,
    unwritable) belong to auth.test, once; each login keeps its own
    activation and failure test.
  • Output: format.e2e owns -f/--format pretty and quiet; output.test owns
    the JSON snapshot, retryable codes, the documented exit code table (one
    test over every ErrorCode), quiet errors, info and verbose. The error
    schema and exit wiring are owned by accounts, multi-account, media and
    credentials e2e tests.
  • access.test keeps the COMMAND_ACCESS completeness, the start guard,
    isReadMethod and the two checks access.e2e does not reach.

Removed:

  • types.test.ts (constants equal themselves, types compile),
    csv.test.ts (dead stringifyTable; includeHeader owned by sql.test),
    exit-codes.e2e.test.ts (every test duplicated accounts, media,
    credentials or help e2e).
  • Duplicates of e2e owners in account-selector (resolveAccount), access,
    output and services/telegram tests; help and format e2e tests that
    re-ran the same citty help or the default JSON.
  • auth.test's phone merge test, which used a hand-written accounts DB:
    on the real table (phone UNIQUE) that merge fails with "UNIQUE
    constraint failed: accounts.phone" and leaves a stray account. The bug
    is reported, not fixed here.
  • A vacuous QR test (toBeDefined() on null) and implied assertions.

Repaired: the background telemetry e2e test no longer sleeps 2 s in its
server, polls with sleeps or compares durations. The server holds every
response on a deferred, the test awaits the fourth event; that commands
hand events off instead of flushing is owned by telemetry.test.

Proofs: 61 product mutations failed their retained owners, each then
restored. Two stayed green, and the tests they exposed were put back: quiet errors
(config.e2e's check is skipped as root) and allowedChats leaving auth
login/logout alone (access.e2e never reaches the check for them).

How I checked it

  • Every removal was checked by breaking the product behaviour on purpose: the retained owner failed, then the code was restored.

  • The files in scope pass with bun test --parallel. Typecheck, lint, format and Knip are clean.

  • Tests pass locally and use made-up data only

  • README, docs and affected demos follow the product content standard

  • Title follows the repo's commit style: Conventional Commits (feat: …, fix: …) unless AGENTS.md says otherwise

🤖 Generated with Claude Code

Tests in scope: 293 -> 158 (unit 206 -> 105, e2e 87 -> 53); non-blank
test lines 4094 -> 2937. multi-account.e2e runs about half as many CLI
processes (~110 -> ~55). Product code is unchanged.

Owners kept:
- Account selection through the CLI (multi-account.e2e): one --account
  snapshot (@beta_test) and one without --account cover every cache
  command; the snapshot now includes messages get. The only account,
  NO_ACTIVE_ACCOUNT, AUTH_REQUIRED, unknown ID, switch persistence (#61),
  activeAccount applied at start (also under -q). Selector forms (ID,
  @username in any case, label) belong to account-selector.test.
- keepActiveAccountInConfig edge cases (no file, no key, same value,
  unwritable) belong to auth.test, once; each login keeps its own
  activation and failure test.
- Output: format.e2e owns -f/--format pretty and quiet; output.test owns
  the JSON snapshot, retryable codes, the documented exit code table (one
  test over every ErrorCode), quiet errors, info and verbose. The error
  schema and exit wiring are owned by accounts, multi-account, media and
  credentials e2e tests.
- access.test keeps the COMMAND_ACCESS completeness, the start guard,
  isReadMethod and the two checks access.e2e does not reach.

Removed:
- types.test.ts (constants equal themselves, types compile),
  csv.test.ts (dead stringifyTable; includeHeader owned by sql.test),
  exit-codes.e2e.test.ts (every test duplicated accounts, media,
  credentials or help e2e).
- Duplicates of e2e owners in account-selector (resolveAccount), access,
  output and services/telegram tests; help and format e2e tests that
  re-ran the same citty help or the default JSON.
- auth.test's phone merge test, which used a hand-written accounts DB:
  on the real table (phone UNIQUE) that merge fails with "UNIQUE
  constraint failed: accounts.phone" and leaves a stray account. The bug
  is reported, not fixed here.
- A vacuous QR test (toBeDefined() on null) and implied assertions.

Repaired: the background telemetry e2e test no longer sleeps 2 s in its
server, polls with sleeps or compares durations. The server holds every
response on a deferred, the test awaits the fourth event; that commands
hand events off instead of flushing is owned by telemetry.test.

Proofs: 61 product mutations failed their retained owners, each then
restored. Two stayed green, and the tests they exposed were put back: quiet errors
(config.e2e's check is skipped as root) and allowedChats leaving auth
login/logout alone (access.e2e never reaches the check for them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@neoromantic
neoromantic merged commit c225b0f into main Nov 19, 2026
5 checks passed
@neoromantic
neoromantic deleted the test/cleanup-cli-core branch November 19, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant