Skip to content

feat(trello): add createBoardCustomField support#781

Merged
aaight merged 2 commits intodevfrom
feature/trello-custom-fields
Mar 13, 2026
Merged

feat(trello): add createBoardCustomField support#781
aaight merged 2 commits intodevfrom
feature/trello-custom-fields

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 13, 2026

Summary

Add Trello custom field creation support to enable the dashboard wizard to create cost fields on boards.

  • Trello client method: createBoardCustomField(boardId, name, type) makes POST to /customFields endpoint
  • tRPC endpoint: createTrelloCustomField mutation in integrationsDiscoveryRouter with full validation
  • Input validation: boardId (alphanumeric, max 32), name (min 1, max 100), type (enum of valid types)
  • Return value: { id, name, type } matching existing custom field shape

Implementation Details

Trello Client (src/trello/client.ts)

  • New async method that follows the createBoardLabel pattern
  • Uses trelloFetch to POST to /customFields with proper body structure
  • Normalizes response fields with defaults for missing data

tRPC Router (src/api/routers/integrationsDiscovery.ts)

  • Mutation endpoint with trelloCredsInput extension
  • Zod validation schema for all inputs
  • Uses existing credential resolution and error wrapping patterns
  • Returns custom field data on success, wraps API errors in BAD_REQUEST

Tests

  • Client tests (6 new tests): API call verification, type handling, error cases
  • Endpoint tests (9 new tests): success response, auth, validation, error handling

Test Results

✅ All 4,603 unit tests pass
✅ Type checking: zero errors
✅ Linting: zero errors

Acceptance Criteria

✅ createBoardCustomField method in trelloClient
✅ Returns { id, name, type } shape
✅ createTrelloCustomField tRPC endpoint
✅ Input validation (boardId, name, type)
✅ Comprehensive unit tests
✅ Tests cover auth, success, validation, error handling

PR Link: https://trello.com/c/69b4443615a99b32a56777d2

- Add createBoardCustomField method to trelloClient making POST to /customFields
- Method accepts boardId, name, type and returns { id, name, type }
- Add createTrelloCustomField tRPC mutation in integrationsDiscoveryRouter
- Validate boardId (alphanumeric, max 32), name (min 1, max 100), type (enum)
- Add unit tests for client method and tRPC endpoint
- Tests cover success, validation, auth, credentials, and error handling
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

Clean, well-structured addition that follows existing patterns precisely. One minor test organization issue worth addressing.

Should Fix

  • tests/unit/api/routers/integrationsDiscovery.test.ts:490 — The new describe('createTrelloCustomField') block is placed outside the parent describe('integrationsDiscoveryRouter') block (which closes at line 486). All other endpoint test suites are nested inside the parent describe. This means the beforeEach at line 99-102 — which wires up the DB mock chain (mockDbSelectmockDbFrommockDbWhere) — does not run before these tests.

    The tests currently pass because mockReturnValue sets a persistent default that survives from earlier tests in the parent describe, but this is order-dependent and fragile. If these tests were ever run in isolation or test ordering changed, the DB-dependent tests (success, NOT_FOUND, API failure) would break.

    Fix: Move the describe('createTrelloCustomField', ...) block inside the parent describe('integrationsDiscoveryRouter', ...) to match the existing pattern for all other endpoint test suites.

Everything else looks good:

  • Client method follows the createBoardLabel pattern exactly
  • tRPC endpoint uses the established withResolvedTrelloCreds + withTrelloCredentials + wrapIntegrationCall chain
  • Input validation (boardId regex/length, name bounds, type enum) is consistent with existing endpoints
  • Return shape { id, name, type } matches getBoardCustomFields
  • Test coverage is thorough (auth, validation, success, error wrapping, scope checking)
  • CI all green

Move the describe('createTrelloCustomField') block inside the parent
describe('integrationsDiscoveryRouter') so the beforeEach DB mock setup
runs before these tests, matching the pattern of all other endpoint suites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

LGTM — Clean, well-structured addition that precisely follows the existing createBoardLabel pattern in both the Trello client and tRPC router. Input validation, credential resolution, and error wrapping all use established conventions. Test coverage is comprehensive (auth, validation, success, error paths). CI is green.

@aaight aaight merged commit def7c05 into dev Mar 13, 2026
6 checks passed
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.

2 participants