|
@@ -1,21 +1,17 @@
|
|
|
import {OrganizationFixture} from 'sentry-fixture/organization';
|
|
|
import {ProjectFixture} from 'sentry-fixture/project';
|
|
|
|
|
|
-import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
|
|
|
+import {render} from 'sentry-test/reactTestingLibrary';
|
|
|
|
|
|
-import {openModal} from 'sentry/actionCreators/modal';
|
|
|
import SetupAlertIntegrationButton from 'sentry/views/alerts/rules/issue/setupAlertIntegrationButton';
|
|
|
|
|
|
jest.mock('sentry/actionCreators/modal');
|
|
|
|
|
|
describe('SetupAlertIntegrationButton', function () {
|
|
|
const organization = OrganizationFixture();
|
|
|
- const featureOrg = OrganizationFixture({
|
|
|
- features: ['messaging-integration-onboarding'],
|
|
|
- });
|
|
|
const project = ProjectFixture();
|
|
|
|
|
|
- it('renders slack button if no alert integrations when feature flag is off', function () {
|
|
|
+ it('renders slack button if no alert integrations are installed', function () {
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
|
|
|
body: {
|
|
@@ -32,7 +28,7 @@ describe('SetupAlertIntegrationButton', function () {
|
|
|
);
|
|
|
expect(container).toHaveTextContent('Set Up Slack Now');
|
|
|
});
|
|
|
- it('does not render button if alert integration installed when feature flag is off', function () {
|
|
|
+ it('does not render button if alert integration is installed', function () {
|
|
|
MockApiClient.addMockResponse({
|
|
|
url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
|
|
|
body: {
|
|
@@ -49,57 +45,4 @@ describe('SetupAlertIntegrationButton', function () {
|
|
|
);
|
|
|
expect(container).not.toHaveTextContent('Set Up Slack Now');
|
|
|
});
|
|
|
- it('renders connect to messaging button when feature flag is on', function () {
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- url: `/projects/${featureOrg.slug}/${project.slug}/?expand=hasAlertIntegration`,
|
|
|
- body: {
|
|
|
- ...project,
|
|
|
- hasAlertIntegrationInstalled: false,
|
|
|
- },
|
|
|
- });
|
|
|
- const {container} = render(
|
|
|
- <SetupAlertIntegrationButton
|
|
|
- projectSlug={project.slug}
|
|
|
- organization={featureOrg}
|
|
|
- refetchConfigs={jest.fn()}
|
|
|
- />
|
|
|
- );
|
|
|
- expect(container).toHaveTextContent('Connect to messaging');
|
|
|
- });
|
|
|
- it('does not render button if alert integration installed when feature flag is on', function () {
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- url: `/projects/${featureOrg.slug}/${project.slug}/?expand=hasAlertIntegration`,
|
|
|
- body: {
|
|
|
- ...project,
|
|
|
- hasAlertIntegrationInstalled: true,
|
|
|
- },
|
|
|
- });
|
|
|
- const {container} = render(
|
|
|
- <SetupAlertIntegrationButton
|
|
|
- projectSlug={project.slug}
|
|
|
- organization={featureOrg}
|
|
|
- refetchConfigs={jest.fn()}
|
|
|
- />
|
|
|
- );
|
|
|
- expect(container).not.toHaveTextContent('Connect to messaging');
|
|
|
- });
|
|
|
- it('opens modal when clicked', async () => {
|
|
|
- MockApiClient.addMockResponse({
|
|
|
- url: `/projects/${featureOrg.slug}/${project.slug}/?expand=hasAlertIntegration`,
|
|
|
- body: {
|
|
|
- ...project,
|
|
|
- hasAlertIntegrationInstalled: false,
|
|
|
- },
|
|
|
- });
|
|
|
- render(
|
|
|
- <SetupAlertIntegrationButton
|
|
|
- projectSlug={project.slug}
|
|
|
- organization={featureOrg}
|
|
|
- refetchConfigs={jest.fn()}
|
|
|
- />
|
|
|
- );
|
|
|
- await userEvent.click(screen.getByLabelText('Connect to messaging'));
|
|
|
-
|
|
|
- expect(openModal).toHaveBeenCalled();
|
|
|
- });
|
|
|
});
|