Skip to content

Refactor/lockfile#157

Merged
LeonardoVieira1630 merged 61 commits into
mainfrom
refactor/lockfile
Sep 11, 2025
Merged

Refactor/lockfile#157
LeonardoVieira1630 merged 61 commits into
mainfrom
refactor/lockfile

Conversation

@LeonardoVieira1630

Copy link
Copy Markdown
Member

No description provided.

LeonardoVieira1630 and others added 30 commits September 3, 2025 14:02
- Add getTelegramBotService() method for test spy injection
- Add injectSendMessageSpy() to capture real Telegram calls
- Skip bot polling in test mode with SEND_REAL_TELEGRAM
- Enable real message sending without starting bot listener
- Add ensureUserAddressInRealDB() helper for real Telegram tests
- Ensures user-address mappings exist when SEND_REAL_TELEGRAM=true
- Add real Telegram chat ID to p1 profile in test constants
- Required for voting-power notifications to find wallet owners
- Conditionally apply Telegram mocks based on SEND_REAL_TELEGRAM
- Inject spy for real sendMessage calls when using real Telegram
- Use real bot token from environment when SEND_REAL_TELEGRAM=true
- Enable capturing real API calls for verification
- Use p1 profile with real chat ID in proposal-finished tests
- Add ensureUserAddressInRealDB call in voting-power test
- Improve message verification in duplicate-prevention test
- Extend timeout for multi-DAO test with real Telegram
- Enable voting-power notifications to work with real API
- Skip spy consumer setup when SEND_REAL_TELEGRAM=true
- Prevent interference with real message processing
- Add graceful error handling for channel nack failures
- Improve robustness when channels are closed
- Enable proper message flow in integration tests
…lementations

- Create TelegramClient interface to abstract Telegram operations
- Implement RealTelegramClient for production use with Telegraf
- Implement TestTelegramClient for testing with message capture
- Add sendOnlyMode option to RealTelegramClient for test environments

This abstraction enables better testing and removes test code from production.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Refactor TelegramBotService to use TelegramClient interface
- Remove injectSendMessageSpy() and test-specific code from TelegramBotService
- Update App.ts to accept optional TelegramClient via constructor
- Remove getTelegramBotService() method from App
- Update index.ts with clarifying comment about client injection

This removes all test code from production services and uses dependency injection.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update startTestApps to create appropriate TelegramClient based on environment
- Use TestTelegramClient for mock tests, RealTelegramClient for real Telegram
- Remove complex conditional mocking from telegram-mock-setup.ts
- Fix TelegramTestHelper to properly handle message options
- Clear mock messages in duplicate-prevention test to avoid contamination
- Simplify jest-setup-after-env by removing spy injection logic

Tests now work seamlessly with both mock and real Telegram modes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Implement purgeAllQueues() method in RabbitMQTestSetup
- Call purgeAllQueues() in TestCleanup.cleanupBetweenTests()
- Purges all queues (logic-system, dispatcher, consumer, subscription)
- Prevents event leakage between test suites

This fixes test isolation issues where events from one test would affect the next.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove telegramBotToken parameter from App constructor
- Make TelegramClient a required dependency (no default creation)
- Move TelegramClient instantiation to index.ts entry point
- Update tests to match new constructor signature

App is now fully decoupled from TelegramClient implementation details.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add MatchedContext type for action handlers with regex match
- Update HandlerRegistration to use ContextWithSession
- Remove all ctx: any from handlers, using proper types
- Use MatchedContext for actions with regex patterns

Type safety improved without using any.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix inconsistent message validation in voting-power-trigger.test.ts
- Remove artificial timeout extension for real Telegram in multi-dao test
- Clean up duplicate-prevention test to use waitForNoMessages helper

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
- Consolidated 6 files (~400 lines) into 1 file (~200 lines)
- Removed unnecessary abstractions and manager classes
- Fixed duplicate container issue (was creating 2 containers)
- Fixed intermittent test failures in spy consumer
- Improved test execution time from ~95s to ~40s
- Fixed spy consumer to use nack with requeue to avoid consuming messages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Simplified test setup by removing unnecessary code and fixing interface naming.

Key changes:
- Renamed TelegramClient interface to TelegramClientInterface for clarity
- Removed bot token parameter from TestTelegramClient constructor in apps.ts
- Both SEND_REAL_TELEGRAM paths now use the same TestTelegramClient initialization
- Fixed imports to use renamed interface

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Separated test code from production code for cleaner architecture.

