Add temporary Sentry test button (dev/test only)

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-07-25 13:46:43 +02:00
co-authored by Junie
parent 524b5a6dc7
commit c90300b9a4
8 changed files with 107 additions and 0 deletions
@@ -0,0 +1,30 @@
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import * as Sentry from '@sentry/react';
import { SentryTestButton, handleSentryTestErrorClick } from '../SentryTestButton';
vi.mock('@sentry/react', () => ({
captureException: vi.fn(),
logger: { info: vi.fn() },
metrics: { count: vi.fn() },
}));
describe('SentryTestButton', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('is visible in the current (development/test) build', () => {
render(<SentryTestButton />);
expect(screen.getByRole('button', { name: 'Break the world' })).toBeInTheDocument();
});
it('sends a log and a metric to Sentry, then throws an intentional test error', () => {
expect(() => handleSentryTestErrorClick()).toThrow('This is your first error!');
expect(Sentry.logger.info).toHaveBeenCalledWith('User triggered test error', {
action: 'test_error_button_click',
});
expect(Sentry.metrics.count).toHaveBeenCalledWith('test_counter', 1);
});
});