diff --git a/static/app/views/issueDetails/streamline/sidebar/seerDrawer.spec.tsx b/static/app/views/issueDetails/streamline/sidebar/seerDrawer.spec.tsx index d43292508ee6fd..0833321b298d78 100644 --- a/static/app/views/issueDetails/streamline/sidebar/seerDrawer.spec.tsx +++ b/static/app/views/issueDetails/streamline/sidebar/seerDrawer.spec.tsx @@ -136,6 +136,12 @@ describe('SeerDrawer', () => { url: `/organizations/${mockProject.organization.slug}/group-search-views/starred/`, body: [], }); + MockApiClient.addMockResponse({ + url: `/projects/${mockProject.organization.slug}/${mockProject.slug}/`, + body: { + autofixAutomationTuning: 'off', + }, + }); }); it('renders consent state if not consented', async () => { diff --git a/static/app/views/issueDetails/streamline/sidebar/seerNotices.spec.tsx b/static/app/views/issueDetails/streamline/sidebar/seerNotices.spec.tsx index 6b4c7c6ecc35aa..806d053bfba166 100644 --- a/static/app/views/issueDetails/streamline/sidebar/seerNotices.spec.tsx +++ b/static/app/views/issueDetails/streamline/sidebar/seerNotices.spec.tsx @@ -2,7 +2,7 @@ import {GroupSearchViewFixture} from 'sentry-fixture/groupSearchView'; import {OrganizationFixture} from 'sentry-fixture/organization'; import {ProjectFixture} from 'sentry-fixture/project'; -import {render, screen} from 'sentry-test/reactTestingLibrary'; +import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary'; import {SeerNotices} from 'sentry/views/issueDetails/streamline/sidebar/seerNotices'; @@ -54,19 +54,42 @@ describe('SeerNotices', function () { }); }); - it('shows automation step if automation is allowed and tuning is off', () => { - const project = getProjectWithAutomation('off'); + it('shows automation step if automation is allowed and tuning is off', async () => { + MockApiClient.addMockResponse({ + method: 'GET', + url: `/projects/${organization.slug}/${ProjectFixture().slug}/`, + body: { + autofixAutomationTuning: 'off', + }, + }); + const project = { + ...ProjectFixture(), + organization: { + ...ProjectFixture().organization, + features: [], + }, + }; render(, { - organization, + organization: { + ...organization, + features: ['trigger-autofix-on-issue-summary'], + }, + }); + await waitFor(() => { + expect(screen.getByText('Unleash Automation')).toBeInTheDocument(); }); - expect(screen.getByText('Unleash Automation')).toBeInTheDocument(); - expect(screen.getByText('Enable Automation')).toBeInTheDocument(); }); it('does not show automation step if automation is not allowed', () => { + MockApiClient.addMockResponse({ + method: 'GET', + url: `/projects/${organization.slug}/${ProjectFixture().slug}/`, + body: { + autofixAutomationTuning: 'off', + }, + }); const project = { ...ProjectFixture(), - autofixAutomationTuning: 'off' as const, organization: { ...ProjectFixture().organization, features: [], @@ -79,6 +102,13 @@ describe('SeerNotices', function () { }); it('shows fixability view step if automation is allowed and view not starred', () => { + MockApiClient.addMockResponse({ + method: 'GET', + url: `/projects/${organization.slug}/${ProjectFixture().slug}/`, + body: { + autofixAutomationTuning: 'medium', + }, + }); const project = getProjectWithAutomation('high'); render(, { organization: { @@ -91,6 +121,13 @@ describe('SeerNotices', function () { }); it('does not render guided steps if all onboarding steps are complete', () => { + MockApiClient.addMockResponse({ + method: 'GET', + url: `/projects/${organization.slug}/${ProjectFixture().slug}/`, + body: { + autofixAutomationTuning: 'medium', + }, + }); MockApiClient.addMockResponse({ url: `/organizations/${organization.slug}/group-search-views/starred/`, body: [ @@ -105,7 +142,7 @@ describe('SeerNotices', function () { ...{ organization: { ...organization, - features: [], + features: ['trigger-autofix-on-issue-summary'], }, }, }); diff --git a/static/app/views/issueDetails/streamline/sidebar/seerNotices.tsx b/static/app/views/issueDetails/streamline/sidebar/seerNotices.tsx index c0920940d786d0..66ea21fbb12613 100644 --- a/static/app/views/issueDetails/streamline/sidebar/seerNotices.tsx +++ b/static/app/views/issueDetails/streamline/sidebar/seerNotices.tsx @@ -25,6 +25,7 @@ import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Project} from 'sentry/types/project'; import {FieldKey} from 'sentry/utils/fields'; +import {useDetailedProject} from 'sentry/utils/useDetailedProject'; import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; import useOrganization from 'sentry/utils/useOrganization'; import {useCreateGroupSearchView} from 'sentry/views/issueList/mutations/useCreateGroupSearchView'; @@ -62,6 +63,10 @@ export function SeerNotices({groupId, hasGithubIntegration, project}: SeerNotice addErrorMessage(t('Failed to create view')); }, }); + const detailedProject = useDetailedProject({ + orgSlug: organization.slug, + projectSlug: project.slug, + }); const isAutomationAllowed = organization.features.includes( 'trigger-autofix-on-issue-summary' @@ -85,8 +90,9 @@ export function SeerNotices({groupId, hasGithubIntegration, project}: SeerNotice !codeMappingRepos?.length && !isLoadingPreferences; const needsAutomation = - (project.autofixAutomationTuning === 'off' || - project.autofixAutomationTuning === undefined) && + detailedProject?.data && + (detailedProject?.data?.autofixAutomationTuning === 'off' || + detailedProject?.data?.autofixAutomationTuning === undefined) && isAutomationAllowed; const needsFixabilityView = !views.some(view => view.query.includes(FieldKey.ISSUE_SEER_ACTIONABILITY)) &&