File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -63,3 +63,15 @@ exports[`return-dispatch > handleAction > getRunIdAndUrl > should return the ID
6363 "Attempting to identify run ID from steps...",
6464]
6565` ;
66+
67+ exports [` return-dispatch > handleAction > getRunIdAndUrl > should timeout when unable failing to get the run IDs 1` ] = `
68+ [
69+ "Attempting to identify Run ID for workflow.yml (123)",
70+ ]
71+ ` ;
72+
73+ exports [` return-dispatch > handleAction > getRunIdAndUrl > should timeout when unable failing to get the run IDs 2` ] = `
74+ [
75+ "Attempting to identify run ID from steps...",
76+ ]
77+ ` ;
Original file line number Diff line number Diff line change @@ -739,7 +739,43 @@ describe("return-dispatch", () => {
739739 assertNoneCalled ( ) ;
740740 } ) ;
741741
742- it ( "should timeout when unable failing to get the run IDs" ) ;
742+ it ( "should timeout when unable failing to get the run IDs" , async ( ) => {
743+ apiRetryOrTimeoutMock . mockResolvedValue ( {
744+ success : false ,
745+ reason : "timeout" ,
746+ } ) ;
747+
748+ // Behaviour
749+ const getRunIdAndUrlPromise = getRunIdAndUrl ( {
750+ ...defaultOpts ,
751+ } ) ;
752+ await vi . advanceTimersByTimeAsync ( 1000 ) ;
753+
754+ const run = await getRunIdAndUrlPromise ;
755+
756+ if ( run . success ) {
757+ expect . fail ( "expected call to fail" ) ;
758+ }
759+
760+ // Behaviour
761+ expect ( run . reason ) . toStrictEqual ( "timeout" ) ;
762+
763+ expect ( apiRetryOrTimeoutMock ) . toHaveBeenCalledOnce ( ) ;
764+ expect ( apiFetchWorkflowRunJobStepsMock ) . not . toHaveBeenCalled ( ) ;
765+ expect ( apiFetchWorkflowRunIdsMock ) . not . toHaveBeenCalled ( ) ;
766+ expect ( utilSleepMock ) . not . toHaveBeenCalled ( ) ;
767+
768+ // Logging
769+ assertOnlyCalled ( coreDebugLogMock , coreInfoLogMock ) ;
770+ expect ( coreDebugLogMock ) . toHaveBeenCalledTimes ( 2 ) ;
771+ expect ( coreDebugLogMock . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
772+ expect ( coreDebugLogMock . mock . calls [ 1 ] ?. [ 0 ] ) . toMatch (
773+ / T i m e d o u t w h i l e a t t e m p t i n g t o f e t c h W o r k f l o w R u n I D s , w a i t e d [ 0 - 9 ] + m s / ,
774+ ) ;
775+
776+ expect ( coreInfoLogMock ) . toHaveBeenCalledOnce ( ) ;
777+ expect ( coreInfoLogMock . mock . calls [ 0 ] ) . toMatchSnapshot ( ) ;
778+ } ) ;
743779
744780 it ( "should timeout when unable to find over time" ) ;
745781 } ) ;
You can’t perform that action at this time.
0 commit comments