-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(autofix): Fix draft PR button not using settings repos #88167
Conversation
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Pull request was converted to draft
f6cd236
to
6710b8f
Compare
7e85bbc
to
309a871
Compare
mockButton.mockClear(); | ||
jest.mocked(useAutofixRepos).mockReset(); | ||
jest.mocked(useAutofixData).mockReset(); | ||
jest.mocked(useAutofixRepos).mockReturnValue({ | ||
repos: [], | ||
codebases: {}, | ||
}); | ||
jest.mocked(useAutofixData).mockReturnValue({ | ||
data: { | ||
request: { | ||
repos: [], | ||
}, | ||
codebases: {}, | ||
created_at: '2024-01-01T00:00:00Z', | ||
run_id: '456', | ||
status: AutofixStatus.COMPLETED, | ||
}, | ||
isPending: false, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it better to mock API responses rather than hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm i remember why I did it this way, the mock api response doesn't work because useAutofixData
is enabled:false
and only fetches from cache, mocking that would be difficult
jest.mocked(useAutofixRepos).mockReset(); | ||
jest.mocked(useAutofixRepos).mockReturnValue({ | ||
repos: [], | ||
codebases: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same thing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, I couldn't get it to use the mocked api response through useAutofixData
, and mocking useAutofixData
directly, useAutofixRepos
wouldn't use the internal representation for some reason...
@@ -474,6 +473,8 @@ function AutofixSolutionDisplay({ | |||
const containerRef = useRef<HTMLDivElement>(null); | |||
const iconFixRef = useRef<HTMLDivElement>(null); | |||
|
|||
const changesDisabled = repos.every(repo => repo.is_readable === false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be disabled if any repo is not accessible? (I can see an argument both ways I guess, so up to you)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have the case for example, that the fix is in seer, but you have the sentry repo leftover as context that isn't readable...ideally we can just pinpoint which repos the solution is in to make this condition better.
I should also update the guard message here to make it more clear...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the solution timeline does include relevant repo names in its payload, so we could use that, but might not be reliable and might not work with human instructions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah right now it's inconsistent, we should update the solution formatter to output repo names/ids for each step, for now I guess this should be sufficient
return ( | ||
<AnimatePresence initial={props.isSolutionFirstAppearance}> | ||
<AnimationWrapper key="card" {...cardAnimationProps}> | ||
<AutofixSolutionDisplay {...props} changesDisabled={changesDisabled} /> | ||
<AutofixSolutionDisplay {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are you doing with changesDisabled
if not passing it here? is it an unused var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above code for changesDisabled
is inside AutofixSolutionDisplay
autofixRepositories, | ||
hasGithubIntegration, | ||
}: SeerNoticesProps) { | ||
export function SeerNotices({groupId, hasGithubIntegration}: SeerNoticesProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a notice for the case where (you have no repos in settings AND no repos from code mappings AND you do have the github integration)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call out, I'll do that in a follow up PR where I do the flow for onboarding the repo settings
e57056f
to
ed6c6e3
Compare
Fixes all uses of repository access to use a new `useAutofixRepos` hook that uses the codebases and repos list from the autofix state instead of using code mappings also removes references to code mappings in set up instructions and notices! 
Fixes all uses of repository access to use a new
useAutofixRepos
hook that uses the codebases and repos list from the autofix state instead of using code mappingsalso removes references to code mappings in set up instructions and notices!