Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/shared/src/chat.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ test('mcp context schemas accept valid user and caller payloads', () => {
if (callerContext.success) {
expect(callerContext.value.executionOrigin).toBe('interactive')
}
})

test('mcp caller context accepts legacy missing origins and validates marked origins', () => {
expect(
parseSafe(mcpCallerContextSchema, {
baseUrl: 'https://example.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ function createCapabilityContext(input?: {
}

test('meta platform feedback submission gates consent and isolates post-persistence enqueue failures', async () => {
expect(metaPlatformFeedbackSubmitCapability.description).toContain(
'Copies already delivered outside Kody, including Discord messages, may remain after Kody account deletion',
)
expect(
JSON.stringify(metaPlatformFeedbackSubmitCapability.inputSchema),
).toContain(
'copies already delivered outside Kody, including Discord messages, may remain after Kody account deletion',
)
mockModule.submitPlatformFeedback.mockResolvedValue(openFeedback)
const input = {
category: 'friction' as const,
Expand Down Expand Up @@ -278,8 +270,12 @@ test('admin platform feedback capabilities enforce role access, redact lists, pa
status: 'open',
category: 'friction',
})
expect(list).toMatchObject({ total: 3, page: 2, pageSize: 1 })
expect(list.content_warning).toBe(platformFeedbackContentWarning)
expect(list).toMatchObject({
total: 3,
page: 2,
pageSize: 1,
content_warning: platformFeedbackContentWarning,
})
expect(list.feedback).toEqual([
{
id: 'feedback-1',
Expand Down Expand Up @@ -309,7 +305,6 @@ test('admin platform feedback capabilities enforce role access, redact lists, pa
})
expect(get.feedback).not.toHaveProperty('summary')
expect(get.feedback).not.toHaveProperty('details')
expect(get.content_warning).toBe(platformFeedbackContentWarning)

const updated = await adminPlatformFeedbackUpdateCapability.handler(
{
Expand Down
58 changes: 27 additions & 31 deletions packages/worker/src/platform-feedback/dispatch-queue.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ function createBatch(messages: Array<ReturnType<typeof createQueueMessage>>) {
} as unknown as MessageBatch<unknown>
}

test('platform feedback queue dispatches valid duplicates and acknowledges permanent deletion cancellation', async () => {
test('platform feedback queue acks valid, invalid, and cancelled messages and retries transient failures', async () => {
consoleError.mockImplementation(() => {})
const first = createQueueMessage('queue-valid', {
feedbackId,
})
Expand All @@ -52,24 +53,39 @@ test('platform feedback queue dispatches valid duplicates and acknowledges perma
const deleted = createQueueMessage('queue-deleted', {
feedbackId: 'feedback-deleted',
})
mocks.dispatchPlatformFeedbackSubmittedSubscriptionEvent.mockImplementation(
async (input: { feedbackId: string }) => {
if (input.feedbackId === 'feedback-deleted') {
throw new PlatformFeedbackDispatchCancelledError(input.feedbackId)
}
return []
},
)
const loadFailure = createQueueMessage('queue-load-failure', {
feedbackId: 'feedback-load-failure',
})
const dispatchFailure = createQueueMessage('queue-dispatch-failure', {
feedbackId,
})
mocks.dispatchPlatformFeedbackSubmittedSubscriptionEvent
.mockResolvedValueOnce([])
.mockResolvedValueOnce([])
.mockRejectedValueOnce(
new PlatformFeedbackDispatchCancelledError('feedback-deleted'),
)
.mockRejectedValueOnce(new Error('D1 lookup unavailable'))
.mockRejectedValueOnce(new Error('subscription wrapper unavailable'))

await handlePlatformFeedbackDispatchQueue(
createBatch([first, duplicate, missing, invalid, extraFields, deleted]),
createBatch([
first,
duplicate,
missing,
invalid,
extraFields,
deleted,
loadFailure,
dispatchFailure,
]),
{ APP_DB: {} } as Env,
{} as ExecutionContext,
)

expect(
mocks.dispatchPlatformFeedbackSubmittedSubscriptionEvent,
).toHaveBeenCalledTimes(3)
).toHaveBeenCalledTimes(5)
expect(
mocks.dispatchPlatformFeedbackSubmittedSubscriptionEvent,
).toHaveBeenNthCalledWith(1, {
Expand Down Expand Up @@ -99,26 +115,6 @@ test('platform feedback queue dispatches valid duplicates and acknowledges perma
expect(message.ack).toHaveBeenCalledTimes(1)
expect(message.retry).not.toHaveBeenCalled()
}
})

test('platform feedback queue retries lookup and subscription wrapper failures after thirty seconds', async () => {
consoleError.mockImplementation(() => {})
const loadFailure = createQueueMessage('queue-load-failure', {
feedbackId: 'feedback-load-failure',
})
const dispatchFailure = createQueueMessage('queue-dispatch-failure', {
feedbackId,
})
mocks.dispatchPlatformFeedbackSubmittedSubscriptionEvent
.mockRejectedValueOnce(new Error('D1 lookup unavailable'))
.mockRejectedValueOnce(new Error('subscription wrapper unavailable'))

await handlePlatformFeedbackDispatchQueue(
createBatch([loadFailure, dispatchFailure]),
{ APP_DB: {} } as Env,
{} as ExecutionContext,
)

for (const message of [loadFailure, dispatchFailure]) {
expect(message.ack).not.toHaveBeenCalled()
expect(message.retry).toHaveBeenCalledWith({ delaySeconds: 30 })
Expand Down
Loading
Loading