123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import ConfigStore from 'sentry/stores/configStore';
- import AlertWizard from 'sentry/views/alerts/wizard/index';
- describe('AlertWizard', () => {
- beforeEach(() => {
- ConfigStore.init();
- });
- it('sets crash free dataset to metrics', async () => {
- const {organization, project, routerProps, router} = initializeOrg({
- organization: {
- features: [
- 'alert-crash-free-metrics',
- 'incidents',
- 'performance-view',
- 'crash-rate-alerts',
- ],
- access: ['org:write', 'alerts:write'],
- },
- });
- render(
- <AlertWizard
- organization={organization}
- projectId={project.slug}
- {...routerProps}
- />,
- {router, organization}
- );
- await userEvent.click(screen.getByText('Crash Free Session Rate'));
- await userEvent.click(screen.getByText('Set Conditions'));
- expect(router.push).toHaveBeenCalledWith({
- pathname: '/organizations/org-slug/alerts/new/metric/',
- query: {
- aggregate:
- 'percentage(sessions_crashed, sessions) AS _crash_rate_alert_aggregate',
- dataset: 'metrics',
- eventTypes: 'session',
- project: 'project-slug',
- referrer: undefined,
- },
- });
- });
- it('should render alerts for enabled features', () => {
- const {organization, project, routerProps, router} = initializeOrg({
- organization: {
- features: [
- 'alert-crash-free-metrics',
- 'incidents',
- 'performance-view',
- 'crash-rate-alerts',
- 'insights-addon-modules',
- ],
- access: ['org:write', 'alerts:write'],
- },
- });
- render(
- <AlertWizard
- organization={organization}
- projectId={project.slug}
- {...routerProps}
- />,
- {router, organization}
- );
- expect(screen.getByText('Errors')).toBeInTheDocument();
- expect(screen.getByText('Sessions')).toBeInTheDocument();
- expect(screen.getByText('Performance')).toBeInTheDocument();
- expect(screen.getByText('LLM Monitoring')).toBeInTheDocument();
- expect(screen.getByText('Custom')).toBeInTheDocument();
- const alertGroups = screen.getAllByRole('radiogroup');
- expect(alertGroups.length).toEqual(5);
- });
- it('should only render alerts for errors in self-hosted errors only', () => {
- ConfigStore.set('isSelfHostedErrorsOnly', true);
- const {organization, project, routerProps, router} = initializeOrg({
- organization: {
- features: [
- 'alert-crash-free-metrics',
- 'incidents',
- 'performance-view',
- 'crash-rate-alerts',
- ],
- access: ['org:write', 'alerts:write'],
- },
- });
- render(
- <AlertWizard
- organization={organization}
- projectId={project.slug}
- {...routerProps}
- />,
- {router, organization}
- );
- expect(screen.getByText('Errors')).toBeInTheDocument();
- const alertGroups = screen.getAllByRole('radiogroup');
- expect(alertGroups.length).toEqual(1);
- });
- });
|