@@ -382,3 +382,64 @@ test('test that shared report with No Tag filter shows entries without tags', as
382382 await expect ( page . getByText ( 'Reporting' ) ) . toBeVisible ( ) ;
383383 await expect ( page . getByText ( 'Total' ) ) . toBeVisible ( ) ;
384384} ) ;
385+
386+ test ( 'test that updating expiration date on already-public report works' , async ( { page } ) => {
387+ const projectName = 'UpdateExpDateProj ' + Math . floor ( Math . random ( ) * 10000 ) ;
388+ const reportName = 'UpdateExpDateReport ' + Math . floor ( Math . random ( ) * 10000 ) ;
389+
390+ await createProject ( page , projectName ) ;
391+ await createTimeEntryWithProject ( page , projectName , '1h' ) ;
392+
393+ await goToReporting ( page ) ;
394+ await expect ( page . getByTestId ( 'reporting_view' ) . getByText ( projectName ) ) . toBeVisible ( ) ;
395+
396+ // Create a public report (already public by default)
397+ await saveAsSharedReport ( page , reportName ) ;
398+
399+ // Go to shared reports and edit
400+ await goToReportingShared ( page ) ;
401+ await expect ( page . getByText ( reportName ) ) . toBeVisible ( ) ;
402+
403+ // Click more options and edit
404+ await page
405+ . getByRole ( 'button' , { name : new RegExp ( 'Actions for Project ' + reportName ) } )
406+ . click ( ) ;
407+ await page . getByRole ( 'menuitem' , { name : / ^ E d i t R e p o r t / } ) . click ( ) ;
408+
409+ // The date picker should be visible (report is already public)
410+ const datePicker = page
411+ . getByRole ( 'dialog' )
412+ . getByRole ( 'button' , { name : DATE_PICKER_BUTTON_PATTERN } ) ;
413+ await expect ( datePicker ) . toBeVisible ( ) ;
414+ await datePicker . click ( ) ;
415+
416+ // Select the 25th of next month
417+ const calendarGrid = page . getByRole ( 'grid' ) ;
418+ await expect ( calendarGrid ) . toBeVisible ( { timeout : 5000 } ) ;
419+ await page . getByRole ( 'button' , { name : / N e x t / i } ) . click ( ) ;
420+ await page . getByRole ( 'gridcell' ) . filter ( { hasText : / ^ 2 5 $ / } ) . first ( ) . click ( ) ;
421+
422+ // Wait for the calendar to close
423+ await expect ( calendarGrid ) . not . toBeVisible ( ) ;
424+
425+ // Update the report and verify it includes the correct public_until date
426+ const [ response ] = await Promise . all ( [
427+ page . waitForResponse (
428+ ( response ) =>
429+ response . url ( ) . includes ( '/reports/' ) &&
430+ response . request ( ) . method ( ) === 'PUT' &&
431+ response . status ( ) === 200
432+ ) ,
433+ page . getByRole ( 'button' , { name : 'Update Report' } ) . click ( ) ,
434+ ] ) ;
435+ const responseBody = await response . json ( ) ;
436+ expect ( responseBody . data . public_until ) . toBeTruthy ( ) ;
437+
438+ // Verify the date is the 25th of a future month
439+ const returnedDate = new Date ( responseBody . data . public_until ) ;
440+ expect ( returnedDate . getUTCDate ( ) ) . toBe ( 25 ) ;
441+
442+ // The returned date should be in the future
443+ const now = new Date ( ) ;
444+ expect ( returnedDate . getTime ( ) ) . toBeGreaterThan ( now . getTime ( ) ) ;
445+ } ) ;
0 commit comments