项目文件夹

文件
wehub-resource-sync 98e40dac97
CLI Smoke Test / smoke-test-linux (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-linux (24) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (24) (push) Has been cancelled
Expo App TypeScript typecheck / typecheck (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:40:49 +08:00

63 行
2.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
getImageAttachmentSendPlan,
supportsImageAttachmentsForFlavor,
} from './attachmentSupport';
describe('supportsImageAttachmentsForFlavor', () => {
it('supports legacy sessions, Claude, and Codex', () => {
expect(supportsImageAttachmentsForFlavor(undefined)).toBe(true);
expect(supportsImageAttachmentsForFlavor(null)).toBe(true);
expect(supportsImageAttachmentsForFlavor('claude')).toBe(true);
expect(supportsImageAttachmentsForFlavor('codex')).toBe(true);
});
it('rejects Gemini, OpenClaw, and unknown explicit flavors', () => {
expect(supportsImageAttachmentsForFlavor('gemini')).toBe(false);
expect(supportsImageAttachmentsForFlavor('openclaw')).toBe(false);
expect(supportsImageAttachmentsForFlavor('custom-agent')).toBe(false);
});
});
describe('getImageAttachmentSendPlan', () => {
it('uses attachments and sends text for Codex', () => {
expect(getImageAttachmentSendPlan({
flavor: 'codex',
text: '',
attachmentCount: 1,
})).toEqual({
supportsAttachments: true,
shouldUseAttachments: true,
shouldShowUnsupportedAlert: false,
shouldSendText: true,
});
});
it('warns but still sends non-empty text for unsupported agents', () => {
expect(getImageAttachmentSendPlan({
flavor: 'gemini',
text: 'describe this',
attachmentCount: 1,
})).toEqual({
supportsAttachments: false,
shouldUseAttachments: false,
shouldShowUnsupportedAlert: true,
shouldSendText: true,
});
});
it('warns and sends nothing for unsupported image-only messages', () => {
expect(getImageAttachmentSendPlan({
flavor: 'openclaw',
text: ' ',
attachmentCount: 2,
})).toEqual({
supportsAttachments: false,
shouldUseAttachments: false,
shouldShowUnsupportedAlert: true,
shouldSendText: false,
});
});
});