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

chore: Migrate updateProfile to ts #3607

Merged
merged 10 commits into from
Jan 2, 2025
Merged

chore: Migrate updateProfile to ts #3607

merged 10 commits into from
Jan 2, 2025

Conversation

suejung-sentry
Copy link
Contributor

@suejung-sentry suejung-sentry commented Dec 23, 2024

Adds zod schema validation to the hook to close out the TS migration work for this hook. Note that I was getting mixed results with the api on what fields are null or undefined so any users of this hook (just the 1 place to update profile) should assume the api contract unreliable and handle if field is undefined.
Also did end to end testing in local (against staging api)

Closes codecov/engineering-team#2861

@codecov-staging
Copy link

codecov-staging bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/user/useUpdateProfile.ts 88.88% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3607      +/-   ##
==========================================
- Coverage   98.99%   98.98%   -0.01%     
==========================================
  Files         810      810              
  Lines       14556    14562       +6     
  Branches     4147     4148       +1     
==========================================
+ Hits        14409    14414       +5     
- Misses        140      141       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
src/services/user/useUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 94.44% <88.88%> (-5.56%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.72% <ø> (ø)
Services 99.33% <90.90%> (-0.04%) ⬇️
Shared 99.37% <ø> (ø)
UI 99.14% <ø> (ø)

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 ecdafdb...db6d0b6. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.98%. Comparing base (ecdafdb) to head (db6d0b6).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/user/useUpdateProfile.ts 88.88% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3607      +/-   ##
==========================================
- Coverage   98.99%   98.98%   -0.01%     
==========================================
  Files         810      810              
  Lines       14556    14562       +6     
  Branches     4147     4141       -6     
==========================================
+ Hits        14409    14414       +5     
- Misses        140      141       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
src/services/user/useUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 94.44% <88.88%> (-5.56%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.72% <ø> (ø)
Services 99.33% <90.90%> (-0.04%) ⬇️
Shared 99.37% <ø> (ø)
UI 99.14% <ø> (ø)

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 ecdafdb...db6d0b6. Read the comment docs.

Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.98%. Comparing base (ecdafdb) to head (db6d0b6).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/user/useUpdateProfile.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3607      +/-   ##
==========================================
- Coverage   98.99%   98.98%   -0.01%     
==========================================
  Files         810      810              
  Lines       14556    14562       +6     
  Branches     4140     4141       +1     
==========================================
+ Hits        14409    14414       +5     
- Misses        140      141       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
src/services/user/useUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 94.44% <88.88%> (-5.56%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.72% <ø> (ø)
Services 99.33% <90.90%> (-0.04%) ⬇️
Shared 99.37% <ø> (ø)
UI 99.14% <ø> (ø)

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 ecdafdb...db6d0b6. Read the comment docs.

Copy link

codecov-public-qa bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.98%. Comparing base (ecdafdb) to head (db6d0b6).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/services/user/useUpdateProfile.ts 88.88% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #3607      +/-   ##
==========================================
- Coverage   98.99%   98.98%   -0.01%     
==========================================
  Files         810      810              
  Lines       14556    14562       +6     
  Branches     4140     4148       +8     
==========================================
+ Hits        14409    14414       +5     
- Misses        140      141       +1     
  Partials        7        7              
Files with missing lines Coverage Δ
src/services/user/useUser.ts 100.00% <100.00%> (ø)
src/services/user/useUpdateProfile.ts 94.44% <88.88%> (-5.56%) ⬇️
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.72% <ø> (ø)
Services 99.33% <90.90%> (-0.04%) ⬇️
Shared 99.37% <ø> (ø)
UI 99.14% <ø> (ø)

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 ecdafdb...db6d0b6. Read the comment docs.

@codecov-staging
Copy link

codecov-staging bot commented Jan 2, 2025

Bundle Report

Changes will increase total bundle size by 1.79kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 6.06MB 915 bytes (0.02%) ⬆️
gazebo-staging-system 6.0MB 878 bytes (0.01%) ⬆️

Copy link

codecov bot commented Jan 2, 2025

Bundle Report

Changes will increase total bundle size by 1.79kB (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 6.0MB 878 bytes (0.01%) ⬆️
gazebo-production-system-esm 6.06MB 915 bytes (0.02%) ⬆️

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Jan 2, 2025

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
2eecb38 Thu, 02 Jan 2025 06:10:52 GMT Expired Expired
7cbf5b2 Thu, 02 Jan 2025 06:19:48 GMT Expired Expired
a72cd15 Thu, 02 Jan 2025 16:44:57 GMT Expired Expired
8d47ccd Thu, 02 Jan 2025 16:59:59 GMT Expired Expired
8cba744 Thu, 02 Jan 2025 18:37:32 GMT Expired Expired
db6d0b6 Thu, 02 Jan 2025 19:05:10 GMT Cloud Enterprise

@suejung-sentry suejung-sentry marked this pull request as ready for review January 2, 2025 06:13
@@ -50,9 +50,13 @@ describe('useUpdateProfile', () => {
server.use(
graphql.mutation('UpdateProfile', (info) => {
const newUser = {
...user,
name: info.variables.input.name,
email: info.variables.input.email,
Copy link
Contributor Author

@suejung-sentry suejung-sentry Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the existing mocks didn't match the current shape of response so updated

])
)

const CurrentUserFragment = z.object({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we export this from useUser and just use one?

Looks like some of the values there are non nullish which match the api (ex: onboardingCompleted)

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 get what you mean, the duplication is not great. Unfortunately I feel like unless we share the graphQL query/fragment across both hooks too, we should keep the response zod schema validations independent so the given hook's paired query + response validation zod doesn't diverge. For example, termsAgreement is part of the useUser query but omitted here (perhaps that's its own oversight) so can't share a zod schema validation that includes that field.

Re: non-nullish - yeah, on that one I left it loose for the client to handle these values being undefined (and less trust in the api). I made it a bit stricter now to match that in useUser, and updated the test mocks too.

@suejung-sentry suejung-sentry added this pull request to the merge queue Jan 2, 2025
Merged via the queue into main with commit 78d2b2a Jan 2, 2025
50 of 62 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jan 2, 2025
@suejung-sentry suejung-sentry deleted the sshin/2861 branch January 2, 2025 20:37
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.

update profile
3 participants