@@ -34,9 +34,12 @@ jest.spyOn(api, 'get');
3434// Mock toLocaleString to always use UTC timezone for consistent test results
3535const originalToLocaleString = Date . prototype . toLocaleString ;
3636beforeAll ( ( ) => {
37- // eslint-disable-next-line no-extend-native
38- Date . prototype . toLocaleString = function ( locale , options ) {
39- return originalToLocaleString . call ( this , locale , { ...options , timeZone : 'UTC' } ) ;
37+ // eslint-disable-next-line no-extend-native, func-names
38+ Date . prototype . toLocaleString = function ( locale , options ) {
39+ return originalToLocaleString . call ( this , locale , {
40+ ...options ,
41+ timeZone : 'UTC' ,
42+ } ) ;
4043 } ;
4144} ) ;
4245afterAll ( ( ) => {
@@ -76,7 +79,12 @@ const initialStateScheduled = {
7679} ;
7780
7881api . get . mockImplementation ( ( { handleSuccess, ...action } ) => {
79- if ( action . key === 'GET_REPORT_TEMPLATES' ) {
82+ if ( action . key === 'GET_REPORT_TEMPLATE_SETTING' ) {
83+ handleSuccess &&
84+ handleSuccess ( {
85+ data : { value : 'Job - Invocation Report' } ,
86+ } ) ;
87+ } else if ( action . key === 'GET_REPORT_TEMPLATES' ) {
8088 handleSuccess &&
8189 handleSuccess ( {
8290 data : mockReportTemplatesResponse ,
@@ -229,7 +237,15 @@ describe('JobInvocationDetailPage', () => {
229237 ) ;
230238
231239 const expectedActions = [
232- { key : GET_REPORT_TEMPLATES , url : '/api/report_templates' } ,
240+ {
241+ key : GET_REPORT_TEMPLATES ,
242+ url : '/api/report_templates' ,
243+ params : { search : 'name="Job - Invocation Report"' , per_page : 1 } ,
244+ } ,
245+ {
246+ key : 'GET_REPORT_TEMPLATE_SETTING' ,
247+ url : '/api/settings/remote_execution_job_invocation_report_template' ,
248+ } ,
233249 {
234250 key : JOB_INVOCATION_KEY ,
235251 url : `/api/job_invocations/${ jobId } ?host_status=true` ,
@@ -278,6 +294,9 @@ describe('JobInvocationDetailPage', () => {
278294 if ( expectedAction . url ) {
279295 expect ( actualActions [ index ] . url ) . toEqual ( expectedAction . url ) ;
280296 }
297+ if ( expectedAction . params ) {
298+ expect ( actualActions [ index ] . params ) . toEqual ( expectedAction . params ) ;
299+ }
281300 }
282301 } ) ;
283302 } ) ;
0 commit comments