File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { act } from '@testing-library/react' ;
1+ import { act , fireEvent } from '@testing-library/react' ;
2+
3+ import { PersonIcon } from '@primer/octicons-react' ;
24
35import {
46 ensureStableEmojis ,
@@ -43,4 +45,35 @@ describe('renderer/components/Oops.tsx', () => {
4345
4446 expect ( tree . container ) . toMatchSnapshot ( ) ;
4547 } ) ;
48+
49+ it ( 'should render action buttons and navigate on click' , async ( ) => {
50+ const mockError = {
51+ title : 'Error title' ,
52+ descriptions : [ 'Error description' ] ,
53+ emojis : [ '🔥' ] ,
54+ actions : [
55+ {
56+ label : 'Go somewhere' ,
57+ route : '/somewhere' ,
58+ variant : 'danger' as const ,
59+ icon : PersonIcon ,
60+ } ,
61+ ] ,
62+ } ;
63+
64+ let tree : ReturnType < typeof renderWithAppContext > | null = null ;
65+
66+ await act ( async ( ) => {
67+ tree = renderWithAppContext ( < Oops error = { mockError } /> ) ;
68+ } ) ;
69+
70+ const btn = tree . getByText ( 'Go somewhere' ) ;
71+ expect ( btn ) . toBeDefined ( ) ;
72+
73+ await act ( async ( ) => {
74+ fireEvent . click ( btn ) ;
75+ } ) ;
76+
77+ expect ( navigateMock ) . toHaveBeenCalledWith ( '/somewhere' ) ;
78+ } ) ;
4679} ) ;
You can’t perform that action at this time.
0 commit comments