Skip to content

Commit 30f0732

Browse files
committed
fix(gmail): type the polling test's workflow record and drop its redundant mock reset
1 parent 22d95f5 commit 30f0732

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

‎apps/sim/lib/webhooks/polling/gmail.test.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { createLogger } from '@sim/logger'
2-
import { createWorkflowRecord } from '@sim/testing/factories/permission.factory'
32
import { jsonResponse } from '@sim/testing/helpers/http'
43
import { idempotencyServiceMock } from '@sim/testing/mocks/idempotency-service.mock'
54
import {
@@ -19,14 +18,40 @@ vi.mock('@/lib/webhooks/processor', () => webhooksProcessorMock)
1918
vi.mock('@/lib/webhooks/polling/utils', () => webhooksPollingUtilsMock)
2019

2120
import { 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

2427
const { mockUpdateWebhookProviderConfig: mockUpdateConfig, mockResolveOAuthCredential } =
2528
webhooksPollingUtilsMockFns
2629
const mockProcessEvent = webhooksProcessorMockFns.mockProcessPolledWebhookEvent
2730

2831
const 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+
3055
interface 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

116139
describe('gmailPollingHandler expired history cursor', () => {
117140
beforeEach(() => {
118-
vi.clearAllMocks()
119141
mockResolveOAuthCredential.mockResolvedValue('access-token')
120142
mockProcessEvent.mockResolvedValue({ success: true })
121143
})

0 commit comments

Comments
 (0)