@@ -1900,6 +1900,37 @@ def test_fork_pr_skips_comment_and_warns(self):
19001900 self .assertIn ("::warning::" , printed )
19011901 self .assertIn ("read-only" , printed )
19021902
1903+ def test_fork_pr_warning_names_only_the_surfaces_that_exist (self ):
1904+ """With job-summary: false the warning must not send the reader to a
1905+ summary this run never wrote; the annotations are still named."""
1906+ summary_path = os .path .join (tempfile .mkdtemp (), "summary.txt" )
1907+ with (
1908+ patch ("main.PR_COMMENTS_ENABLED" , True ),
1909+ patch .dict (os .environ , {"GITHUB_EVENT_NAME" : "pull_request" }),
1910+ patch ("main.is_fork_pr" , return_value = True ),
1911+ patch ("main.JOB_SUMMARY_ENABLED" , False ),
1912+ patch ("main.GITHUB_STEP_SUMMARY" , summary_path ),
1913+ patch ("builtins.print" ) as mock_print ,
1914+ ):
1915+ rc = main .add_pr_comments ([pass_scope ()])
1916+ self .assertEqual (rc , 0 )
1917+ printed = mock_print .call_args [0 ][0 ]
1918+ self .assertIn ("annotations on the Files changed tab" , printed )
1919+ self .assertNotIn ("job's summary" , printed )
1920+ self .assertFalse (os .path .exists (summary_path ))
1921+
1922+ with (
1923+ patch ("main.PR_COMMENTS_ENABLED" , True ),
1924+ patch .dict (os .environ , {"GITHUB_EVENT_NAME" : "pull_request" }),
1925+ patch ("main.is_fork_pr" , return_value = True ),
1926+ patch ("main.JOB_SUMMARY_ENABLED" , True ),
1927+ patch ("main.GITHUB_STEP_SUMMARY" , summary_path ),
1928+ patch ("builtins.print" ) as mock_print ,
1929+ ):
1930+ main .add_pr_comments ([pass_scope ()])
1931+ printed = mock_print .call_args [0 ][0 ]
1932+ self .assertIn ("in this job's summary and in the annotations" , printed )
1933+
19031934 def test_fork_pr_writes_job_summary_hint (self ):
19041935 summary_path = os .path .join (tempfile .mkdtemp (), "summary.txt" )
19051936 with (
0 commit comments