1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop: Fix infinite loop on startup after quickly moving folders (#12140)

This commit is contained in:
Henry Heino
2025-04-24 00:52:35 -07:00
committed by GitHub
parent e953290810
commit ddc75ecc13
2 changed files with 50 additions and 3 deletions

View File

@@ -163,6 +163,23 @@ describe('models/Folder', () => {
}
}));
it('folder hierarchy cycles should not cause addNoteCounts to loop infinitely', async () => {
const f1 = await Folder.save({ title: 'folder1' });
const f2 = await Folder.save({ title: 'folder2', parent_id: f1.id });
const f3 = await Folder.save({ title: 'folder3', parent_id: f2.id });
await Note.save({ title: 'test', parent_id: f1.id });
// Create a cycle.
// Note: This has been observed to happen, likely as a result of a bug in other code.
await Folder.save({ id: f1.id, parent_id: f3.id });
const folders = await Folder.all();
// Should not loop indefinitely:
await Folder.addNoteCounts(folders);
// Note count may be incorrect
expect(folders.find(folder => folder.id === f1.id)).toHaveProperty('note_count');
});
it('should not count completed to-dos', (async () => {
const f1 = await Folder.save({ title: 'folder1' });