@@ -4,6 +4,8 @@ import { CaptureChoiceEngine } from "./CaptureChoiceEngine";
44import type ICaptureChoice from "../types/choices/ICaptureChoice" ;
55import type { IChoiceExecutor } from "../IChoiceExecutor" ;
66import { isFolder , openFile } from "../utilityObsidian" ;
7+ import { QA_INTERNAL_CAPTURE_TARGET_FILE_PATH } from "../constants" ;
8+ import { ChoiceAbortError } from "../errors/ChoiceAbortError" ;
79
810const { setUseSelectionAsCaptureValueMock, setTitleMock } = vi . hoisted ( ( ) => ( {
911 setUseSelectionAsCaptureValueMock : vi . fn ( ) ,
@@ -270,7 +272,7 @@ describe("CaptureChoiceEngine capture target resolution", () => {
270272 expect ( result ) . toEqual ( { kind : "file" , path : "journals" } ) ;
271273 } ) ;
272274
273- it ( "preserves explicit .base capture target paths" , async ( ) => {
275+ it ( "rejects explicit .base capture target paths" , ( ) => {
274276 const app = createApp ( ) ;
275277 const engine = new CaptureChoiceEngine (
276278 app ,
@@ -279,9 +281,28 @@ describe("CaptureChoiceEngine capture target resolution", () => {
279281 createExecutor ( ) ,
280282 ) ;
281283
282- const result = await ( engine as any ) . getFormattedPathToCaptureTo ( false ) ;
284+ expect ( ( ) =>
285+ ( engine as any ) . resolveCaptureTarget ( "Boards/Kanban.base" ) ,
286+ ) . toThrow ( ChoiceAbortError ) ;
287+ } ) ;
283288
284- expect ( result ) . toBe ( "Boards/Kanban.base" ) ;
289+ it ( "rejects preselected .base capture target paths" , async ( ) => {
290+ const app = createApp ( ) ;
291+ const executor = createExecutor ( ) ;
292+ executor . variables . set (
293+ QA_INTERNAL_CAPTURE_TARGET_FILE_PATH ,
294+ "Boards/Kanban.base" ,
295+ ) ;
296+ const engine = new CaptureChoiceEngine (
297+ app ,
298+ { settings : { useSelectionAsCaptureValue : false } } as any ,
299+ createChoice ( ) ,
300+ executor ,
301+ ) ;
302+
303+ await expect (
304+ ( engine as any ) . getFormattedPathToCaptureTo ( false ) ,
305+ ) . rejects . toBeInstanceOf ( ChoiceAbortError ) ;
285306 } ) ;
286307
287308 it ( "preserves explicit .canvas capture target paths" , async ( ) => {
@@ -298,7 +319,7 @@ describe("CaptureChoiceEngine capture target resolution", () => {
298319 expect ( result ) . toBe ( "Boards/Map.canvas" ) ;
299320 } ) ;
300321
301- it ( "uses extensionless title for created .base/. canvas capture files" , async ( ) => {
322+ it ( "uses extensionless title for created .canvas capture files" , async ( ) => {
302323 const app = createApp ( ) as any ;
303324 app . vault . read = vi . fn ( async ( ) => "" ) ;
304325
@@ -321,16 +342,11 @@ describe("CaptureChoiceEngine capture target resolution", () => {
321342 extension : path . endsWith ( ".base" ) ? "base" : "canvas" ,
322343 } ) ) ;
323344
324- await ( engine as any ) . onCreateFileIfItDoesntExist (
325- "Boards/Kanban.base" ,
326- "capture" ,
327- ) ;
328345 await ( engine as any ) . onCreateFileIfItDoesntExist (
329346 "Boards/Map.canvas" ,
330347 "capture" ,
331348 ) ;
332349
333- expect ( setTitleMock ) . toHaveBeenCalledWith ( "Kanban" ) ;
334350 expect ( setTitleMock ) . toHaveBeenCalledWith ( "Map" ) ;
335351 } ) ;
336352} ) ;
0 commit comments