feat(chat): add agent attachments and shared conversation confirmation
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const { test } = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
const fs = require('node:fs')
|
||||
const vm = require('node:vm')
|
||||
const ts = require('typescript')
|
||||
const output = {}
|
||||
vm.runInNewContext(ts.transpileModule(fs.readFileSync(require.resolve('../src/renderer/src/components/chatAttachments.ts'), 'utf8'), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 }
|
||||
}).outputText, { exports: output, TextDecoder })
|
||||
const { readChatAttachments } = output
|
||||
const file = (name, content) => new File([content], name)
|
||||
|
||||
test('reads source/config/log files and preserves Korean UTF-8 text', async () => {
|
||||
const files = await readChatAttachments([file('control.py', '# 조향 설정'), file('config.yaml', 'robot: mkmini'), file('runtime.log', 'started')], [])
|
||||
assert.equal(files[0].content, '# 조향 설정')
|
||||
assert.equal(files[2].name, 'runtime.log')
|
||||
})
|
||||
test('rejects unsupported image/PDF files', async () => {
|
||||
await assert.rejects(readChatAttachments([file('photo.png', 'image')], []), /이미지와 PDF/)
|
||||
await assert.rejects(readChatAttachments([file('guide.pdf', 'pdf')], []), /이미지와 PDF/)
|
||||
})
|
||||
test('rejects more than five attachments including existing ones', async () => {
|
||||
await assert.rejects(readChatAttachments([file('a.txt', 'a')], Array(5).fill({ name: 'b.txt', content: '' })), /최대 5개/)
|
||||
})
|
||||
test('rejects binary and non-UTF8 content even under a text extension', async () => {
|
||||
await assert.rejects(readChatAttachments([file('a.txt', 'a\0b')], []), /바이너리/)
|
||||
await assert.rejects(readChatAttachments([file('a.txt', new Uint8Array([255, 254]))], []), /UTF-8/)
|
||||
})
|
||||
test('rejects oversized files instead of silently truncating', async () => {
|
||||
await assert.rejects(readChatAttachments([file('a.txt', 'a'.repeat(100_001))], []), /100KB/)
|
||||
await assert.rejects(readChatAttachments([file('a.txt', 'a'.repeat(50_001))], []), /5만 자/)
|
||||
})
|
||||
test('rejects aggregate attachment context above 100000 characters', async () => {
|
||||
await assert.rejects(readChatAttachments([file('a.txt', 'a'.repeat(50_000)), file('b.txt', 'a'.repeat(50_000))], []), /10만 자/)
|
||||
})
|
||||
Reference in New Issue
Block a user