-
Notifications
You must be signed in to change notification settings - Fork 17
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
Create a components selector that fetches components by head commit of a branch #2452
Create a components selector that fetches components by head commit of a branch #2452
Conversation
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.
In this review, I've identified significant concerns in both implementation and design. Many points are related to maintaining statically-typed nature of your codebase. There are a few places where any type was used, which should be avoided when TypeScript is being used. In addition, several ts-expect-error
directives were used either due to lacking type definitions or to suppress type warnings, and a use of undefined
under UseBranchComponentsArgs
. While it might seem convenient to suppress TypeScript's type checking or to use any
or undefined
, these practices may disguise bugs or other issues for the static type-checker and lead to maintenance difficulties later on.
jest.mock('../../summaryHooks') | ||
|
||
const mockedUseFlags = useFlags as jest.Mock<{ componentsSelect: boolean }> | ||
const mockedUseSummary = useSummary as jest.Mock<any> |
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 'useSummary' hook is mocked globally for all tests with the option to modify it per test case. It's possible for the return values of these mock functions to be inadvertently carried into other tests, causing them to rely on each other’s state and affect their execution. Consider avoiding the global mocking or investigate strategies to isolate the test cases.
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.
I did this to avoid defining and writing out all attributes with their types and subtypes since we only care about one attribute in this case.
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Outdated
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
@@ -46,7 +46,7 @@ interface UseBranchComponentsArgs { | |||
provider: string | |||
owner: string | |||
repo: string | |||
branch: string | |||
branch: string | undefined |
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.
It is always recommended to avoid types such as undefined
in TypeScript. It tends to invite a number of runtime type errors.
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.
Can you swap this to branch?: string
to make it optional over using undefined
directly
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2452 +/- ##
=======================================
Coverage 98.09% 98.10%
=======================================
Files 767 768 +1
Lines 9786 9819 +33
Branches 2479 2486 +7
=======================================
+ Hits 9600 9633 +33
Misses 184 184
Partials 2 2
Continue to review full report in Codecov by Sentry.
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2452 +/- ##
=======================================
+ Coverage 98.10 98.11 +0.01
=======================================
Files 767 768 +1
Lines 9786 9819 +33
Branches 2460 2491 +31
=======================================
+ Hits 9600 9633 +33
Misses 184 184
Partials 2 2
Continue to review full report in Codecov by Sentry.
|
Codecov Report
@@ Coverage Diff @@
## main #2452 +/- ##
=======================================
Coverage 98.09% 98.10%
=======================================
Files 767 768 +1
Lines 9786 9819 +33
Branches 2474 2440 -34
=======================================
+ Hits 9600 9633 +33
Misses 184 184
Partials 2 2
Continue to review full report in Codecov by Sentry.
|
✅ Deploy Preview for gazebo-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Few quick things to peak at 👀
jest.mock('../../summaryHooks') | ||
|
||
const mockedUseFlags = useFlags as jest.Mock<{ componentsSelect: boolean }> | ||
const mockedUseSummary = useSummary as jest.Mock<any> |
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.
Wondering about the justification for mocking out this hook, over using msw? We typically want to avoid this so we have a deeper integration test, as well if any changes are ever made to useSummary
that break the functionality we won't pick it up.
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.
My initial thoughts were mocking all the hooks within useSummary()
would have been overkill, but I agree with your point about not picking up changes to useSummary
. Updated.
@@ -46,7 +46,7 @@ interface UseBranchComponentsArgs { | |||
provider: string | |||
owner: string | |||
repo: string | |||
branch: string | |||
branch: string | undefined |
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.
Can you swap this to branch?: string
to make it optional over using undefined
directly
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.
CodecovAI submitted a new review for e06c7b4
@@ -46,7 +46,7 @@ interface UseBranchComponentsArgs { | |||
provider: string | |||
owner: string | |||
repo: string | |||
branch: string | |||
branch?: string | |||
filters?: { |
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.
If possible, you should refrain from making optional arguments that could have default values. Here 'branch' being undefined might lead to errors.
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.
Oh yea sorry I missed this, branch is a non-nullable graphql string argument and is required to be passed at all times even if it's just an empty string.
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
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.
CodecovAI submitted a new review for e4b9ada
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.tsx
Show resolved
Hide resolved
e4b9ada
to
4a24df2
Compare
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.
CodecovAI submitted a new review for 4a24df2
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
src/pages/RepoPage/CoverageTab/subroute/Fileviewer/ComponentsSelectCommit.spec.tsx
Show resolved
Hide resolved
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.
Looks all good to me 👍
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Description
Part 1 of a multi-phase change to add the components selector to the file viewer on the coverage tab. In this PR, the selector component is created. It fetches components from the head commit of a given branch and supports filtering. Note that the selector itself is not being used as of yet. This will be addressed in a follow up PR with changes to
Fileviewer
and related files. This PR addresses codecov/engineering-team#832.Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.