feat(commands): multi-select ordered command pipeline with step reordering and single-pass composition (AI-05, AI-07)
This commit is contained in:
parent
f49acf0105
commit
10af20a0ad
157 changed files with 29455 additions and 913 deletions
|
|
@ -6,6 +6,7 @@ import {
|
|||
createMobileSearchExcerpt,
|
||||
createPostgrestLikePattern,
|
||||
createSupabaseUnifiedSearchSource,
|
||||
isUnifiedSearchAbortedError,
|
||||
sanitizeUnifiedSearchQuery,
|
||||
searchUnifiedContent,
|
||||
type MobileUnifiedSearchOptions,
|
||||
|
|
@ -212,4 +213,110 @@ describe('mobile unified search service', () => {
|
|||
expect(normalizeUnifiedSearchInitialQuery(123)).toBe('')
|
||||
expect(normalizeUnifiedSearchInitialQuery('가'.repeat(120))).toHaveLength(100)
|
||||
})
|
||||
|
||||
test('includes transcript segment matches with segment snippet and parent meeting ID', async () => {
|
||||
const segmentOnlyMeetingId = '44444444-4444-4444-8444-444444444444'
|
||||
const source: UnifiedSearchSourcePort = {
|
||||
searchRecords: jest.fn(async () => ({ rows: [], total: 0 })),
|
||||
searchMeetings: jest.fn(async () => ({ rows: [], total: 0 })),
|
||||
searchTranscriptSegments: jest.fn(async () => ({
|
||||
rows: [{
|
||||
id: '55555555-5555-4555-8555-555555555555',
|
||||
meeting_id: segmentOnlyMeetingId,
|
||||
text: '보안 감사 일정을 금요일로 확정했습니다.',
|
||||
speaker: '김팀장',
|
||||
timestamp_ms: 125_000,
|
||||
created_at: '2026-09-29T00:00:00.000Z',
|
||||
}],
|
||||
total: 1,
|
||||
})),
|
||||
loadMeetingsByIds: jest.fn(async () => [{
|
||||
id: segmentOnlyMeetingId,
|
||||
title: '보안 점검 회의',
|
||||
started_at: '2026-09-29T00:00:00.000Z',
|
||||
}]),
|
||||
}
|
||||
|
||||
const response = await searchUnifiedContent({
|
||||
userId: USER_ID,
|
||||
query: '보안 감사',
|
||||
limit: 10,
|
||||
}, source)
|
||||
|
||||
expect(source.searchTranscriptSegments).toHaveBeenCalledWith('보안 감사', 10)
|
||||
expect(source.loadMeetingsByIds).toHaveBeenCalledWith([segmentOnlyMeetingId])
|
||||
expect(response.total).toBe(1)
|
||||
expect(response.results).toEqual([
|
||||
expect.objectContaining({
|
||||
source: 'meeting',
|
||||
id: segmentOnlyMeetingId,
|
||||
title: '보안 점검 회의',
|
||||
matchedField: 'transcript',
|
||||
excerpt: '[02:05] [김팀장] 보안 감사 일정을 금요일로 확정했습니다.',
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
test('cancels in-flight search when AbortSignal is aborted', async () => {
|
||||
const controller = new AbortController()
|
||||
controller.abort()
|
||||
const source: UnifiedSearchSourcePort = {
|
||||
searchRecords: jest.fn(),
|
||||
searchMeetings: jest.fn(),
|
||||
}
|
||||
|
||||
let caughtError: unknown = null
|
||||
try {
|
||||
await searchUnifiedContent({
|
||||
userId: USER_ID,
|
||||
query: '로드맵',
|
||||
signal: controller.signal,
|
||||
}, source)
|
||||
} catch (error) {
|
||||
caughtError = error
|
||||
}
|
||||
expect(isUnifiedSearchAbortedError(caughtError)).toBe(true)
|
||||
expect(source.searchRecords).not.toHaveBeenCalled()
|
||||
expect(source.searchMeetings).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('bounds oversized text payloads in Supabase source adapter', async () => {
|
||||
const hugeText = `${'가'.repeat(500)} 핵심키워드 ${'나'.repeat(500)}`
|
||||
const transcriptBuilder = {
|
||||
select: jest.fn(),
|
||||
or: jest.fn(),
|
||||
order: jest.fn(),
|
||||
abortSignal: jest.fn(),
|
||||
limit: jest.fn(),
|
||||
}
|
||||
transcriptBuilder.select.mockReturnValue(transcriptBuilder)
|
||||
transcriptBuilder.or.mockReturnValue(transcriptBuilder)
|
||||
transcriptBuilder.order.mockReturnValue(transcriptBuilder)
|
||||
transcriptBuilder.abortSignal.mockReturnValue(transcriptBuilder)
|
||||
transcriptBuilder.limit.mockResolvedValue({
|
||||
data: [{
|
||||
id: 'seg-1',
|
||||
meeting_id: meeting.id,
|
||||
text: hugeText,
|
||||
speaker: '화자 1',
|
||||
timestamp_ms: 15_000,
|
||||
created_at: '2026-09-28T00:00:00.000Z',
|
||||
}],
|
||||
error: null,
|
||||
count: 1,
|
||||
})
|
||||
|
||||
const from = jest.fn(() => transcriptBuilder)
|
||||
const source = createSupabaseUnifiedSearchSource({ from } as unknown as D3roSupabaseClient)
|
||||
const controller = new AbortController()
|
||||
|
||||
const page = await source.searchTranscriptSegments!('핵심키워드', 10, controller.signal)
|
||||
expect(transcriptBuilder.select).toHaveBeenCalledWith(
|
||||
'id,meeting_id,text,speaker,timestamp_ms,created_at',
|
||||
{ count: 'exact' },
|
||||
)
|
||||
expect(transcriptBuilder.abortSignal).toHaveBeenCalledWith(controller.signal)
|
||||
expect(page.rows[0].text.length).toBeLessThanOrEqual(602)
|
||||
expect(page.rows[0].text).toContain('핵심키워드')
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue