test: 부하에 흔들리던 시간 검사를 계산량·조건 대기로 고정

다른 작업과 함께 돌면 혼자 0.8초인 정화가 9초로 재지는 등, 벽시계 한도와 고정 대기를 쓰던 테스트가 가끔 실패했다.

- 백엔드 성능 단언은 벽시계 대신 이 프로세스의 CPU 시간으로 잰다 (backend/test/cpu-time.ts 의 startCpuTimer).
  부하 중에도 1.4배쯤만 늘고, 예전 제곱 시간 경로(15~172초)는 그대로 한도를 넘는다
- 임시 업로드 삭제 테스트는 고정 20ms 대신 파일이 지워질 때까지 기다린다 (최대 2초, 지워지지 않으면 실패)
- 프론트 테스트 시간 한도를 20초로 (jsdom·편집기 테스트가 부하에서 5~13초), 긴 초안을 맞추는 테스트는 30초
  (src/test-utils/timeouts.ts)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 13:00:08 +09:00
parent 13888af2c2
commit 2701d04fc2
7 changed files with 112 additions and 31 deletions
@@ -8,6 +8,7 @@ import { docToText } from '@/components/mail/editor/mail-serialize'
import { MAIL_BODY_MAX_LENGTH, MAIL_QUOTE_OMITTED_MARK } from '@/shared/constants/mail'
import { MAIL_BODY_HTML_MAX_LENGTH } from '@/shared/constants/mail-editor'
import { editorOf, fileDragEvent, installProseMirrorDom, pasteEvent } from '@/test-utils/prosemirror-dom'
import { LONG_DRAFT_TIMEOUT_MS } from '@/test-utils/timeouts'
import { buildQuoteHtml, textToParagraphHtml } from '@/shared/utils/mail-quote'
type EditorWrapper = VueWrapper<InstanceType<typeof MailEditor>>
@@ -112,7 +113,7 @@ describe('MailEditor (서식 편집기)', () => {
expect(html?.length ?? 0).toBeLessThanOrEqual(INITIAL_DRAFT_LIMITS.html)
expect(text.endsWith(`> ${MAIL_QUOTE_OMITTED_MARK}`)).toBe(true)
expect(text).toContain('> 제목: 긴 메일')
})
}, LONG_DRAFT_TIMEOUT_MS)
describe('보내기 직전의 길이 (텍스트 100,000 · 서식 500,000 — 최종 직렬화 결과로 잰다)', () => {
it('맞춘 초안에 몇 글자 쓰면 그대로 보낸다 — 남겨 둔 자리 안이다', () => {
@@ -127,7 +128,7 @@ describe('MailEditor (서식 편집기)', () => {
expect(content?.text.length).toBeLessThanOrEqual(MAIL_BODY_MAX_LENGTH)
// 인용은 그대로 — 처음 맞춘 모양
expect(mailQuoteOf(editor.state.doc)).toBe(quoteBefore)
})
}, LONG_DRAFT_TIMEOUT_MS)
it('남겨 둔 자리보다 길게 쓰면 인용을 더 줄여 맞추고 편집기에도 그 모양을 보인다 — 내 글은 그대로', () => {
const view = mountEditor({ initialHtml: longQuoteDraft(), fitToLimits: true })
@@ -148,7 +149,7 @@ describe('MailEditor (서식 편집기)', () => {
// 실행 취소로 되돌릴 수 있다
editor.commands.undo()
expect(docToText(editor.state.doc).length).toBeGreaterThan(MAIL_BODY_MAX_LENGTH)
})
}, LONG_DRAFT_TIMEOUT_MS)
it('인용이 없는데(또는 인용을 다 줄여도) 내 글만으로 넘으면 null — 편집기는 그대로 둔다', () => {
const view = mountEditor()