11import { createLogger } from '@sim/logger'
2- import { createWorkflowRecord } from '@sim/testing/factories/permission.factory'
32import { jsonResponse } from '@sim/testing/helpers/http'
43import { idempotencyServiceMock } from '@sim/testing/mocks/idempotency-service.mock'
54import {
@@ -19,14 +18,40 @@ vi.mock('@/lib/webhooks/processor', () => webhooksProcessorMock)
1918vi . mock ( '@/lib/webhooks/polling/utils' , ( ) => webhooksPollingUtilsMock )
2019
2120import { gmailPollingHandler } from '@/lib/webhooks/polling/gmail'
22- import type { PollWebhookContext , WebhookRecord } from '@/lib/webhooks/polling/types'
21+ import type {
22+ PollWebhookContext ,
23+ WebhookRecord ,
24+ WorkflowRecord ,
25+ } from '@/lib/webhooks/polling/types'
2326
2427const { mockUpdateWebhookProviderConfig : mockUpdateConfig , mockResolveOAuthCredential } =
2528 webhooksPollingUtilsMockFns
2629const mockProcessEvent = webhooksProcessorMockFns . mockProcessPolledWebhookEvent
2730
2831const EXPIRED_HISTORY_ID = '30000'
2932
33+ const WORKFLOW : WorkflowRecord = {
34+ id : 'gmail-listener' ,
35+ userId : 'gmail-owner' ,
36+ workspaceId : 'gmail-workspace' ,
37+ folderId : null ,
38+ sortOrder : 0 ,
39+ name : 'Gmail listener' ,
40+ description : null ,
41+ lastSynced : new Date ( '2026-10-01T00:00:00.000Z' ) ,
42+ createdAt : new Date ( '2026-10-01T00:00:00.000Z' ) ,
43+ updatedAt : new Date ( '2026-10-01T00:00:00.000Z' ) ,
44+ isDeployed : true ,
45+ deployedAt : new Date ( '2026-10-01T00:00:00.000Z' ) ,
46+ isPublicApi : false ,
47+ locked : false ,
48+ forkSyncExcluded : false ,
49+ runCount : 0 ,
50+ lastRunAt : null ,
51+ variables : { } ,
52+ archivedAt : null ,
53+ }
54+
3055interface MailboxState {
3156 profileHistoryId : string
3257 inboxMessages : { id : string ; historyId : string } [ ]
@@ -61,9 +86,7 @@ function context(providerConfig: Record<string, unknown>): PollWebhookContext {
6186 }
6287 return {
6388 webhookData,
64- workflowData : createWorkflowRecord ( {
65- id : 'gmail-listener' ,
66- } ) as PollWebhookContext [ 'workflowData' ] ,
89+ workflowData : WORKFLOW ,
6790 requestId : 'gmail-request' ,
6891 logger : createLogger ( 'GmailTest' ) ,
6992 }
@@ -115,7 +138,6 @@ function persistedHistoryIds() {
115138
116139describe ( 'gmailPollingHandler expired history cursor' , ( ) => {
117140 beforeEach ( ( ) => {
118- vi . clearAllMocks ( )
119141 mockResolveOAuthCredential . mockResolvedValue ( 'access-token' )
120142 mockProcessEvent . mockResolvedValue ( { success : true } )
121143 } )
0 commit comments