d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { gmailHandler } from '@/lib/webhooks/providers/gmail'
|
|
import { gmailPollingTrigger } from '@/triggers/gmail'
|
|
|
|
const sampleEmail = {
|
|
id: 'msg-123',
|
|
threadId: 'thread-456',
|
|
subject: 'Test subject',
|
|
from: 'sender@example.com',
|
|
to: 'recipient@example.com',
|
|
cc: '',
|
|
date: '2026-07-08T00:00:00.000Z',
|
|
bodyText: 'plain text body',
|
|
bodyHtml: '<p>html body</p>',
|
|
labels: ['INBOX', 'UNREAD'],
|
|
hasAttachments: false,
|
|
attachments: [],
|
|
}
|
|
|
|
describe('Gmail webhook provider', () => {
|
|
it('formatInput passes through the polled email and timestamp unchanged', async () => {
|
|
const { input } = await gmailHandler.formatInput!({
|
|
webhook: {},
|
|
workflow: { id: 'wf', userId: 'u' },
|
|
body: { email: sampleEmail, timestamp: '2026-07-08T00:00:05.000Z' },
|
|
headers: {},
|
|
requestId: 'test',
|
|
})
|
|
|
|
expect(input).toEqual({
|
|
email: sampleEmail,
|
|
timestamp: '2026-07-08T00:00:05.000Z',
|
|
})
|
|
})
|
|
|
|
it('passes the raw body through when it has no email key', async () => {
|
|
const { input } = await gmailHandler.formatInput!({
|
|
webhook: {},
|
|
workflow: { id: 'wf', userId: 'u' },
|
|
body: { foo: 'bar' },
|
|
headers: {},
|
|
requestId: 'test',
|
|
})
|
|
|
|
expect(input).toEqual({ foo: 'bar' })
|
|
})
|
|
|
|
it('every key formatInput can deliver on `email` matches a declared trigger output key', async () => {
|
|
const { input } = await gmailHandler.formatInput!({
|
|
webhook: {},
|
|
workflow: { id: 'wf', userId: 'u' },
|
|
body: { email: sampleEmail, timestamp: '2026-07-08T00:00:05.000Z' },
|
|
headers: {},
|
|
requestId: 'test',
|
|
})
|
|
|
|
const declaredEmailKeys = Object.keys(gmailPollingTrigger.outputs.email)
|
|
const deliveredEmailKeys = Object.keys((input as { email: object }).email)
|
|
|
|
expect(deliveredEmailKeys.sort()).toEqual(declaredEmailKeys.sort())
|
|
})
|
|
})
|