mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-21 19:09:20 +00:00
Report group call errors to sentry
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
} from "react";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import * as Sentry from "@sentry/react";
|
||||
|
||||
import {
|
||||
type CallErrorRecoveryAction,
|
||||
@@ -32,6 +33,15 @@ import {
|
||||
import { mockConfig } from "../utils/test.ts";
|
||||
import { ElementWidgetActions, type WidgetHelpers } from "../widget.ts";
|
||||
|
||||
// Mock Sentry before importing the component
|
||||
vi.mock("@sentry/react", async () => {
|
||||
const actual = await vi.importActual("@sentry/react");
|
||||
return {
|
||||
...actual,
|
||||
captureException: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
test.each([
|
||||
{
|
||||
error: new MatrixRTCTransportMissingError("example.com"),
|
||||
@@ -212,6 +222,33 @@ describe("Rageshake button", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should call Sentry.captureException for unknown errors", async () => {
|
||||
vi.mocked(Sentry.captureException).mockClear(); // Clear previous calls
|
||||
|
||||
const originalError = new Error("Unknown test error");
|
||||
const error = new UnknownCallError(originalError);
|
||||
const TestComponent = (): ReactNode => {
|
||||
throw error;
|
||||
};
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<GroupCallErrorBoundary
|
||||
onError={vi.fn()}
|
||||
recoveryActionHandler={vi.fn()}
|
||||
widget={null}
|
||||
>
|
||||
<TestComponent />
|
||||
</GroupCallErrorBoundary>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
|
||||
await screen.findByText(/Something went wrong/);
|
||||
|
||||
expect(Sentry.captureException).toHaveBeenCalledWith(error);
|
||||
expect(Sentry.captureException).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test("should have a close button in widget mode", async () => {
|
||||
const error = new MatrixRTCTransportMissingError("example.com");
|
||||
const TestComponent = (): ReactNode => {
|
||||
|
||||
Reference in New Issue
Block a user