test: 补充recipeNameEn翻译、重复精油、改名重翻译、去重跳过测试
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 6s
PR Preview / teardown-preview (pull_request) Successful in 14s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 6s
Test / e2e-test (push) Successful in 53s
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 6s
PR Preview / teardown-preview (pull_request) Successful in 14s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 6s
Test / e2e-test (push) Successful in 53s
单元测试256个全部通过(新增14个): - recipeNameEn: 11个翻译测试 - 重复精油检查: 3个 后端: 补充"缓解"翻译词条 E2E: 改名重翻译、删除用户去重跳过 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #27.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { recipeNameEn } from '../composables/useOilTranslation'
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// EDITOR_ONLY_TAGS includes '已下架'
|
||||
@@ -84,3 +85,88 @@ describe('已下架 tag filtering', () => {
|
||||
expect(filterDelisted(all)).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// recipeNameEn — front-end keyword translation
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('recipeNameEn', () => {
|
||||
it('translates 酸痛包 → Pain Relief Blend', () => {
|
||||
expect(recipeNameEn('酸痛包')).toBe('Pain Relief Blend')
|
||||
})
|
||||
|
||||
it('translates 助眠配方 → Sleep Aid Blend', () => {
|
||||
expect(recipeNameEn('助眠配方')).toBe('Sleep Aid Blend')
|
||||
})
|
||||
|
||||
it('translates 头痛 → Headache', () => {
|
||||
expect(recipeNameEn('头痛')).toBe('Headache')
|
||||
})
|
||||
|
||||
it('translates 肩颈按摩 → Neck & Shoulder Massage', () => {
|
||||
expect(recipeNameEn('肩颈按摩')).toBe('Neck & Shoulder Massage')
|
||||
})
|
||||
|
||||
it('translates 湿疹舒缓 → Eczema Soothing', () => {
|
||||
expect(recipeNameEn('湿疹舒缓')).toBe('Eczema Soothing')
|
||||
})
|
||||
|
||||
it('translates 淋巴排毒 → Lymph Detox', () => {
|
||||
expect(recipeNameEn('淋巴排毒')).toBe('Lymph Detox')
|
||||
})
|
||||
|
||||
it('translates 灰指甲 → Nail Fungus', () => {
|
||||
expect(recipeNameEn('灰指甲')).toBe('Nail Fungus')
|
||||
})
|
||||
|
||||
it('translates 缓解焦虑 → Relief Anxiety', () => {
|
||||
expect(recipeNameEn('缓解焦虑')).toBe('Relief Anxiety')
|
||||
})
|
||||
|
||||
it('returns original name for unknown text', () => {
|
||||
expect(recipeNameEn('XYZXYZ')).toBe('XYZXYZ')
|
||||
})
|
||||
|
||||
it('returns empty/null for empty/null input', () => {
|
||||
expect(recipeNameEn('')).toBe('')
|
||||
expect(recipeNameEn(null)).toBeNull()
|
||||
})
|
||||
|
||||
it('does not duplicate keywords', () => {
|
||||
// 酸痛 maps to Pain Relief; should not appear twice
|
||||
const result = recipeNameEn('酸痛酸痛')
|
||||
expect(result).toBe('Pain Relief')
|
||||
})
|
||||
})
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Duplicate oil prevention logic
|
||||
// ---------------------------------------------------------------------------
|
||||
describe('duplicate oil prevention', () => {
|
||||
it('detects duplicate oil in ingredient list', () => {
|
||||
const ings = [
|
||||
{ oil: '薰衣草', drops: 3 },
|
||||
{ oil: '茶树', drops: 2 },
|
||||
]
|
||||
const newOil = '薰衣草'
|
||||
const isDup = ings.some(i => i.oil === newOil)
|
||||
expect(isDup).toBe(true)
|
||||
})
|
||||
|
||||
it('allows non-duplicate oil', () => {
|
||||
const ings = [
|
||||
{ oil: '薰衣草', drops: 3 },
|
||||
{ oil: '茶树', drops: 2 },
|
||||
]
|
||||
const newOil = '乳香'
|
||||
const isDup = ings.some(i => i.oil === newOil)
|
||||
expect(isDup).toBe(false)
|
||||
})
|
||||
|
||||
it('allows same oil for the same row (editing current)', () => {
|
||||
const ing = { oil: '薰衣草', drops: 3 }
|
||||
const ings = [ing, { oil: '茶树', drops: 2 }]
|
||||
// When selecting for the same row, exclude self
|
||||
const isDup = ings.some(i => i !== ing && i.oil === '薰衣草')
|
||||
expect(isDup).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user