123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {SentryAppFixture} from 'sentry-fixture/sentryApp';
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import SentryApplicationRowButtons from 'sentry/views/settings/organizationDeveloperSettings/sentryApplicationRow/sentryApplicationRowButtons';
- describe('Sentry App Row Buttons', function () {
- const removeApp = jest.fn();
- const publishApp = jest.fn();
- const sentryApp = SentryAppFixture();
- afterEach(() => {
- MockApiClient.clearMockResponses();
- });
- it('renders', async () => {
- render(
- <SentryApplicationRowButtons
- organization={OrganizationFixture()}
- app={sentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- expect(publishButton).toBeDisabled();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('hides the publish button if the app is internal', async () => {
- const internalSentryApp = SentryAppFixture({status: 'internal'});
- render(
- <SentryApplicationRowButtons
- organization={OrganizationFixture()}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- expect(screen.queryByText('Publish')).not.toBeInTheDocument();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('disables the delete and publish button if the app is published', async () => {
- const internalSentryApp = SentryAppFixture({status: 'published'});
- render(
- <SentryApplicationRowButtons
- organization={OrganizationFixture()}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- expect(publishButton).toBeDisabled();
- await userEvent.hover(publishButton, {delay: 100});
- expect(
- screen.getByText('Published integrations cannot be re-published.')
- ).toBeInTheDocument();
- expect(publishButton).toBeDisabled();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeDisabled();
- await userEvent.hover(deleteButton, {delay: 100});
- expect(
- screen.getByText('Published integrations cannot be removed.')
- ).toBeInTheDocument();
- expect(publishButton).toBeDisabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('disables the publish button if the sentry app has a UI feature and no icon', async () => {
- const organization = OrganizationFixture();
- const internalSentryApp = SentryAppFixture({
- status: 'unpublished',
- avatars: [
- {
- avatarType: 'upload',
- avatarUuid: '1234561234561234561234567',
- avatarUrl: 'https://example.com/avatar/1234561234561234561234567/',
- color: true,
- photoType: 'logo',
- },
- {
- avatarType: 'default',
- avatarUuid: '1234561234561234561234567',
- avatarUrl: 'https://example.com/avatar/1234561234561234561234567/',
- color: false,
- photoType: 'icon',
- },
- ],
- schema: {
- elements: [
- {
- type: 'issue-link',
- create: {
- uri: '/api/sentry/issue-link/create/',
- required_fields: [
- {
- type: 'text',
- label: 'Task Name',
- name: 'title',
- default: 'issue.title',
- },
- ],
- },
- link: {
- uri: '/api/sentry/issue-link/link/',
- required_fields: [
- {
- type: 'select',
- label: 'Which task would you like to link to this Sentry Issue?',
- name: 'itemId',
- uri: '/api/sentry/options/items/',
- },
- ],
- },
- },
- ],
- },
- });
- render(
- <SentryApplicationRowButtons
- organization={organization}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- await userEvent.hover(publishButton, {delay: 100});
- expect(
- screen.getByText('Integrations with a UI component must have an icon')
- ).toBeInTheDocument();
- expect(publishButton).toBeDisabled();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('disables the publish button if the app is in progress of publishing', async () => {
- const organization = OrganizationFixture();
- const internalSentryApp = SentryAppFixture({status: 'publish_request_inprogress'});
- render(
- <SentryApplicationRowButtons
- organization={organization}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- expect(publishButton).toBeDisabled();
- await userEvent.hover(publishButton, {delay: 100});
- expect(
- screen.getByText('This integration has already been submitted for publishing')
- ).toBeInTheDocument();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('disables the publish button if the app is in progress of deletion', async () => {
- const organization = OrganizationFixture();
- const internalSentryApp = SentryAppFixture({status: 'deletion_in_progress'});
- render(
- <SentryApplicationRowButtons
- organization={organization}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- expect(publishButton).toBeDisabled();
- await userEvent.hover(publishButton, {delay: 100});
- expect(
- screen.getByText('Only unpublished integrations can be published')
- ).toBeInTheDocument();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- it('disables the publish button if the app doesnt have a logo', async () => {
- const organization = OrganizationFixture();
- const internalSentryApp = SentryAppFixture({status: 'unpublished'});
- render(
- <SentryApplicationRowButtons
- organization={organization}
- app={internalSentryApp}
- onClickRemove={removeApp}
- onClickPublish={publishApp}
- />
- );
- const publishButton = await screen.findByRole('button', {name: 'Publish'});
- expect(publishButton).toBeDisabled();
- await userEvent.hover(publishButton, {delay: 100});
- expect(
- screen.getByText('A logo is required to publish an integration')
- ).toBeInTheDocument();
- const deleteButton = await screen.findByRole('button', {name: 'Delete'});
- expect(deleteButton).toBeEnabled();
- const dashboardButton = await screen.findByRole('button', {name: 'Dashboard'});
- expect(dashboardButton).toBeEnabled();
- });
- });
|