@@ -804,15 +804,22 @@ describe("ProjectRepository.setTaskPriority", () => {
804804 } ) ;
805805
806806 it ( "throws when content id not found for issue (issue/PR not in repo)" , async ( ) => {
807+ const { logError } = require ( "../../../utils/logger" ) ;
808+ ( logError as jest . Mock ) . mockClear ( ) ;
807809 mockGraphql . mockResolvedValueOnce ( {
808810 repository : { issueOrPullRequest : null } ,
809811 } ) ;
810812 await expect (
811813 repo . setTaskPriority ( project , "owner" , "repo" , 999 , "High" , "token" )
812814 ) . rejects . toThrow ( "Content ID not found" ) ;
815+ expect ( logError ) . toHaveBeenCalledWith (
816+ expect . stringContaining ( "999 not found in repository" )
817+ ) ;
813818 } ) ;
814819
815820 it ( "throws when project node is null (invalid project ID)" , async ( ) => {
821+ const { logError } = require ( "../../../utils/logger" ) ;
822+ ( logError as jest . Mock ) . mockClear ( ) ;
816823 mockGraphql
817824 . mockResolvedValueOnce ( {
818825 repository : { issueOrPullRequest : { id : "I_issue1" } } ,
@@ -821,9 +828,14 @@ describe("ProjectRepository.setTaskPriority", () => {
821828 await expect (
822829 repo . setTaskPriority ( project , "owner" , "repo" , 1 , "High" , "token" )
823830 ) . rejects . toThrow ( "Project not found or invalid project ID" ) ;
831+ expect ( logError ) . toHaveBeenCalledWith (
832+ expect . stringContaining ( "Project not found for ID" )
833+ ) ;
824834 } ) ;
825835
826836 it ( "throws when issue/PR not in project yet" , async ( ) => {
837+ const { logError } = require ( "../../../utils/logger" ) ;
838+ ( logError as jest . Mock ) . mockClear ( ) ;
827839 mockGraphql
828840 . mockResolvedValueOnce ( {
829841 repository : { issueOrPullRequest : { id : "I_issue1" } } ,
@@ -839,5 +851,59 @@ describe("ProjectRepository.setTaskPriority", () => {
839851 await expect (
840852 repo . setTaskPriority ( project , "owner" , "repo" , 1 , "High" , "token" )
841853 ) . rejects . toThrow ( "not in the project yet" ) ;
854+ expect ( logError ) . toHaveBeenCalledWith (
855+ expect . stringContaining ( "not found in project after checking" )
856+ ) ;
857+ } ) ;
858+
859+ it ( "logs error when hasNextPage is true but endCursor is null" , async ( ) => {
860+ const { logError } = require ( "../../../utils/logger" ) ;
861+ ( logError as jest . Mock ) . mockClear ( ) ;
862+ mockGraphql
863+ . mockResolvedValueOnce ( {
864+ repository : { issueOrPullRequest : { id : "I_issue1" } } ,
865+ } )
866+ . mockResolvedValueOnce ( {
867+ node : {
868+ items : {
869+ nodes : [ { id : "other" , content : { id : "I_other" } } ] ,
870+ pageInfo : { hasNextPage : true , endCursor : null } ,
871+ } ,
872+ } ,
873+ } ) ;
874+ await expect (
875+ repo . setTaskPriority ( project , "owner" , "repo" , 1 , "High" , "token" )
876+ ) . rejects . toThrow ( "not in the project yet" ) ;
877+ expect ( logError ) . toHaveBeenCalledWith (
878+ expect . stringContaining ( "hasNextPage is true but endCursor is null" )
879+ ) ;
880+ } ) ;
881+
882+ it ( "stops after maxPages and throws when item not found" , async ( ) => {
883+ const { logError } = require ( "../../../utils/logger" ) ;
884+ ( logError as jest . Mock ) . mockClear ( ) ;
885+ const pageWithNext = {
886+ node : {
887+ items : {
888+ nodes : Array . from ( { length : 100 } , ( _ , i ) => ( {
889+ id : `item_${ i } ` ,
890+ content : { id : `I_other_${ i } ` } ,
891+ } ) ) ,
892+ pageInfo : { hasNextPage : true , endCursor : "next" } ,
893+ } ,
894+ } ,
895+ } ;
896+ mockGraphql . mockResolvedValueOnce ( {
897+ repository : { issueOrPullRequest : { id : "I_issue1" } } ,
898+ } ) ;
899+ for ( let p = 0 ; p < 100 ; p ++ ) {
900+ mockGraphql . mockResolvedValueOnce ( pageWithNext ) ;
901+ }
902+ await expect (
903+ repo . setTaskPriority ( project , "owner" , "repo" , 1 , "High" , "token" )
904+ ) . rejects . toThrow ( "not in the project yet" ) ;
905+ expect ( logError ) . toHaveBeenCalledWith (
906+ expect . stringContaining ( "Stopped after 100 pages" )
907+ ) ;
842908 } ) ;
843909} ) ;
0 commit comments