mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-15 18:49:21 +00:00
review: Improve test
This commit is contained in:
@@ -26,8 +26,12 @@ import {
|
|||||||
ConnectionLostError,
|
ConnectionLostError,
|
||||||
E2EENotSupportedError,
|
E2EENotSupportedError,
|
||||||
type ElementCallError,
|
type ElementCallError,
|
||||||
|
FailToGetOpenIdToken,
|
||||||
|
FailToStartLivekitConnection,
|
||||||
InsufficientCapacityError,
|
InsufficientCapacityError,
|
||||||
MatrixRTCTransportMissingError,
|
MatrixRTCTransportMissingError,
|
||||||
|
NoMatrix2AuthorizationService,
|
||||||
|
SFURoomCreationRestrictedError,
|
||||||
UnknownCallError,
|
UnknownCallError,
|
||||||
} from "../utils/errors.ts";
|
} from "../utils/errors.ts";
|
||||||
import { mockConfig } from "../utils/test.ts";
|
import { mockConfig } from "../utils/test.ts";
|
||||||
@@ -222,32 +226,43 @@ describe("Rageshake button", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should call Sentry.captureException for unknown errors", async () => {
|
test.each([
|
||||||
vi.mocked(Sentry.captureException).mockClear(); // Clear previous calls
|
{ error: new MatrixRTCTransportMissingError("example.com") },
|
||||||
|
{ error: new ConnectionLostError() },
|
||||||
|
{ error: new UnknownCallError(new Error("FOO")) },
|
||||||
|
{ error: new E2EENotSupportedError() },
|
||||||
|
{ error: new InsufficientCapacityError() },
|
||||||
|
{ error: new SFURoomCreationRestrictedError() },
|
||||||
|
{ error: new FailToStartLivekitConnection() },
|
||||||
|
{ error: new NoMatrix2AuthorizationService(new Error("FOO")) },
|
||||||
|
{ error: new FailToGetOpenIdToken(new Error("FOO")) },
|
||||||
|
])(
|
||||||
|
"should call Sentry.captureException for group call errors $error",
|
||||||
|
({ error }) => {
|
||||||
|
vi.mocked(Sentry.captureException).mockClear(); // Clear previous calls
|
||||||
|
|
||||||
const originalError = new Error("Unknown test error");
|
const TestComponent = (): ReactNode => {
|
||||||
const error = new UnknownCallError(originalError);
|
throw error;
|
||||||
const TestComponent = (): ReactNode => {
|
};
|
||||||
throw error;
|
|
||||||
};
|
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<GroupCallErrorBoundary
|
<GroupCallErrorBoundary
|
||||||
onError={vi.fn()}
|
onError={vi.fn()}
|
||||||
recoveryActionHandler={vi.fn()}
|
recoveryActionHandler={vi.fn()}
|
||||||
widget={null}
|
widget={null}
|
||||||
>
|
>
|
||||||
<TestComponent />
|
<TestComponent />
|
||||||
</GroupCallErrorBoundary>
|
</GroupCallErrorBoundary>
|
||||||
</BrowserRouter>,
|
</BrowserRouter>,
|
||||||
);
|
);
|
||||||
|
|
||||||
await screen.findByText(/Something went wrong/);
|
// await screen.findByText(/Something went wrong/);
|
||||||
|
|
||||||
expect(Sentry.captureException).toHaveBeenCalledWith(error);
|
expect(Sentry.captureException).toHaveBeenCalledWith(error);
|
||||||
expect(Sentry.captureException).toHaveBeenCalledOnce();
|
expect(Sentry.captureException).toHaveBeenCalledOnce();
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test("should have a close button in widget mode", async () => {
|
test("should have a close button in widget mode", async () => {
|
||||||
const error = new MatrixRTCTransportMissingError("example.com");
|
const error = new MatrixRTCTransportMissingError("example.com");
|
||||||
|
|||||||
Reference in New Issue
Block a user