@@ -4,6 +4,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
44const state = {
55 infoCalls : [ ] as string [ ] ,
66 setFailedCalls : [ ] as string [ ] ,
7+ warningCalls : [ ] as string [ ] ,
78 execCalls : [ ] as [ string , string [ ] | undefined , unknown ] [ ] , // [cmd, args, opts]
89 getInputImpl : ( _name : string ) : string => "" ,
910 getBooleanInputImpl : ( _name : string ) : boolean => false ,
@@ -42,6 +43,9 @@ vi.mock("@actions/core", () => ({
4243 setFailed : vi . fn ( ( msg : string ) => {
4344 state . setFailedCalls . push ( msg ) ;
4445 } ) ,
46+ warning : vi . fn ( ( msg : string ) => {
47+ state . warningCalls . push ( msg ) ;
48+ } ) ,
4549} ) ) ;
4650
4751vi . mock ( "@actions/github" , ( ) => ( {
@@ -84,6 +88,7 @@ function setupMocks({
8488 // Reset shared state
8589 state . infoCalls = [ ] ;
8690 state . setFailedCalls = [ ] ;
91+ state . warningCalls = [ ] ;
8792 state . execCalls = [ ] ;
8893
8994 // Setup input implementations
@@ -153,6 +158,7 @@ beforeEach(() => {
153158 vi . clearAllMocks ( ) ;
154159 state . infoCalls = [ ] ;
155160 state . setFailedCalls = [ ] ;
161+ state . warningCalls = [ ] ;
156162 state . execCalls = [ ] ;
157163} ) ;
158164
@@ -323,10 +329,12 @@ describe("updateFromSourceSpec", () => {
323329 } ) ,
324330 ) ;
325331
326- // Comment body should mention sync failed
332+ // Comment body should mention sync failed and include error details
327333 const commentCall = mockIssuesCreateComment . mock . calls [ 0 ] [ 0 ] ;
328334 expect ( commentCall . body ) . toContain ( "Sync failed" ) ;
329335 expect ( commentCall . body ) . toContain ( "merge conflicts" ) ;
336+ expect ( commentCall . body ) . toContain ( "Rebase error:" ) ;
337+ expect ( commentCall . body ) . toContain ( "merge conflict" ) ;
330338
331339 // Action should still fail (not silently succeed)
332340 expect ( state . setFailedCalls ) . toEqual (
@@ -362,6 +370,72 @@ describe("updateFromSourceSpec", () => {
362370 ] ) ,
363371 ) ;
364372 } ) ;
373+
374+ it ( "should include rebase abort error in PR comment when abort fails" , async ( ) => {
375+ setupMocks ( { hasChanges : true , existingPRNumber : 42 } ) ;
376+ state . execImpl = async (
377+ cmd : string ,
378+ args ?: string [ ] ,
379+ ) : Promise < number > => {
380+ if (
381+ cmd === "git" &&
382+ Array . isArray ( args ) &&
383+ ( args . includes ( "push" ) ||
384+ ( args . includes ( "pull" ) && args . includes ( "--rebase" ) ) )
385+ ) {
386+ throw new Error ( "merge conflict" ) ;
387+ }
388+ if (
389+ cmd === "git" &&
390+ Array . isArray ( args ) &&
391+ args . includes ( "rebase" ) &&
392+ args . includes ( "--abort" )
393+ ) {
394+ throw new Error ( "no rebase in progress" ) ;
395+ }
396+ return 0 ;
397+ } ;
398+ await importAndRun ( ) ;
399+
400+ const commentCall = mockIssuesCreateComment . mock . calls [ 0 ] [ 0 ] ;
401+ expect ( commentCall . body ) . toContain ( "Rebase error:" ) ;
402+ expect ( commentCall . body ) . toContain ( "merge conflict" ) ;
403+ expect ( commentCall . body ) . toContain ( "Rebase abort error:" ) ;
404+ expect ( commentCall . body ) . toContain ( "no rebase in progress" ) ;
405+ } ) ;
406+ } ) ;
407+
408+ describe ( "dynamic branch name warning" , ( ) => {
409+ it ( "should warn when branch name contains an ISO date" , async ( ) => {
410+ setupMocks ( { hasChanges : false } ) ;
411+ state . getInputImpl = ( name : string ) : string => {
412+ const inputs : Record < string , string > = {
413+ token : "fake-token" ,
414+ branch : "update-openapi-spec-2026-02-25T00-27-08-474Z" ,
415+ auto_merge : "false" ,
416+ update_from_source : "true" ,
417+ } ;
418+ return inputs [ name ] || "" ;
419+ } ;
420+ await importAndRun ( ) ;
421+
422+ expect ( state . warningCalls ) . toEqual (
423+ expect . arrayContaining ( [
424+ expect . stringContaining ( "appears to contain a timestamp" ) ,
425+ ] ) ,
426+ ) ;
427+ } ) ;
428+
429+ it ( "should not warn for a stable branch name" , async ( ) => {
430+ setupMocks ( { hasChanges : false } ) ;
431+ await importAndRun ( ) ;
432+
433+ expect ( state . warningCalls ) . not . toEqual (
434+ expect . arrayContaining ( [
435+ expect . stringContaining ( "appears to contain a timestamp" ) ,
436+ ] ) ,
437+ ) ;
438+ } ) ;
365439 } ) ;
366440
367441 describe ( "when auto_merge is true" , ( ) => {
0 commit comments