dify/web/__tests__/app-star-i18n.test.ts
Jingyi 9b74df21d0
feat(web): refine onboarding UI (#37433)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: fatelei <fatelei@gmail.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
Co-authored-by: gigglewang <gigglewang@dify.ai>
Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai>
Co-authored-by: chariri <w@chariri.moe>
Co-authored-by: Evan <2869018789@qq.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
2026-06-15 08:47:15 +00:00

48 lines
1.3 KiB
TypeScript

import fs from 'node:fs'
import path from 'node:path'
const I18N_DIR = path.join(__dirname, '../i18n')
const REQUIRED_APP_STAR_KEYS = [
'studio.allApps',
'studio.starApp',
'studio.starFailed',
'studio.starred',
'studio.unstarApp',
] as const
type AppTranslations = Record<string, unknown>
const getSupportedLocales = () => fs.readdirSync(I18N_DIR)
.filter(item => fs.statSync(path.join(I18N_DIR, item)).isDirectory())
.sort()
const loadAppTranslations = (locale: string): AppTranslations => {
const filePath = path.join(I18N_DIR, locale, 'app.json')
if (!fs.existsSync(filePath))
throw new Error(`Translation file not found: ${filePath}`)
return JSON.parse(fs.readFileSync(filePath, 'utf-8')) as AppTranslations
}
describe('App star i18n translations', () => {
it('should define star-related app list labels for every locale', () => {
const supportedLocales = getSupportedLocales()
const missingKeys = supportedLocales.flatMap((locale) => {
const translations = loadAppTranslations(locale)
return REQUIRED_APP_STAR_KEYS
.filter((key) => {
const value = translations[key]
return typeof value !== 'string' || value.trim() === ''
})
.map(key => `${locale}:${key}`)
})
expect(supportedLocales.length).toBeGreaterThan(0)
expect(missingKeys).toEqual([])
})
})