fix(history): tell users a memo tag is too long instead of offering a retry that always fails

Tags over 80 characters now show a length notice, and adding a tag that
already exists in another case just closes the input, rather than both
landing on a '#tag · retry' badge that repeats the same rejection.
This commit is contained in:
Yun Chan 2026-10-20 16:26:16 +09:00
parent 90c96c6f80
commit 1b39afe9ff
5 changed files with 48 additions and 11 deletions

View file

@ -1,7 +1,7 @@
import fs from 'fs'
import path from 'path'
import { describe, expect, it, vi } from 'vitest'
import type { IPCResult } from '@d3ro/core/errors'
import { ErrorCode, type IPCResult } from '@d3ro/core/errors'
import type { HistoryAudioSource, MemoTag } from '@d3ro/core/types'
import {
HistoryAudioPlayer,
@ -58,6 +58,19 @@ describe('HistoryEntryCard — 메모 태그 계약', () => {
expect(seen).toEqual([{ historyId: 'h1' }, { historyId: 'h1', tag: 'meeting' }, { historyId: 'h1', tag: 'work' }])
})
it('너무 긴 태그는 호출 없이 too-long, 중복 거절은 duplicate 로 알린다 — 재시도로 보이지 않는다', async () => {
const { port } = memoPort()
expect(await addEntryTag(port, 'h1', 'a'.repeat(81))).toEqual({ status: 'too-long', tag: 'a'.repeat(81) })
expect(port.addTag).not.toHaveBeenCalled()
const dupPort: MemoTagPort = {
...port,
addTag: async () =>
({ success: false, error: { code: ErrorCode.MemoTagDuplicate, message: 'dup' } }) as IPCResult<MemoTag>,
}
expect(await addEntryTag(dupPort, 'h1', 'Work')).toEqual({ status: 'duplicate', tag: 'Work' })
})
it('빈 입력은 호출하지 않고, 실패·예외는 failed/false/null로 알린다', async () => {
const { port } = memoPort()
expect(await addEntryTag(port, 'h1', ' ')).toEqual({ status: 'empty' })