2026-04-20 15:41:15 +03:00
|
|
|
import { describe, expect, it } from 'vitest';
|
2026-02-11 23:51:03 -08:00
|
|
|
|
2026-02-22 19:05:13 -03:00
|
|
|
import { prepareNotificationLastMessage, truncateNotificationText } from './message.js';
|
2026-02-11 23:51:03 -08:00
|
|
|
|
|
|
|
|
describe('notification message helpers', () => {
|
|
|
|
|
it('truncates oversized notification text', () => {
|
|
|
|
|
expect(truncateNotificationText('abcdef', 3)).toBe('abc...');
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-19 02:06:52 +03:00
|
|
|
it('ignores retired summarization settings and truncates original message', async () => {
|
2026-02-11 23:51:03 -08:00
|
|
|
const result = await prepareNotificationLastMessage({
|
|
|
|
|
message: '0123456789',
|
|
|
|
|
settings: {
|
|
|
|
|
summarizeLastMessage: true,
|
|
|
|
|
summaryThreshold: 5,
|
|
|
|
|
summaryLength: 3,
|
|
|
|
|
maxLastMessageLength: 4,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(result).toBe('0123...');
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-19 02:06:52 +03:00
|
|
|
it('normalizes markdown message to plain text', async () => {
|
2026-02-11 23:51:03 -08:00
|
|
|
const result = await prepareNotificationLastMessage({
|
2026-05-19 02:06:52 +03:00
|
|
|
message: "**Committed.**\n\n- Commit: `85924b9d`\n- Message: `fix desktop notifications`",
|
2026-02-11 23:51:03 -08:00
|
|
|
settings: {
|
2026-04-06 17:40:20 +03:00
|
|
|
maxLastMessageLength: 200,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(result).toBe('Committed. Commit: 85924b9d Message: fix desktop notifications');
|
|
|
|
|
});
|
2026-02-11 23:51:03 -08:00
|
|
|
});
|