55import { describe , it , expect , jest , beforeEach , afterEach } from '@jest/globals' ;
66import { VotingReminderTrigger } from '../src/triggers/voting-reminder-trigger' ;
77import { ProposalOnChain } from '../src/interfaces/proposal.interface' ;
8- import { DispatcherService , DispatcherMessage } from '../src/interfaces/dispatcher.interface' ;
8+ import { DispatcherService } from '../src/interfaces/dispatcher.interface' ;
99import { MockedFunction } from 'jest-mock' ;
1010
1111describe ( 'VotingReminderTrigger' , ( ) => {
@@ -111,30 +111,6 @@ describe('VotingReminderTrigger', () => {
111111 expect ( mockDispatcherService . sendMessage ) . not . toHaveBeenCalled ( ) ;
112112 } ) ;
113113
114- it ( 'should update timestampCursor after processing' , async ( ) => {
115- const proposalStart = baseTime - 3600 ;
116- const proposalEnd = baseTime + 300 ; // within 90-95% window
117-
118- const proposal : ProposalOnChain = {
119- id : 'proposal-123' ,
120- daoId : 'test-dao' ,
121- description : 'Test proposal' ,
122- timestamp : proposalStart . toString ( ) ,
123- endTimestamp : proposalEnd . toString ( ) ,
124- status : 'ACTIVE'
125- } as ProposalOnChain ;
126-
127- // Process proposal
128- await trigger . process ( [ proposal ] ) ;
129-
130- // Check that timestampCursor was updated to the proposal's timestamp + 1
131- // +1 to avoid duplicates since API uses >= comparison
132- const updatedTimestamp = ( trigger as any ) . timestampCursor ;
133- expect ( updatedTimestamp ) . toBe ( proposalStart + 1 ) ;
134-
135- expect ( mockDispatcherService . sendMessage ) . toHaveBeenCalledTimes ( 1 ) ;
136- } ) ;
137-
138114 it ( 'should skip proposals without required timestamps' , async ( ) => {
139115 const proposal : ProposalOnChain = {
140116 id : 'proposal-123' ,
@@ -187,7 +163,7 @@ describe('VotingReminderTrigger', () => {
187163 } ) ;
188164
189165 describe ( 'fetchData' , ( ) => {
190- it ( 'should fetch active proposals with fromDate filter' , async ( ) => {
166+ it ( 'should fetch active proposals without timestamp filter' , async ( ) => {
191167 const proposals = [
192168 { id : 'prop-1' , status : 'ACTIVE' } ,
193169 { id : 'prop-2' , status : 'ACTIVE' }
@@ -197,46 +173,15 @@ describe('VotingReminderTrigger', () => {
197173
198174 const result = await trigger [ 'fetchData' ] ( ) ;
199175
200- // Should include fromDate filter with timestampCursor and exclude optimistic proposals
176+ // Should only filter by status ACTIVE, no fromDate
201177 expect ( mockProposalRepository . listAll ) . toHaveBeenCalledWith ( {
202178 status : 'ACTIVE' ,
203- fromDate : expect . any ( Number ) ,
204179 includeOptimisticProposals : false
205180 } ) ;
206181 expect ( result ) . toEqual ( proposals ) ;
207182 } ) ;
208183 } ) ;
209184
210- describe ( 'reset' , ( ) => {
211- it ( 'should reset the timestampCursor' , ( ) => {
212- // Create trigger with initial timestamp
213- const initialTimestamp = '1000000' ;
214- const triggerWithTimestamp = new VotingReminderTrigger (
215- mockDispatcherService ,
216- mockProposalRepository ,
217- 30000 ,
218- 90 ,
219- 5 ,
220- initialTimestamp
221- ) ;
222-
223- // Reset without timestamp - should default to 24 hours ago
224- triggerWithTimestamp . reset ( ) ;
225-
226- // Access private property for testing
227- const resetTimestamp = ( triggerWithTimestamp as any ) . timestampCursor ;
228- const twentyFourHoursAgo = Math . floor ( ( Date . now ( ) - 24 * 60 * 60 * 1000 ) / 1000 ) ;
229-
230- // Should be around 24 hours ago (within 1 second tolerance)
231- expect ( Math . abs ( resetTimestamp - twentyFourHoursAgo ) ) . toBeLessThanOrEqual ( 1 ) ;
232-
233- // Reset with specific timestamp
234- triggerWithTimestamp . reset ( '2000000' ) ;
235- const specificTimestamp = ( triggerWithTimestamp as any ) . timestampCursor ;
236- expect ( specificTimestamp ) . toBe ( 2000000 ) ;
237- } ) ;
238- } ) ;
239-
240185 describe ( 'time calculation' , ( ) => {
241186 it ( 'should calculate time elapsed percentage correctly' , ( ) => {
242187 const startTime = 1000 ;
0 commit comments