Skip to content
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

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

rohitvinnakota-codecov
Copy link
Contributor

@rohitvinnakota-codecov rohitvinnakota-codecov commented Dec 12, 2023

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.

Copy link

@codecov codecov bot left a 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>
Copy link

@codecov codecov bot Dec 12, 2023

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.

Copy link
Contributor Author

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.

@@ -46,7 +46,7 @@ interface UseBranchComponentsArgs {
provider: string
owner: string
repo: string
branch: string
branch: string | undefined
Copy link

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.

Copy link
Contributor

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

@codecov-qa
Copy link

codecov-qa bot commented Dec 12, 2023

Codecov Report

Merging #2452 (6623477) into main (aa54260) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           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           
Files Coverage Δ
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <ø> (ø)
Shared 99.81% <ø> (ø)
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...6623477. Read the comment docs.

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Merging #2452 (6623477) into main (aa54260) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           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             
Files Coverage Δ
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <ø> (ø)
Shared 99.81% <ø> (ø)
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...6623477. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 12, 2023

Codecov Report

Merging #2452 (6623477) into main (aa54260) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           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           
Files Coverage Δ
...Tab/subroute/Fileviewer/ComponentsSelectCommit.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 59.37% <ø> (ø)
Layouts 97.30% <ø> (ø)
Pages 98.96% <100.00%> (+<0.01%) ⬆️
Services 99.44% <ø> (ø)
Shared 99.81% <ø> (ø)
UI 94.32% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa54260...6623477. Read the comment docs.

Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for gazebo-staging ready!

Name Link
🔨 Latest commit 6623477
🔍 Latest deploy log https://app.netlify.com/sites/gazebo-staging/deploys/6579c9b5cbf87a0008dc507b
😎 Deploy Preview https://deploy-preview-2452--gazebo-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rohitvinnakota-codecov rohitvinnakota-codecov marked this pull request as ready for review December 12, 2023 17:06
@rohitvinnakota-codecov rohitvinnakota-codecov changed the title Create a components selector that fetches components by head commit Create a components selector that fetches components by head commit of a branch Dec 12, 2023
Copy link
Contributor

@nicholas-codecov nicholas-codecov left a 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>
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link

@codecov codecov bot left a 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?: {
Copy link

@codecov codecov bot Dec 12, 2023

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.

Copy link
Contributor

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.

Copy link

@codecov codecov bot left a 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

Copy link

@codecov codecov bot left a 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

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a 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 👍

@rohitvinnakota-codecov rohitvinnakota-codecov merged commit 218e142 into main Dec 13, 2023
50 checks passed
@rohitvinnakota-codecov rohitvinnakota-codecov deleted the rvinnakota-components-file-viewer branch December 13, 2023 15:18
Copy link

sentry-io bot commented Dec 17, 2023

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ React ErrorBoundary TypeError: Failed to fetch graphql(shared/api/api) View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants