Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

i18n-upload-features.test.ts 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. * Test suite for verifying upload feature translations across all locales
  3. * Specifically tests for issue #23062: Missing Upload feature translations (esp. audioUpload) across most locales
  4. */
  5. import fs from 'node:fs'
  6. import path from 'node:path'
  7. // Get all supported locales from the i18n directory
  8. const I18N_DIR = path.join(__dirname, '../i18n')
  9. const getSupportedLocales = (): string[] => {
  10. return fs.readdirSync(I18N_DIR)
  11. .filter(item => fs.statSync(path.join(I18N_DIR, item)).isDirectory())
  12. .sort()
  13. }
  14. // Helper function to load translation file content
  15. const loadTranslationContent = (locale: string): string => {
  16. const filePath = path.join(I18N_DIR, locale, 'app-debug.ts')
  17. if (!fs.existsSync(filePath))
  18. throw new Error(`Translation file not found: ${filePath}`)
  19. return fs.readFileSync(filePath, 'utf-8')
  20. }
  21. // Helper function to check if upload features exist
  22. const hasUploadFeatures = (content: string): { [key: string]: boolean } => {
  23. return {
  24. fileUpload: /fileUpload\s*:\s*{/.test(content),
  25. imageUpload: /imageUpload\s*:\s*{/.test(content),
  26. documentUpload: /documentUpload\s*:\s*{/.test(content),
  27. audioUpload: /audioUpload\s*:\s*{/.test(content),
  28. featureBar: /bar\s*:\s*{/.test(content),
  29. }
  30. }
  31. describe('Upload Features i18n Translations - Issue #23062', () => {
  32. let supportedLocales: string[]
  33. beforeAll(() => {
  34. supportedLocales = getSupportedLocales()
  35. console.log(`Testing ${supportedLocales.length} locales for upload features`)
  36. })
  37. test('all locales should have translation files', () => {
  38. supportedLocales.forEach((locale) => {
  39. const filePath = path.join(I18N_DIR, locale, 'app-debug.ts')
  40. expect(fs.existsSync(filePath)).toBe(true)
  41. })
  42. })
  43. test('all locales should have required upload features', () => {
  44. const results: { [locale: string]: { [feature: string]: boolean } } = {}
  45. supportedLocales.forEach((locale) => {
  46. const content = loadTranslationContent(locale)
  47. const features = hasUploadFeatures(content)
  48. results[locale] = features
  49. // Check that all upload features exist
  50. expect(features.fileUpload).toBe(true)
  51. expect(features.imageUpload).toBe(true)
  52. expect(features.documentUpload).toBe(true)
  53. expect(features.audioUpload).toBe(true)
  54. expect(features.featureBar).toBe(true)
  55. })
  56. console.log('✅ All locales have complete upload features')
  57. })
  58. test('previously missing locales should now have audioUpload - Issue #23062', () => {
  59. // These locales were specifically missing audioUpload
  60. const previouslyMissingLocales = ['fa-IR', 'hi-IN', 'ro-RO', 'sl-SI', 'th-TH', 'uk-UA', 'vi-VN']
  61. previouslyMissingLocales.forEach((locale) => {
  62. const content = loadTranslationContent(locale)
  63. // Verify audioUpload exists
  64. expect(/audioUpload\s*:\s*{/.test(content)).toBe(true)
  65. // Verify it has title and description
  66. expect(/audioUpload[^}]*title\s*:/.test(content)).toBe(true)
  67. expect(/audioUpload[^}]*description\s*:/.test(content)).toBe(true)
  68. console.log(`✅ ${locale} - Issue #23062 resolved: audioUpload feature present`)
  69. })
  70. })
  71. test('upload features should have required properties', () => {
  72. supportedLocales.forEach((locale) => {
  73. const content = loadTranslationContent(locale)
  74. // Check fileUpload has required properties
  75. if (/fileUpload\s*:\s*{/.test(content)) {
  76. expect(/fileUpload[^}]*title\s*:/.test(content)).toBe(true)
  77. expect(/fileUpload[^}]*description\s*:/.test(content)).toBe(true)
  78. }
  79. // Check imageUpload has required properties
  80. if (/imageUpload\s*:\s*{/.test(content)) {
  81. expect(/imageUpload[^}]*title\s*:/.test(content)).toBe(true)
  82. expect(/imageUpload[^}]*description\s*:/.test(content)).toBe(true)
  83. }
  84. // Check documentUpload has required properties
  85. if (/documentUpload\s*:\s*{/.test(content)) {
  86. expect(/documentUpload[^}]*title\s*:/.test(content)).toBe(true)
  87. expect(/documentUpload[^}]*description\s*:/.test(content)).toBe(true)
  88. }
  89. // Check audioUpload has required properties
  90. if (/audioUpload\s*:\s*{/.test(content)) {
  91. expect(/audioUpload[^}]*title\s*:/.test(content)).toBe(true)
  92. expect(/audioUpload[^}]*description\s*:/.test(content)).toBe(true)
  93. }
  94. })
  95. })
  96. })