agent-ecosystem/test/shared/constants/crossTeam.test.ts
iliya bec8a6184a fix: refine regex patterns and improve utility functions for mention handling
- Updated regex patterns in chipUtils and mentionLinkify to enhance boundary detection for mentions.
- Refactored taskChangeRequest to simplify earliest date calculation using array destructuring.
- Improved taskReferenceUtils by replacing character boundary checks with a more concise regex.
- Enhanced teamMessageFiltering to ensure boolean checks for message filtering conditions.
- Adjusted urlMatchUtils to refine URL matching regex for better accuracy.
- Updated crossTeam constants to include comments for regex patterns, improving code clarity.
- Removed unused CommentAttachmentPayload type from api.ts to clean up type definitions.
- Introduced McpInstallScope type for better type safety in mcp.ts.
- Enhanced extensionNormalizers to improve URL normalization and added tests for parseGitHubOwnerRepo function.
- Cleaned up pricing.ts by removing unnecessary eslint disable comments.
- Added tests for new functionality in chipUtils and crossTeam constants, ensuring robust coverage.
2026-03-19 13:35:51 +02:00

47 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
formatCrossTeamPrefix,
parseCrossTeamPrefix,
stripCrossTeamPrefix,
} from '@shared/constants/crossTeam';
describe('crossTeam protocol helpers', () => {
it('parses canonical cross-team prefix metadata', () => {
const parsed = parseCrossTeamPrefix(
'<cross-team from="dream-team.team-lead" depth="0" conversationId="conv-1" replyToConversationId="conv-0" />\nHello'
);
expect(parsed).toEqual({
from: 'dream-team.team-lead',
chainDepth: 0,
conversationId: 'conv-1',
replyToConversationId: 'conv-0',
});
});
it('strips canonical prefix from UI text', () => {
expect(
stripCrossTeamPrefix('<cross-team from="a.b" depth="0" conversationId="conv-1" />\nHello')
).toBe('Hello');
});
it('parseCrossTeamAttributes regex: parses attr="value" pairs', () => {
const text = formatCrossTeamPrefix('team.user', 0, {
conversationId: 'c1',
replyToConversationId: 'c0',
});
const parsed = parseCrossTeamPrefix(text + '\nbody');
expect(parsed).not.toBeNull();
expect(parsed!.from).toBe('team.user');
expect(parsed!.conversationId).toBe('c1');
expect(parsed!.replyToConversationId).toBe('c0');
});
it('handles depth attribute', () => {
const parsed = parseCrossTeamPrefix(
'<cross-team from="a.b" depth="2" />\nHi'
);
expect(parsed?.chainDepth).toBe(2);
});
});