Skip to content

Commit 4560ee5

Browse files
committed
chore: fix tests
1 parent b3711cf commit 4560ee5

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/decap-cms-core/src/__tests__/backend.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ describe('Backend', () => {
460460
partial: false,
461461
raw: '---\ntitle: "Hello World"\n---\n',
462462
data: { title: 'Hello World' },
463-
meta: { path: 'src/posts/index.md' },
463+
meta: { path: 'src/posts/index.md', path_type: 'slug' },
464464
i18n: {},
465465
label: null,
466466
isModification: true,

packages/decap-cms-core/src/lib/__tests__/i18n.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import * as i18n from '../i18n';
55
jest.mock('../../reducers/collections', () => {
66
return {
77
selectEntrySlug: () => 'index',
8+
// provide default implementation to avoid undefined in tests using i18n.getI18nDataFiles
9+
isNestedSubfolders: () => false,
810
};
911
});
1012

packages/decap-cms-core/src/lib/i18n.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ export function getI18nDataFiles(
379379
return diffFiles;
380380
}
381381
const paths = getFilePaths(collection, extension, path, slug);
382-
const subfolders = isNestedSubfolders(collection);
382+
// When using i18n multiple folders, locale is encoded as a subfolder (e.g., `en/index.md`),
383+
// so compare using the last two segments. Also respect nested subfolders collections.
384+
const subfolders =
385+
(getI18nInfo(collection) as I18nInfo).structure === I18N_STRUCTURE.MULTIPLE_FOLDERS ||
386+
isNestedSubfolders(collection);
383387
const dataFiles = paths.reduce((acc, path) => {
384388
const dataFile = diffFiles.find(file => compareFilePathEndings(file.path, path, subfolders));
385389
if (dataFile) {

0 commit comments

Comments
 (0)