@@ -11,27 +11,22 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
1111 * and the folder/file layers, not in the extractor's own arithmetic. The fake
1212 * therefore enforces the real rules:
1313 *
14- * - folder paths are validated with the production {@link parseFolderPath} family,
15- * so a non-canonical path (no leading slash, unencoded segment) throws exactly
16- * as `requireNonRootFolderPath` does in `workspace-file-folder-manager`;
17- * - `createWorkspaceFileFolderOperation` creates ONE leaf and rejects an existing
18- * path or a missing parent, mirroring `createWorkspaceFileFolderAtPath`;
14+ * - folder keys are built with the production {@link buildFolderPath}, so a segment
15+ * that needs encoding is rejected or encoded exactly as the folder layer would;
1916 * - `exactName: true` throws `FileConflictError` on a duplicate leaf name, while
2017 * `exactName: false` auto-suffixes, mirroring `uploadWorkspaceFile`.
2118 */
22- const { store, mockUpload, mockDelete, mockCreateFolder , mockEnsureFolder } = vi . hoisted ( ( ) => ( {
19+ const { store, mockUpload, mockDelete, mockEnsureFolder } = vi . hoisted ( ( ) => ( {
2320 store : {
2421 folderIdByPath : new Map < string , string > ( ) ,
2522 fileKeys : new Set < string > ( ) ,
2623 sequence : 0 ,
2724 } ,
2825 mockUpload : vi . fn ( ) ,
2926 mockDelete : vi . fn ( ) ,
30- mockCreateFolder : vi . fn ( ) ,
3127 mockEnsureFolder : vi . fn ( ) ,
3228} ) )
3329vi . mock ( '@/lib/workspace-files/application/workspace-file-folders' , ( ) => ( {
34- createWorkspaceFileFolderOperation : { execute : mockCreateFolder } ,
3530 ensureWorkspaceFileFolderPathOperation : { execute : mockEnsureFolder } ,
3631} ) )
3732vi . mock ( '@/lib/workspace-files/application/create-workspace-file' , ( ) => ( {
@@ -45,7 +40,7 @@ vi.mock('@/lib/workspace-files/application/delete-workspace-file', () => ({
4540 } ,
4641} ) )
4742
48- import { buildFolderPath , requireNonRootFolderPath } from '@/lib/folders/paths'
43+ import { buildFolderPath } from '@/lib/folders/paths'
4944import {
5045 decompressArchiveBufferToWorkspaceFiles ,
5146 MAX_ARCHIVE_CENTRAL_DIR_EXTRA_BYTES ,
@@ -125,20 +120,6 @@ beforeEach(() => {
125120 store . fileKeys . clear ( )
126121 store . sequence = 0
127122
128- mockCreateFolder . mockImplementation ( async ( { input } : { input : { path : string } } ) => {
129- const segments = requireNonRootFolderPath ( input . path )
130- if ( store . folderIdByPath . has ( input . path ) ) {
131- throw new Error ( `A folder named "${ segments [ segments . length - 1 ] } " already exists` )
132- }
133- const parentPath = buildFolderPath ( segments . slice ( 0 , - 1 ) )
134- if ( parentPath !== '/' && ! store . folderIdByPath . has ( parentPath ) ) {
135- throw new Error ( 'Parent folder not found' )
136- }
137- const id = `folder_${ ++ store . sequence } `
138- store . folderIdByPath . set ( input . path , id )
139- return { folder : { id, path : input . path } }
140- } )
141-
142123 mockEnsureFolder . mockImplementation ( async ( { input } : { input : { pathSegments : string [ ] } } ) => {
143124 let folderId : string | null = null
144125 const walked : string [ ] = [ ]
0 commit comments