@@ -600,4 +600,117 @@ describe("create_project_status_update", () => {
600600 // Cleanup
601601 delete process . env . GH_AW_PROJECT_URL ;
602602 } ) ;
603+
604+ it ( "should resolve a temporary project ID from temporaryIdMap" , async ( ) => {
605+ mockGithub . graphql
606+ . mockResolvedValueOnce ( {
607+ organization : {
608+ projectV2 : {
609+ id : "PVT_test123" ,
610+ number : 42 ,
611+ title : "Test Project" ,
612+ url : "https://github.com/orgs/test-org/projects/42" ,
613+ } ,
614+ } ,
615+ } )
616+ . mockResolvedValueOnce ( {
617+ createProjectV2StatusUpdate : {
618+ statusUpdate : {
619+ id : "PVTSU_test123" ,
620+ body : "Test status update" ,
621+ bodyHTML : "<p>Test status update</p>" ,
622+ startDate : "2025-01-01" ,
623+ targetDate : "2025-12-31" ,
624+ status : "ON_TRACK" ,
625+ createdAt : "2025-01-06T12:00:00Z" ,
626+ } ,
627+ } ,
628+ } ) ;
629+
630+ const handler = await main ( { max : 10 } ) ;
631+
632+ const temporaryIdMap = new Map ( ) ;
633+ temporaryIdMap . set ( "aw_abc12345" , { projectUrl : "https://github.com/orgs/test-org/projects/42" } ) ;
634+
635+ const result = await handler (
636+ {
637+ project : "aw_abc12345" ,
638+ body : "Test status update" ,
639+ status : "ON_TRACK" ,
640+ start_date : "2025-01-01" ,
641+ target_date : "2025-12-31" ,
642+ } ,
643+ Object . fromEntries ( temporaryIdMap ) ,
644+ temporaryIdMap
645+ ) ;
646+
647+ expect ( result . success ) . toBe ( true ) ;
648+ expect ( result . status_update_id ) . toBe ( "PVTSU_test123" ) ;
649+ expect ( mockCore . info ) . toHaveBeenCalledWith ( expect . stringContaining ( "Resolved temporary project ID aw_abc12345" ) ) ;
650+ } ) ;
651+
652+ it ( "should resolve a temporary project ID with hash prefix from temporaryIdMap" , async ( ) => {
653+ mockGithub . graphql
654+ . mockResolvedValueOnce ( {
655+ organization : {
656+ projectV2 : {
657+ id : "PVT_test123" ,
658+ number : 42 ,
659+ title : "Test Project" ,
660+ url : "https://github.com/orgs/test-org/projects/42" ,
661+ } ,
662+ } ,
663+ } )
664+ . mockResolvedValueOnce ( {
665+ createProjectV2StatusUpdate : {
666+ statusUpdate : {
667+ id : "PVTSU_test123" ,
668+ body : "Test status update" ,
669+ bodyHTML : "<p>Test status update</p>" ,
670+ startDate : "2025-01-01" ,
671+ targetDate : "2025-12-31" ,
672+ status : "ON_TRACK" ,
673+ createdAt : "2025-01-06T12:00:00Z" ,
674+ } ,
675+ } ,
676+ } ) ;
677+
678+ const handler = await main ( { max : 10 } ) ;
679+
680+ const temporaryIdMap = new Map ( ) ;
681+ temporaryIdMap . set ( "aw_abc12345" , { projectUrl : "https://github.com/orgs/test-org/projects/42" } ) ;
682+
683+ const result = await handler (
684+ {
685+ project : "#aw_abc12345" ,
686+ body : "Test status update" ,
687+ } ,
688+ Object . fromEntries ( temporaryIdMap ) ,
689+ temporaryIdMap
690+ ) ;
691+
692+ expect ( result . success ) . toBe ( true ) ;
693+ expect ( result . status_update_id ) . toBe ( "PVTSU_test123" ) ;
694+ expect ( mockCore . info ) . toHaveBeenCalledWith ( expect . stringContaining ( "Resolved temporary project ID #aw_abc12345" ) ) ;
695+ } ) ;
696+
697+ it ( "should return error when temporary project ID is not found in temporaryIdMap" , async ( ) => {
698+ const handler = await main ( { max : 10 } ) ;
699+
700+ const temporaryIdMap = new Map ( ) ;
701+
702+ const result = await handler (
703+ {
704+ project : "aw_notfound" ,
705+ body : "Test status update" ,
706+ } ,
707+ Object . fromEntries ( temporaryIdMap ) ,
708+ temporaryIdMap
709+ ) ;
710+
711+ expect ( result . success ) . toBe ( false ) ;
712+ expect ( result . error ) . toContain ( "aw_notfound" ) ;
713+ expect ( mockCore . error ) . toHaveBeenCalledWith ( expect . stringContaining ( "aw_notfound" ) ) ;
714+ expect ( mockGithub . graphql ) . not . toHaveBeenCalled ( ) ;
715+ } ) ;
603716} ) ;
0 commit comments