Support status-prefixed structured attachments

Support status-prefixed structured attachment output and keep visible verdict text.
This commit is contained in:
Eyejoker
2026-05-02 19:22:55 +09:00
committed by GitHub
parent fb32726ac0
commit 9e45534de0
4 changed files with 151 additions and 3 deletions

View File

@@ -173,4 +173,56 @@ describe('DiscordChannel structured output', () => {
'"ejclaw"',
);
});
it('normalizes status-prefixed EJClaw JSON and keeps the status line visible', async () => {
const channel = new DiscordChannel('test-token', createTestOpts());
await channel.connect();
const filePath = path.join(
os.tmpdir(),
`ejclaw-discord-image-status-${Date.now()}.png`,
);
fs.writeFileSync(filePath, ONE_PIXEL_PNG);
tempFiles.push(filePath);
const mockChannel = {
send: vi.fn().mockResolvedValue({ id: 'discord-message-2' }),
sendTyping: vi.fn(),
};
clientRef.current.channels.fetch.mockResolvedValue(mockChannel);
await channel.sendMessage(
'dc:1234567890123456',
`TASK_DONE
\`\`\`json
${JSON.stringify({
ejclaw: {
visibility: 'public',
text: '첨부 테스트입니다.',
verdict: 'done',
attachments: [
{
path: filePath,
name: 'status.png',
mime: 'image/png',
},
],
},
})}
\`\`\``,
);
expect(mockChannel.send).toHaveBeenCalledWith({
content: 'TASK_DONE\n\n첨부 테스트입니다.',
files: [
{
attachment: fs.realpathSync(filePath),
name: 'status.png',
},
],
flags: 1 << 2,
});
expect(JSON.stringify(mockChannel.send.mock.calls)).not.toContain(
'"ejclaw"',
);
});
});