Skip to content

Commit bfcf4e8

Browse files
committed
Fix failing test
1 parent f0496bf commit bfcf4e8

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

assets/src/js/pro/blocks-v3/components/error-boundary.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, createContext } from '@wordpress/element';
2+
import { BlockPlaceholder } from './block-placeholder';
23

34
// Create context outside the class
45
export const ErrorBoundaryContext = createContext( null );
@@ -37,6 +38,8 @@ export class ErrorBoundary extends Component {
3738
}
3839

3940
componentDidCatch( error, errorInfo ) {
41+
acf.debug( 'Block preview error caught:', error, errorInfo );
42+
4043
// Call optional onError callback
4144
if ( this.props.onError ) {
4245
this.props.onError( error, errorInfo );
@@ -123,19 +126,10 @@ export const BlockPreviewErrorFallback = ( {
123126
}
124127

125128
return (
126-
<Placeholder
127-
icon={ <Icon icon={ blockIcon } /> }
128-
label={ blockLabel }
129+
<BlockPlaceholder
130+
setBlockFormModalOpen={ setBlockFormModalOpen }
131+
blockLabel={ blockLabel }
129132
instructions={ errorMessage }
130-
>
131-
<Button
132-
variant="primary"
133-
onClick={ () => {
134-
setBlockFormModalOpen( true );
135-
} }
136-
>
137-
{ acf.__( 'Edit Block' ) }
138-
</Button>
139-
</Placeholder>
133+
/>
140134
);
141135
};

tests/js/blocks-v3/block-edit-error-boundary.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ describe( 'ErrorBoundary Component', () => {
116116
</ErrorBoundary>
117117
);
118118

119-
// Verify debug was called
119+
// Verify debug was called in componentDidCatch
120120
expect( global.acf.debug ).toHaveBeenCalledWith(
121121
'Block preview error caught:',
122122
expect.any( Error ),
123123
expect.any( Object )
124124
);
125125

126+
// Verify debug was called in BlockPreviewErrorFallback
126127
expect( global.acf.debug ).toHaveBeenCalledWith(
127128
'Block preview error:',
128129
expect.any( Error )

0 commit comments

Comments
 (0)