mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 14:14:10 +00:00
test: delete of folder does not delete unintended folders
This commit is contained in:
parent
008d82f8f7
commit
15e71b69b0
@ -220,6 +220,33 @@ describe('Bulk actions for folders & files', () => {
|
||||
const existingfoldersIds = resFolder.body.data.map((f) => f.id);
|
||||
expect(existingfoldersIds).toEqual(expect.not.arrayContaining([folder.id]));
|
||||
});
|
||||
|
||||
test('Can delete folders without deleting others with similar name', async () => {
|
||||
// Ensure the folder algo does not only delete by folders that start with the same path (startswith /1 matches /10 too)
|
||||
|
||||
// Delete all previous folders, so first file path is /1
|
||||
await rq
|
||||
.get('/upload/folders')
|
||||
.then((res) => res.body.data.map((f) => f.id))
|
||||
.then((folderIds) => rq.post('/upload/actions/bulk-delete', { body: { folderIds } }));
|
||||
|
||||
// Create folders
|
||||
const folder1 = await createFolder('folderToDelete', null);
|
||||
data.folders = await Promise.all(
|
||||
Array.from({ length: 20 }).map((_, i) => createFolder(`${i}`, null))
|
||||
);
|
||||
|
||||
// Delete folder1
|
||||
await rq.post('/upload/actions/bulk-delete', { body: { folderIds: [folder1.id] } });
|
||||
|
||||
const afterFolderIds = await rq
|
||||
.get('/upload/folders')
|
||||
.then((res) => res.body.data.map((f) => f.id));
|
||||
|
||||
// Should include all folders except the one we deleted
|
||||
expect(afterFolderIds.length).toBe(20);
|
||||
expect(afterFolderIds).toEqual(expect.not.arrayContaining([folder1.id]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('move', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user