|
@@ -1,3 +1,5 @@
|
|
|
|
+import {OrganizationFixture} from 'sentry-fixture/organization';
|
|
|
|
+import {OrganizationIntegrationsFixture} from 'sentry-fixture/organizationIntegrations';
|
|
import {
|
|
import {
|
|
MOCK_RESP_INCONSISTENT_INTERVALS,
|
|
MOCK_RESP_INCONSISTENT_INTERVALS,
|
|
MOCK_RESP_INCONSISTENT_PLACEHOLDERS,
|
|
MOCK_RESP_INCONSISTENT_PLACEHOLDERS,
|
|
@@ -5,18 +7,40 @@ import {
|
|
MOCK_RESP_VERBOSE,
|
|
MOCK_RESP_VERBOSE,
|
|
} from 'sentry-fixture/ruleConditions';
|
|
} from 'sentry-fixture/ruleConditions';
|
|
|
|
|
|
-import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
|
|
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
|
|
import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
|
|
import selectEvent from 'sentry-test/selectEvent';
|
|
import selectEvent from 'sentry-test/selectEvent';
|
|
|
|
|
|
|
|
+import type {IssueAlertNotificationProps} from 'sentry/views/projectInstall/issueAlertNotificationOptions';
|
|
import IssueAlertOptions from 'sentry/views/projectInstall/issueAlertOptions';
|
|
import IssueAlertOptions from 'sentry/views/projectInstall/issueAlertOptions';
|
|
|
|
|
|
describe('IssueAlertOptions', function () {
|
|
describe('IssueAlertOptions', function () {
|
|
- const {organization} = initializeOrg();
|
|
|
|
|
|
+ const organization = OrganizationFixture({
|
|
|
|
+ features: ['messaging-integration-onboarding-project-creation'],
|
|
|
|
+ });
|
|
const URL = `/projects/${organization.slug}/rule-conditions/`;
|
|
const URL = `/projects/${organization.slug}/rule-conditions/`;
|
|
|
|
+
|
|
|
|
+ const notificationProps: IssueAlertNotificationProps = {
|
|
|
|
+ actions: [],
|
|
|
|
+ channel: 'channel',
|
|
|
|
+ integration: OrganizationIntegrationsFixture(),
|
|
|
|
+ provider: 'slack',
|
|
|
|
+ providersToIntegrations: {},
|
|
|
|
+ querySuccess: true,
|
|
|
|
+ shouldRenderSetupButton: false,
|
|
|
|
+ refetchConfigs: jest.fn(),
|
|
|
|
+ setActions: jest.fn(),
|
|
|
|
+ setChannel: jest.fn(),
|
|
|
|
+ setIntegration: jest.fn(),
|
|
|
|
+ setProvider: jest.fn(),
|
|
|
|
+ };
|
|
|
|
+
|
|
const props = {
|
|
const props = {
|
|
onChange: jest.fn(),
|
|
onChange: jest.fn(),
|
|
|
|
+ organization,
|
|
|
|
+ notificationProps,
|
|
};
|
|
};
|
|
|
|
+ const getComponent = () => <IssueAlertOptions {...props} {...notificationProps} />;
|
|
|
|
+
|
|
beforeEach(() => {
|
|
beforeEach(() => {
|
|
MockApiClient.addMockResponse({
|
|
MockApiClient.addMockResponse({
|
|
url: `/projects/${organization.slug}/rule-conditions/`,
|
|
url: `/projects/${organization.slug}/rule-conditions/`,
|
|
@@ -34,7 +58,7 @@ describe('IssueAlertOptions', function () {
|
|
body: [],
|
|
body: [],
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />, {organization});
|
|
|
|
|
|
+ render(getComponent(), {organization});
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -44,7 +68,7 @@ describe('IssueAlertOptions', function () {
|
|
body: {},
|
|
body: {},
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />, {organization});
|
|
|
|
|
|
+ render(getComponent(), {organization});
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -54,7 +78,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_INCONSISTENT_INTERVALS,
|
|
body: MOCK_RESP_INCONSISTENT_INTERVALS,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />, {organization});
|
|
|
|
|
|
+ render(getComponent(), {organization});
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(2);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -63,7 +87,7 @@ describe('IssueAlertOptions', function () {
|
|
url: URL,
|
|
url: URL,
|
|
body: MOCK_RESP_INCONSISTENT_PLACEHOLDERS,
|
|
body: MOCK_RESP_INCONSISTENT_PLACEHOLDERS,
|
|
});
|
|
});
|
|
- render(<IssueAlertOptions {...props} />, {organization});
|
|
|
|
|
|
+ render(getComponent(), {organization});
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -73,7 +97,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_ONLY_IGNORED_CONDITIONS_INVALID,
|
|
body: MOCK_RESP_ONLY_IGNORED_CONDITIONS_INVALID,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />, {organization});
|
|
|
|
|
|
+ render(getComponent(), {organization});
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
await selectEvent.select(screen.getByText('Select...'), 'users affected by');
|
|
await selectEvent.select(screen.getByText('Select...'), 'users affected by');
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
@@ -90,7 +114,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_VERBOSE,
|
|
body: MOCK_RESP_VERBOSE,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />);
|
|
|
|
|
|
+ render(getComponent());
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
expect(screen.getAllByRole('radio')).toHaveLength(3);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -100,7 +124,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_VERBOSE,
|
|
body: MOCK_RESP_VERBOSE,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />);
|
|
|
|
|
|
+ render(getComponent());
|
|
await selectEvent.select(screen.getByText('occurrences of'), 'users affected by');
|
|
await selectEvent.select(screen.getByText('occurrences of'), 'users affected by');
|
|
await selectEvent.select(screen.getByText('one minute'), '30 days');
|
|
await selectEvent.select(screen.getByText('one minute'), '30 days');
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
@@ -117,7 +141,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_VERBOSE,
|
|
body: MOCK_RESP_VERBOSE,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} />);
|
|
|
|
|
|
+ render(getComponent());
|
|
expect(screen.getByTestId('range-input')).toHaveValue(10);
|
|
expect(screen.getByTestId('range-input')).toHaveValue(10);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -127,7 +151,7 @@ describe('IssueAlertOptions', function () {
|
|
body: MOCK_RESP_VERBOSE,
|
|
body: MOCK_RESP_VERBOSE,
|
|
});
|
|
});
|
|
|
|
|
|
- render(<IssueAlertOptions {...props} organization={organization} />);
|
|
|
|
|
|
+ render(getComponent());
|
|
await userEvent.click(screen.getByLabelText(/When there are more than/i));
|
|
await userEvent.click(screen.getByLabelText(/When there are more than/i));
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
expect(props.onChange).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
expect.objectContaining({
|
|
@@ -141,4 +165,40 @@ describe('IssueAlertOptions', function () {
|
|
})
|
|
})
|
|
);
|
|
);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ it('should render alert configuration if `Default` or `Custom` alerts are selected', async () => {
|
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
|
+ url: URL,
|
|
|
|
+ body: MOCK_RESP_VERBOSE,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ render(getComponent());
|
|
|
|
+ await screen.findByRole('checkbox', {name: 'Notify via email'});
|
|
|
|
+ await screen.findByRole('checkbox', {
|
|
|
|
+ name: 'Notify via integration (Slack, Discord, MS Teams, etc.)',
|
|
|
|
+ });
|
|
|
|
+ await selectEvent.select(screen.getByText('occurrences of'), 'users affected by');
|
|
|
|
+ await screen.findByRole('checkbox', {name: 'Notify via email'});
|
|
|
|
+ await screen.findByRole('checkbox', {
|
|
|
|
+ name: 'Notify via integration (Slack, Discord, MS Teams, etc.)',
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ it('should not render notification configuration if `Create Alerts Later` is selected', async () => {
|
|
|
|
+ MockApiClient.addMockResponse({
|
|
|
|
+ url: URL,
|
|
|
|
+ body: MOCK_RESP_VERBOSE,
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ render(getComponent());
|
|
|
|
+ await userEvent.click(screen.getByLabelText("I'll create my own alerts later"));
|
|
|
|
+ expect(
|
|
|
|
+ screen.queryByRole('checkbox', {name: 'Notify via email'})
|
|
|
|
+ ).not.toBeInTheDocument();
|
|
|
|
+ expect(
|
|
|
|
+ screen.queryByRole('checkbox', {
|
|
|
|
+ name: 'Notify via integration (Slack, Discord, MS Teams, etc.)',
|
|
|
|
+ })
|
|
|
|
+ ).not.toBeInTheDocument();
|
|
|
|
+ });
|
|
});
|
|
});
|