Skip to content

Conversation

@snoble
Copy link
Contributor

@snoble snoble commented Dec 11, 2025

This PR adds tests to verify that the generated SDK exposes type-specific methods (e.g., PostUserFundsAccount, PostFundingSettlement) for entry types defined in schemas with lines.

Changes

  • Added tests for entry type methods with different naming conventions:
    • Hyphenated naming (user-funds-account → PostUserFundsAccount)
    • CamelCase naming (fundingSettlement → PostFundingSettlement)
    • Underscore naming (payment_processing → PostPaymentProcessing)
  • Tests verify method existence and functionality when methods are generated
  • Tests use schemas with entry types that have lines defined (not empty)
  • Consolidated tests into basic-test.test.ts to match existing test structure

Testing

Tests will verify:

  • Whether type-specific Post methods exist on the client
  • If methods exist, they can be called and create entries correctly
  • Multiple entry types in a single schema work correctly

- Add test file to verify generated Post methods for entry types
- Test hyphenated, camelCase, and underscore naming conventions
- Test schemas with entry types that have lines defined
- Verify method existence and functionality when methods are generated
- Consolidate tests into basic-test.test.ts to match existing test structure
- Remove console.log statements to match existing test style
- Simplify test names and variable names to match existing patterns
- Test entry type methods with hyphenated, camelCase, and underscore naming
- Document how type-specific methods are generated for entry types with lines
- Show examples with different naming conventions (hyphenated, camelCase, underscore)
- Explain when methods are available and fallback to addLedgerEntry
- Try individual parameters first (amount as direct arg)
- Fall back to parameters object if individual params fail
- All entry types have required 'amount' parameter from {{amount}} template
- Add detectParameterStyle helper that throws if method signature is unexpected
- Tests now explicitly fail if parameter style can't be determined
- Add dedicated test to verify parameter style and ensure wrong style fails
- Tests will catch API changes or incorrect method signatures
- Add EXPECTED_PARAMETER_STYLE constant to document expected signature
- Replace detectParameterStyle with verifyParameterStyle that fails if signature doesn't match
- Tests now explicitly use expected style and fail if it's wrong
- Remove fallback logic - tests will fail if signature is unexpected
- Add tests/fixtures/test-schema.json with entry types
- Generate GraphQL queries using Fragment CLI
- Generate SDK from GraphQL queries
- Add scripts/update-test-schema.sh for easy updates
- Add CI check to verify generated files match schema
- Add tests/generated-sdk.test.ts that imports generated SDK directly
- Update EXPECTED_PARAMETER_STYLE to 'individual' (Fragment CLI generates individual params)
- Update README to show correct parameter style
- Install Homebrew on Ubuntu runner
- Install Fragment CLI from fragment-dev/tap
- Use full path to fragment command in verification step
- Cache Homebrew installation directory and cache
- Only install Homebrew if not cached
- Check if Fragment CLI is installed before installing
- Set up brew shellenv properly for cached installations
- Update test schema to include user-funds-account with typeVersion 1 and 2
- Regenerate GraphQL queries and SDK (includes PostUserFundsAccount_v2)
- Add typeVersion to GraphQL query response fields
- Update test to verify both version 1 and version 2 entries can be posted
- Test verifies typeVersion in response matches expected version
- Add expense-root account to schema
- Add fee-line to typeVersion 2 entry type using {{feeAmount}} parameter
- Adjust asset-line to account for fee: {{amount}} - {{feeAmount}}
- Update test to include expense account and pass feeAmount parameter
- Generated SDK now includes feeAmount as a required parameter for PostUserFundsAccount_v2
- Explain how typeVersion affects method naming
- Show examples of version 1 vs version 2 method calls
- Document that different versions can have different parameters
- Add typeVersion field to all entry response blocks in GraphQL queries
- Regenerate SDK to include typeVersion in TypeScript types
- Fixes TypeScript errors in tests that check typeVersion
- Fragment CLI doesn't include typeVersion in response by default
- Add sed command to insert typeVersion after type field in all entry blocks
- This ensures generated SDK includes typeVersion in TypeScript types
- Regenerate files to match CI expectations
…tead

- Remove sed command that added typeVersion to GraphQL queries
- Tests now verify version differences by checking line structure
- Version 1 has 2 lines, version 2 has 3 lines (including fee-line)
- This tests what Fragment CLI actually generates, not modified output
Co-authored-by: Vigneshwer Vaidyanathan <vignesh.vaid@gmail.com>
@snoble snoble merged commit 20cb9f9 into dev Dec 11, 2025
4 checks passed
@snoble snoble deleted the test-entry-type-methods branch December 11, 2025 20:11
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.

3 participants