@@ -263,4 +263,51 @@ describe('PayrollLanding', () => {
263263 )
264264 } )
265265 } )
266+
267+ describe ( 'payroll cancelled alert' , ( ) => {
268+ it ( 'shows payroll cancelled alert when showPayrollCancelledAlert prop is true' , async ( ) => {
269+ renderWithProviders ( < PayrollLanding { ...defaultProps } showPayrollCancelledAlert = { true } /> )
270+
271+ await waitFor ( ( ) => {
272+ expect ( screen . getByText ( 'Payroll cancelled' ) ) . toBeInTheDocument ( )
273+ } )
274+ } )
275+
276+ it ( 'does not show payroll cancelled alert when showPayrollCancelledAlert prop is false' , async ( ) => {
277+ renderWithProviders ( < PayrollLanding { ...defaultProps } showPayrollCancelledAlert = { false } /> )
278+
279+ await waitFor ( ( ) => {
280+ expect ( screen . getByRole ( 'tab' , { name : 'Run payroll' } ) ) . toBeInTheDocument ( )
281+ } )
282+
283+ expect ( screen . queryByText ( 'Payroll cancelled' ) ) . not . toBeInTheDocument ( )
284+ } )
285+
286+ it ( 'does not show payroll cancelled alert by default' , async ( ) => {
287+ renderWithProviders ( < PayrollLanding { ...defaultProps } /> )
288+
289+ await waitFor ( ( ) => {
290+ expect ( screen . getByRole ( 'tab' , { name : 'Run payroll' } ) ) . toBeInTheDocument ( )
291+ } )
292+
293+ expect ( screen . queryByText ( 'Payroll cancelled' ) ) . not . toBeInTheDocument ( )
294+ } )
295+
296+ it ( 'emits dismiss event when payroll cancelled alert is dismissed' , async ( ) => {
297+ const user = userEvent . setup ( )
298+ renderWithProviders ( < PayrollLanding { ...defaultProps } showPayrollCancelledAlert = { true } /> )
299+
300+ await waitFor ( ( ) => {
301+ expect ( screen . getByText ( 'Payroll cancelled' ) ) . toBeInTheDocument ( )
302+ } )
303+
304+ const dismissButton = screen . getByRole ( 'button' , { name : / d i s m i s s / i } )
305+ await user . click ( dismissButton )
306+
307+ expect ( defaultProps . onEvent ) . toHaveBeenCalledWith (
308+ componentEvents . RUN_PAYROLL_CANCELLED_ALERT_DISMISSED ,
309+ undefined ,
310+ )
311+ } )
312+ } )
266313} )
0 commit comments