Files
ai-code-app/tests/mainChatPanel/messageParts.test.ts

68 lines
2.2 KiB
TypeScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { extractChatMessageParts } from '../../src/app/main/mainChatPanel/messageParts';
test('extractChatMessageParts keeps internal resource link-card lines as plain resource urls', () => {
assert.deepEqual(
extractChatMessageParts(
[
'표 원본입니다.',
'[[link-card:테이블 열기|/api/chat/resources/.codex_chat/chat-room/resource/reports/table.json|열기]]',
].join('\n'),
),
{
strippedText: ['표 원본입니다.', '/api/chat/resources/.codex_chat/chat-room/resource/reports/table.json'].join('\n'),
parts: [],
},
);
});
test('extractChatMessageParts does not promote relative internal resource markdown links into link cards', () => {
assert.deepEqual(
extractChatMessageParts(
['문서 경로', '[/api/chat/resources 문서](/api/chat/resources/.codex_chat/chat-room/resource/source/chat-room-reference.md)'].join(
'\n',
),
),
{
strippedText: ['문서 경로', '[/api/chat/resources 문서](/api/chat/resources/.codex_chat/chat-room/resource/source/chat-room-reference.md)'].join(
'\n',
),
parts: [],
},
);
});
test('extractChatMessageParts keeps angle-bracket internal resource markdown links as plain text', () => {
assert.deepEqual(
extractChatMessageParts(
['문서 경로', '[채팅방 참고 문서](</api/chat/resources/.codex_chat/chat-room/resource/source/chat room reference.md>)'].join(
'\n',
),
),
{
strippedText: ['문서 경로', '[채팅방 참고 문서](</api/chat/resources/.codex_chat/chat-room/resource/source/chat room reference.md>)'].join(
'\n',
),
parts: [],
},
);
});
test('extractChatMessageParts promotes standalone markdown links with angle-bracket external targets into link cards', () => {
assert.deepEqual(
extractChatMessageParts(' - [판매글 열기](<https://www.daangn.com/kr/buy-sell/mac studio>)'),
{
strippedText: '',
parts: [
{
type: 'link_card',
title: '판매글 열기',
url: 'https://www.daangn.com/kr/buy-sell/mac studio',
actionLabel: null,
},
],
},
);
});