diff --git a/core-web/libs/edit-content-bridge/src/lib/bridges/angular-form-bridge.spec.ts b/core-web/libs/edit-content-bridge/src/lib/bridges/angular-form-bridge.spec.ts index 279276694eca..46586ca0bdf1 100644 --- a/core-web/libs/edit-content-bridge/src/lib/bridges/angular-form-bridge.spec.ts +++ b/core-web/libs/edit-content-bridge/src/lib/bridges/angular-form-bridge.spec.ts @@ -8,6 +8,8 @@ import { DotAssetPickerComponent } from '@dotcms/ui'; import { AngularFormBridge } from './angular-form-bridge'; +import { DotBrowserOptions } from '../interfaces/asset-browser.interface'; + /** The site the picker browses; the bridge is handed a way to resolve it. */ const SITE: DotSite = { identifier: 'site-1', @@ -942,7 +944,6 @@ describe('AngularFormBridge', () => { bridge.openBrowserModal(); expect(openedConfig().allowedBaseTypes).toEqual(['DOTASSET', 'FILEASSET']); - expect(openedConfig().browse?.showFolders).toBeFalsy(); expect(openedConfig().browse?.showLinks).toBeFalsy(); }); }); @@ -954,12 +955,66 @@ describe('AngularFormBridge', () => { expect(openedConfig().allowedBaseTypes).toEqual(['FILEASSET', 'HTMLPAGE']); }); - it('should map folder and link kinds to browse options', () => { - bridge.openBrowserModal({ kinds: ['page', 'folder', 'link'] }); + it('should map the link kind to a browse option', () => { + bridge.openBrowserModal({ kinds: ['page', 'link'] }); - expect(openedConfig().browse).toEqual( - expect.objectContaining({ showFolders: true, showLinks: true }) - ); + expect(openedConfig().browse).toEqual(expect.objectContaining({ showLinks: true })); + }); + + it('should not carry a folder browse option for a caller that asks for folders', () => { + // #37366: `'folder'` left the contract, but a VTL template is a string literal — + // TypeScript polices nothing here, so the runtime has to. The kind is dropped, and + // the picker is never handed an option that would list folders. + bridge.openBrowserModal({ + kinds: ['page', 'folder', 'link'] + } as unknown as DotBrowserOptions); + + expect(openedConfig().browse).not.toHaveProperty('showFolders'); + expect(openedConfig().browse).toEqual(expect.objectContaining({ showLinks: true })); + }); + + it('should warn about an unsupported kind rather than ignore it silently', () => { + // AC-008: a template author must not be able to ask for a kind the picker refuses + // and get no signal. Same treatment the `link` + `mimeTypes` conflict already gets. + const warn = jest.spyOn(console, 'warn').mockImplementation(); + + bridge.openBrowserModal({ + kinds: ['file', 'page', 'folder'] + } as unknown as DotBrowserOptions); + + expect(warn).toHaveBeenCalledTimes(1); + expect(warn.mock.calls[0][0]).toContain('folder'); + expect(openedConfig().allowedBaseTypes).toEqual(['FILEASSET', 'HTMLPAGE']); + + warn.mockRestore(); + }); + + it('should fall back to asset-only browsing when folder is the only kind asked for', () => { + // Degenerate case: no requested kind maps to a base type, so `baseTypesFor` returns + // undefined and the picker uses its own default. Must not throw — an exception + // inside a VTL