From 06f1a82d4c3e5ef1894d54dfb7b897a5876dee57 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Mon, 30 Mar 2026 08:37:12 +0800 Subject: [PATCH] fix(tests): add missing MODEL_TYPES mock in ModelModal tests Add mock for apiConfig.js MODEL_TYPES constant in test files to fix 'Cannot read properties of undefined' errors when running npm test. - tests/frontend/components/modelMetadata.renamePath.test.js - tests/frontend/components/modelModal.licenseIcons.test.js --- .../frontend/components/modelMetadata.renamePath.test.js | 8 ++++++++ tests/frontend/components/modelModal.licenseIcons.test.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/frontend/components/modelMetadata.renamePath.test.js b/tests/frontend/components/modelMetadata.renamePath.test.js index e5e2f764..ef3b6b41 100644 --- a/tests/frontend/components/modelMetadata.renamePath.test.js +++ b/tests/frontend/components/modelMetadata.renamePath.test.js @@ -89,6 +89,14 @@ vi.mock(I18N_HELPERS_MODULE, () => ({ translate: vi.fn((_, __, fallback) => fallback || ''), })); +vi.mock('../../../static/js/api/apiConfig.js', () => ({ + MODEL_TYPES: { + LORA: 'loras', + CHECKPOINT: 'checkpoints', + EMBEDDING: 'embeddings' + } +})); + vi.mock(API_FACTORY, () => ({ getModelApiClient: vi.fn(), })); diff --git a/tests/frontend/components/modelModal.licenseIcons.test.js b/tests/frontend/components/modelModal.licenseIcons.test.js index dfd1d837..7a9ad1d7 100644 --- a/tests/frontend/components/modelModal.licenseIcons.test.js +++ b/tests/frontend/components/modelModal.licenseIcons.test.js @@ -87,6 +87,14 @@ vi.mock(I18N_HELPERS_MODULE, () => ({ translate: vi.fn((_, __, fallback) => fallback || ''), })); +vi.mock('../../../static/js/api/apiConfig.js', () => ({ + MODEL_TYPES: { + LORA: 'loras', + CHECKPOINT: 'checkpoints', + EMBEDDING: 'embeddings' + } +})); + vi.mock(API_FACTORY, () => ({ getModelApiClient: vi.fn(), }));