frontend-plugin-api: add ExtensionBoundary test for throwing PluginWrapper

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2026-01-16 16:36:30 +01:00
parent c4c2419daa
commit 7b7e547d46
@@ -163,6 +163,47 @@ describe('ExtensionBoundary', () => {
expect(pluginWrapperApi.getPluginWrapper).toHaveBeenCalledWith('app');
});
it('should handle errors thrown by PluginWrapper with ErrorDisplayBoundary', async () => {
const errorMsg = 'PluginWrapper error';
const TextComponent = () => {
return <p>Content</p>;
};
const ThrowingWrapper = () => {
throw new Error(errorMsg);
};
const pluginWrapperApi: PluginWrapperApi = {
getPluginWrapper: jest.fn((pluginId: string) => {
if (pluginId === 'app') {
return ThrowingWrapper;
}
return undefined;
}),
};
const { error } = await withLogCollector(['error'], async () => {
renderInTestApp(
<TestApiProvider apis={[[pluginWrapperApiRef, pluginWrapperApi]]}>
{createExtensionTester(
wrapInBoundaryExtension(<TextComponent />),
).reactElement()}
</TestApiProvider>,
);
await waitFor(() =>
expect(screen.getByText(errorMsg)).toBeInTheDocument(),
);
});
expect(error).toEqual(
expect.arrayContaining([
expect.objectContaining({
message: expect.stringContaining(errorMsg),
}),
]),
);
});
// TODO(Rugvip): Need a way to be able to override APIs in the app to be able to test this properly
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should emit analytics events if routable', async () => {