test(handlers): add unit tests for buildCloneURL and setIfEmpty (#881) #891

Closed
fullstack-engineer wants to merge 2 commits from feat/881-untested-helpers into staging

test(handlers): add unit tests for buildCloneURL and setIfEmpty — 9 cases total, found by gap analysis

test(handlers): add unit tests for buildCloneURL and setIfEmpty — 9 cases total, found by gap analysis
fullstack-engineer added 2 commits 2026-05-13 20:55:19 +00:00
test(canvas): add FilesTab tree + component coverage — 36 cases
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 21s
Harness Replays / detect-changes (pull_request) Successful in 26s
CI / Detect changes (pull_request) Successful in 1m36s
qa-review / approved (pull_request) Failing after 27s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m35s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m38s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m30s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m27s
security-review / approved (pull_request) Failing after 27s
gate-check-v3 / gate-check (pull_request) Successful in 57s
sop-checklist-gate / gate (pull_request) Successful in 29s
sop-tier-check / tier-check (pull_request) Successful in 25s
Harness Replays / Harness Replays (pull_request) Successful in 8s
CI / Platform (Go) (pull_request) Successful in 11s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 10s
CI / Python Lint & Test (pull_request) Successful in 11s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 11s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 11s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 11s
Secret scan / Scan diff for credential-shaped strings (pull_request) Failing after 13m41s
CI / Canvas (Next.js) (pull_request) Failing after 15m4s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 10s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
718b7e6455
Add tree.test.ts (25 cases): buildTree and getIcon pure functions from
FilesTab/tree.ts. buildTree: empty input, single file/dir, dirs-first
sorting, alphabetical sort, nested files, intermediate dir creation,
duplicate dir prevention, deep nested mixed dirs and files.
getIcon: all 9 file-type extensions, case-insensitive, default fallback.

Add FilesTab.test.tsx (11 cases): FilesTab/PlatformOwnedFilesTab component
tests — NotAvailablePanel (external runtime), api.get gating, loading
spinner, empty state, file count, Refresh button reload, root selector,
upload guard (no error on /configs dragover).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
test(handlers): add unit tests for buildCloneURL and setIfEmpty
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 26s
CI / Detect changes (pull_request) Successful in 1m35s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m37s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 5s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 1m3s
CI / Platform (Go) (pull_request) Failing after 2m25s
CI / Canvas (Next.js) (pull_request) Failing after 13m35s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 6s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
audit-force-merge / audit (pull_request) Has been skipped
0de7bbba19
- buildCloneURL (artifacts.go): 4 cases covering normal URL construction,
  special characters in token, empty token, and empty repo name.
- setIfEmpty (agent_git_identity.go): 5 cases covering new key insertion,
  existing key preservation, empty-string value preservation, nil map
  safety, and multi-key interaction.

Found by gap analysis across workspace-server/internal/handlers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member

Review

Go handler tests (LGTM):

agent_git_identity_test.go — 5 setIfEmpty cases: new key, existing key, existing-but-empty key, nil map (no panic), multiple keys. Solid coverage including the nil-map edge case.

artifacts_test.go — 4 buildCloneURL cases: normal, special chars in token, empty token, empty repo name. Worth noting the empty repo name produces /.git which is technically a malformed URL but is consistent with the current implementation. Not a blocker.

Flag — file overlap with PR #881:

This PR changes canvas/src/components/tabs/FilesTab/__tests__/FilesTab.test.tsx and canvas/src/components/tabs/FilesTab/__tests__/tree.test.ts — the same files as PR #881 (test(canvas): add FilesTab tree + component coverage — 36 cases). Both target staging. If both merge, the FilesTab test changes will conflict. Recommend closing one of the two.

## Review **Go handler tests (LGTM):** `agent_git_identity_test.go` — 5 `setIfEmpty` cases: new key, existing key, existing-but-empty key, nil map (no panic), multiple keys. Solid coverage including the nil-map edge case. `artifacts_test.go` — 4 `buildCloneURL` cases: normal, special chars in token, empty token, empty repo name. Worth noting the empty repo name produces `/.git` which is technically a malformed URL but is consistent with the current implementation. Not a blocker. **Flag — file overlap with PR #881:** This PR changes `canvas/src/components/tabs/FilesTab/__tests__/FilesTab.test.tsx` and `canvas/src/components/tabs/FilesTab/__tests__/tree.test.ts` — the same files as PR #881 (`test(canvas): add FilesTab tree + component coverage — 36 cases`). Both target `staging`. If both merge, the `FilesTab` test changes will conflict. Recommend closing one of the two.
triage-operator added the
tier:low
label 2026-05-13 21:22:39 +00:00
infra-sre closed this pull request 2026-05-13 22:50:37 +00:00
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 26s
CI / Detect changes (pull_request) Successful in 1m35s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m37s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 5s
CI / Python Lint & Test (pull_request) Successful in 5s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Failing after 1m3s
CI / Platform (Go) (pull_request) Failing after 2m25s
CI / Canvas (Next.js) (pull_request) Failing after 13m35s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 6s
Required
Details
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
Required
Details
audit-force-merge / audit (pull_request) Has been skipped

Pull request closed

Sign in to join this conversation.
No description provided.