From d9a3e421ebb005a94bff39ec1eb7b5a37f4cc229 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 25 Dec 2025 10:35:59 +0800 Subject: [PATCH] update --- web/__tests__/i18n-upload-features.test.ts | 54 +++++++++------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/web/__tests__/i18n-upload-features.test.ts b/web/__tests__/i18n-upload-features.test.ts index 7d676a55cb..b861728f6d 100644 --- a/web/__tests__/i18n-upload-features.test.ts +++ b/web/__tests__/i18n-upload-features.test.ts @@ -15,24 +15,23 @@ const getSupportedLocales = (): string[] => { } // Helper function to load translation file content -const loadTranslationContent = (locale: string): Record => { +const loadTranslationContent = (locale: string): string => { const filePath = path.join(I18N_DIR, locale, 'app-debug.json') if (!fs.existsSync(filePath)) throw new Error(`Translation file not found: ${filePath}`) - return JSON.parse(fs.readFileSync(filePath, 'utf-8')) + return fs.readFileSync(filePath, 'utf-8') } // Helper function to check if upload features exist -const hasUploadFeatures = (content: Record): { [key: string]: boolean } => { - const feature = content.feature as Record | undefined +const hasUploadFeatures = (content: string): { [key: string]: boolean } => { return { - fileUpload: !!(feature?.fileUpload && typeof feature.fileUpload === 'object'), - imageUpload: !!(feature?.imageUpload && typeof feature.imageUpload === 'object'), - documentUpload: !!(feature?.documentUpload && typeof feature.documentUpload === 'object'), - audioUpload: !!(feature?.audioUpload && typeof feature.audioUpload === 'object'), - featureBar: !!(feature?.bar && typeof feature.bar === 'object'), + fileUpload: /"fileUpload"\s*:\s*\{/.test(content), + imageUpload: /"imageUpload"\s*:\s*\{/.test(content), + documentUpload: /"documentUpload"\s*:\s*\{/.test(content), + audioUpload: /"audioUpload"\s*:\s*\{/.test(content), + featureBar: /"bar"\s*:\s*\{/.test(content), } } @@ -76,15 +75,13 @@ describe('Upload Features i18n Translations - Issue #23062', () => { previouslyMissingLocales.forEach((locale) => { const content = loadTranslationContent(locale) - const feature = content.feature as Record | undefined - const audioUpload = feature?.audioUpload as Record | undefined // Verify audioUpload exists - expect(audioUpload && typeof audioUpload === 'object').toBe(true) + expect(/"audioUpload"\s*:\s*\{/.test(content)).toBe(true) // Verify it has title and description - expect(audioUpload?.title).toBeDefined() - expect(audioUpload?.description).toBeDefined() + expect(/"audioUpload"[^}]*"title"\s*:/.test(content)).toBe(true) + expect(/"audioUpload"[^}]*"description"\s*:/.test(content)).toBe(true) console.log(`✅ ${locale} - Issue #23062 resolved: audioUpload feature present`) }) @@ -93,34 +90,29 @@ describe('Upload Features i18n Translations - Issue #23062', () => { it('upload features should have required properties', () => { supportedLocales.forEach((locale) => { const content = loadTranslationContent(locale) - const feature = content.feature as Record | undefined // Check fileUpload has required properties - const fileUpload = feature?.fileUpload as Record | undefined - if (fileUpload && typeof fileUpload === 'object') { - expect(fileUpload.title).toBeDefined() - expect(fileUpload.description).toBeDefined() + if (/"fileUpload"\s*:\s*\{/.test(content)) { + expect(/"fileUpload"[^}]*"title"\s*:/.test(content)).toBe(true) + expect(/"fileUpload"[^}]*"description"\s*:/.test(content)).toBe(true) } // Check imageUpload has required properties - const imageUpload = feature?.imageUpload as Record | undefined - if (imageUpload && typeof imageUpload === 'object') { - expect(imageUpload.title).toBeDefined() - expect(imageUpload.description).toBeDefined() + if (/"imageUpload"\s*:\s*\{/.test(content)) { + expect(/"imageUpload"[^}]*"title"\s*:/.test(content)).toBe(true) + expect(/"imageUpload"[^}]*"description"\s*:/.test(content)).toBe(true) } // Check documentUpload has required properties - const documentUpload = feature?.documentUpload as Record | undefined - if (documentUpload && typeof documentUpload === 'object') { - expect(documentUpload.title).toBeDefined() - expect(documentUpload.description).toBeDefined() + if (/"documentUpload"\s*:\s*\{/.test(content)) { + expect(/"documentUpload"[^}]*"title"\s*:/.test(content)).toBe(true) + expect(/"documentUpload"[^}]*"description"\s*:/.test(content)).toBe(true) } // Check audioUpload has required properties - const audioUpload = feature?.audioUpload as Record | undefined - if (audioUpload && typeof audioUpload === 'object') { - expect(audioUpload.title).toBeDefined() - expect(audioUpload.description).toBeDefined() + if (/"audioUpload"\s*:\s*\{/.test(content)) { + expect(/"audioUpload"[^}]*"title"\s*:/.test(content)).toBe(true) + expect(/"audioUpload"[^}]*"description"\s*:/.test(content)).toBe(true) } }) })