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
|
|
@ -1,4 +1,6 @@
|
|||
import { Feature } from '@d3ro/core/types'
|
||||
import { normalizeEntitlement } from '../src/lib/entitlement-context'
|
||||
import { resolveWebEntitlement } from '../../web/src/lib/entitlement'
|
||||
|
||||
describe('normalizeEntitlement', () => {
|
||||
const now = new Date('2026-08-21T00:00:00Z')
|
||||
|
|
@ -16,6 +18,7 @@ describe('normalizeEntitlement', () => {
|
|||
expect(snapshot.adFree).toBe(false)
|
||||
expect(snapshot.overageCredits).toBe(50)
|
||||
expect(snapshot.usageToday.stt_transcribe).toBe(3)
|
||||
expect(snapshot.features).not.toContain(Feature.TEAM_WORKSPACE)
|
||||
})
|
||||
|
||||
it('서버가 확인한 유효 paid period만 광고 제거 권한을 준다', () => {
|
||||
|
|
@ -34,7 +37,10 @@ describe('normalizeEntitlement', () => {
|
|||
current_period_end: '2026-08-20T00:00:00Z',
|
||||
}, [], [], now)
|
||||
|
||||
expect(active.tier).toBe('pro')
|
||||
expect(active.adFree).toBe(true)
|
||||
expect(active.features).toContain(Feature.TEAM_WORKSPACE)
|
||||
expect(expired.tier).toBe('free')
|
||||
expect(expired.adFree).toBe(false)
|
||||
})
|
||||
|
||||
|
|
@ -61,11 +67,41 @@ describe('normalizeEntitlement', () => {
|
|||
product_id: 'unknown',
|
||||
purchase_state: 'purchased',
|
||||
verified_at: 'invalid',
|
||||
}], now)
|
||||
}], now, 'manager')
|
||||
|
||||
expect(snapshot.tier).toBe('pro_plus')
|
||||
expect(snapshot.adFree).toBe(true)
|
||||
expect(snapshot.adminRole).toBe('manager')
|
||||
expect(snapshot.autoRenewing).toBe(false)
|
||||
expect(snapshot.purchases).toHaveLength(1)
|
||||
expect(snapshot.purchases[0].productId).toBe('d3ro_voice_pro_plus_monthly')
|
||||
})
|
||||
|
||||
it('웹 구독과 역할도 @d3ro/core resolveEntitlement 기준으로 정규화한다', () => {
|
||||
const activeWeb = resolveWebEntitlement({
|
||||
tier: 'pro_plus',
|
||||
status: 'active',
|
||||
provider: 'none',
|
||||
payment_provider: 'payple',
|
||||
current_period_end: '2026-09-21T00:00:00Z',
|
||||
overage_credits: 120,
|
||||
}, { supabaseRole: 'admin', now })
|
||||
|
||||
expect(activeWeb.tier).toBe('pro_plus')
|
||||
expect(activeWeb.provider).toBe('payple')
|
||||
expect(activeWeb.adFree).toBe(true)
|
||||
expect(activeWeb.adminRole).toBe('admin')
|
||||
expect(activeWeb.adminCapabilities.canAdmin).toBe(true)
|
||||
|
||||
const expiredWeb = resolveWebEntitlement({
|
||||
tier: 'pro',
|
||||
status: 'active',
|
||||
provider: 'payple',
|
||||
current_period_end: '2026-08-01T00:00:00Z',
|
||||
}, { now })
|
||||
|
||||
expect(expiredWeb.tier).toBe('free')
|
||||
expect(expiredWeb.rawTier).toBe('pro')
|
||||
expect(expiredWeb.adFree).toBe(false)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import {
|
|||
computeMemoTimestamp,
|
||||
createMeetingCreationIdempotencyKey,
|
||||
createMeetingWorkspaceWithMetadata,
|
||||
findActiveTranscriptSegmentId,
|
||||
getMeetingRecordingLanguage,
|
||||
MeetingServiceError,
|
||||
normalizeDocumentDraft,
|
||||
|
|
@ -48,11 +49,17 @@ import {
|
|||
normalizeMeetingLanguage,
|
||||
normalizeMeetingTitle,
|
||||
normalizeMemoContent,
|
||||
parseTimestampTokenToMs,
|
||||
parseTranscriptSeekSegments,
|
||||
sanitizeMeetingSearch,
|
||||
subscribeToMeetingDetail,
|
||||
updateMeetingMemoConflictSafe,
|
||||
updateMeetingTitleRevisionSafe,
|
||||
} from '../src/features/meetings/meetings-service'
|
||||
import {
|
||||
findActiveWebTranscriptSegmentId,
|
||||
parseFallbackTranscriptRows,
|
||||
} from '../../web/src/components/meetings/live-transcript-list'
|
||||
|
||||
const USER_ID = '11111111-1111-4111-8111-111111111111'
|
||||
const MEETING_ID = '22222222-2222-4222-8222-222222222222'
|
||||
|
|
@ -307,6 +314,53 @@ describe('meeting transcript selection', () => {
|
|||
expect(buildMeetingTranscriptView(meeting(), []))
|
||||
.toEqual({ source: 'empty', text: '' })
|
||||
})
|
||||
|
||||
test('parses [MM:SS] timestamps and resolves active segment for audio seek sync', () => {
|
||||
expect(parseTimestampTokenToMs('[01:25]')).toBe(85_000)
|
||||
expect(parseTimestampTokenToMs('02:05')).toBe(125_000)
|
||||
expect(parseTimestampTokenToMs('[01:02:03]')).toBe(3_723_000)
|
||||
expect(parseTimestampTokenToMs('invalid')).toBeNull()
|
||||
|
||||
const fromRows = parseTranscriptSeekSegments(meeting(), [
|
||||
transcript('seg-2', 2, '두 번째 발언', '화자 2'),
|
||||
transcript('seg-1', 1, '첫 번째 발언', '화자 1'),
|
||||
])
|
||||
expect(fromRows.map((item) => ({ id: item.id, timestampMs: item.timestampMs }))).toEqual([
|
||||
{ id: 'seg-1', timestampMs: 1_000 },
|
||||
{ id: 'seg-2', timestampMs: 2_000 },
|
||||
])
|
||||
expect(findActiveTranscriptSegmentId(fromRows, 500)).toBeNull()
|
||||
expect(findActiveTranscriptSegmentId(fromRows, 1_500)).toBe('seg-1')
|
||||
expect(findActiveTranscriptSegmentId(fromRows, 2_500)).toBe('seg-2')
|
||||
|
||||
const fromFallback = parseTranscriptSeekSegments(
|
||||
meeting({ raw_transcript: '[00:05] [화자 A] 안건 소개\n[00:20] 일정 논의' }),
|
||||
[],
|
||||
)
|
||||
expect(fromFallback).toEqual([
|
||||
expect.objectContaining({
|
||||
id: 'line-0',
|
||||
timestampMs: 5_000,
|
||||
speaker: '화자 A',
|
||||
text: '안건 소개',
|
||||
timed: true,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: 'line-1',
|
||||
timestampMs: 20_000,
|
||||
speaker: null,
|
||||
text: '일정 논의',
|
||||
timed: true,
|
||||
}),
|
||||
])
|
||||
expect(findActiveTranscriptSegmentId(fromFallback, 12_000)).toBe('line-0')
|
||||
expect(findActiveTranscriptSegmentId(fromFallback, 25_000)).toBe('line-1')
|
||||
|
||||
const webRows = parseFallbackTranscriptRows('[00:10] [윤찬] 첫 구간\n[00:40] 둘째 구간')
|
||||
expect(webRows).toHaveLength(2)
|
||||
expect(findActiveWebTranscriptSegmentId(webRows, 15_000)).toBe('fallback-line-0')
|
||||
expect(findActiveWebTranscriptSegmentId(webRows, 45_000)).toBe('fallback-line-1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('meeting mutation safety', () => {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,13 @@ import {
|
|||
import {
|
||||
detachPushRegistrationForLogout,
|
||||
registerPushRegistration,
|
||||
resolveDevicePushProvider,
|
||||
synchronizePushRegistration,
|
||||
} from '../src/features/notifications/notification-service'
|
||||
import {
|
||||
subscribeWebPush,
|
||||
urlBase64ToUint8Array,
|
||||
} from '../../web/src/lib/web-push'
|
||||
|
||||
const USER_ID = '11111111-1111-4111-8111-111111111111'
|
||||
const DEVICE_ID = '22222222-2222-4222-8222-222222222222'
|
||||
|
|
@ -270,4 +275,56 @@ describe('device-bound push registration', () => {
|
|||
expect(mockedSupabase.rpc).not.toHaveBeenCalled()
|
||||
expect(mockedNative.deleteNativePushRegistration).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
test('registers iOS devices with provider apns while Android uses fcm', async () => {
|
||||
const iosDevice: RegisteredDevice = {
|
||||
...device,
|
||||
platform: 'ios',
|
||||
deviceName: 'iPhone 16 Pro',
|
||||
osVersion: 'iOS 18.1',
|
||||
}
|
||||
const apnsToken = `apns_${'b'.repeat(64)}`
|
||||
expect(resolveDevicePushProvider(device)).toBe('fcm')
|
||||
expect(resolveDevicePushProvider(iosDevice)).toBe('apns')
|
||||
|
||||
mockedNative.getNativeNotificationStatus.mockResolvedValue({
|
||||
configured: true,
|
||||
provider: 'apns',
|
||||
reason: 'configured',
|
||||
permission: 'granted',
|
||||
registrationId: apnsToken,
|
||||
fullSyncRequired: false,
|
||||
})
|
||||
mockedSupabase.rpc.mockResolvedValue({
|
||||
data: {
|
||||
device_id: DEVICE_ID,
|
||||
provider: 'apns',
|
||||
registered_at: '2026-08-21T00:05:00.000Z',
|
||||
},
|
||||
error: null,
|
||||
})
|
||||
|
||||
await expect(synchronizePushRegistration(USER_ID, iosDevice)).resolves.toMatchObject({
|
||||
status: 'registered',
|
||||
registeredAt: '2026-08-21T00:05:00.000Z',
|
||||
})
|
||||
expect(mockedSupabase.rpc).toHaveBeenCalledWith('register_push_registration', {
|
||||
push_device_id: DEVICE_ID,
|
||||
push_provider: 'apns',
|
||||
registration_id: apnsToken,
|
||||
})
|
||||
})
|
||||
|
||||
test('converts VAPID public key and fails closed when VAPID key is absent in web push', async () => {
|
||||
const bytes = urlBase64ToUint8Array('SGVsbG8td29ybGQ')
|
||||
expect(bytes).toBeInstanceOf(Uint8Array)
|
||||
expect(bytes.length).toBeGreaterThan(0)
|
||||
|
||||
await expect(
|
||||
subscribeWebPush({
|
||||
userId: USER_ID,
|
||||
vapidPublicKey: '',
|
||||
}),
|
||||
).rejects.toMatchObject({ code: 'vapid-key-missing' })
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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