You've already forked joplin
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:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user