Key changes:
- Moved TelegramTestClient from consumers to integrated-tests/src/test-clients/
- Moved telegram.client.ts from consumers/src/clients/ to consumers/src/
- Updated all imports to use TelegramClientInterface consistently
- Fixed dispatcher test to match current implementation (multiple status values)

Benefits:
- Production bundle no longer includes test utilities
- Cleaner file structure with telegram.client.ts at src root
- All tests passing (43 dispatcher, 23 integrated-tests, etc.)
- Better separation of concerns between prod and test code

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implements vote confirmation notification handler that processes vote events
and sends confirmations to subscribed users. Includes message formatting,
deduplication, and batch processing capabilities.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add voteTest DAO constant for vote confirmation tests
- Enhance GraphQL mock to support timestamp filtering for votes
- Update anticapture client vote fetching logic

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comprehensive test suite for vote confirmation notifications including
event processing, user subscription checks, deduplication, and message
formatting validation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
LeonardoVieira1630 and others added 24 commits September 8, 2025 15:40
…nd_real_msg

Refactor/integrated tests to send real msg
- Detect self-delegation (sourceAccountId === accountId)
- Skip delegation received notification for self-delegation
- Always send delegation sent notification with voting power info
- Simplify delegation processing logic with cleaner conditional flow

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move extractTitle logic from individual trigger handlers to a centralized FormattingService to follow DRY principle and improve code reusability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implements trigger that monitors active proposals and emits events when voting period reaches 30%, 60%, and 90% thresholds. Each threshold is tracked independently with proper deduplication.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implements handler that processes voting reminder events, checks which users haven't voted via AntiCapture API, and sends appropriate notifications based on urgency level (30%, 60%, 90%).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Tests cover all thresholds (30%, 60%, 90%), deduplication logic, user voting status checks, and edge cases. Uses real Telegram IDs for SEND_REAL_TELEGRAM support.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Removes unnecessary pattern matching complexity in favor of exact trigger ID matching. This simplification improves code clarity without losing functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused VotingReminderOptions interface
- Remove generic parameter from Trigger base class usage
- Update start() calls to not pass thresholdPercentage (already set in constructor)
- Clean up fetchData() signature to remove unused options parameter

The thresholdPercentage was being passed twice - once in constructor and again
in start(), but the start() parameter was completely ignored (dead code).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Extract calculateTimeRemaining from VotingReminderTriggerHandler
- Add as static method in FormattingService for better reusability
- Update all references to use FormattingService.calculateTimeRemaining

This improves code organization by centralizing formatting logic in one place,
following Single Responsibility Principle.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove comment about pattern matching tests that were removed
when we simplified the TriggerProcessorService implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update voting reminder service tests to use FormattingService.calculateTimeRemaining
instead of trying to access the private method on the handler class.

The function was moved to FormattingService in previous commit for better
code organization and reusability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…otification

Feat/users delegation changed notification
…ctive_but_user_hasnt_vote

Feat/notification proposal is active but user hasnt vote
- Add viem dependency for address validation and conversion
- Implement normalizeAddresses method to recursively convert addresses to checksum format
- Apply normalization to all GraphQL query variables
- Fixes bug where lowercase addresses from DB weren't matching API expectations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add toChecksum helper to convert addresses to EIP-55 format
- Mock API now returns checksummed addresses (simulating real API behavior)
- Use exact address comparison instead of case-insensitive
- Validates that AnticaptureClient normalization is working correctly

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix TypeScript compilation errors in tests
- Configure ts-jest with isolatedModules for faster test runs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update types based on latest schema changes
- Some fields changed from nullable to non-nullable
- endBlock/startBlock changed from String to Float type

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…use_checksum_format

Refactor/anticapture client to use checksum format
@LeonardoVieira1630 LeonardoVieira1630 self-assigned this Sep 11, 2025
@LeonardoVieira1630 LeonardoVieira1630 merged commit dcaeeb8 into main Sep 11, 2025
@LeonardoVieira1630 LeonardoVieira1630 deleted the refactor/lockfile branch September 11, 2025 19:11
@LeonardoVieira1630 LeonardoVieira1630 restored the refactor/lockfile branch September 11, 2025 19:12
@LeonardoVieira1630 LeonardoVieira1630 deleted the refactor/lockfile branch September 11, 2025 19:15
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