community-platform icon indicating copy to clipboard operation
community-platform copied to clipboard

feat: add guard clause to capitalizeFirstLetter

Open benfurber opened this issue 3 months ago • 6 comments

PR Checklist

PR Type

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Developer experience (improves developer workflows for contributing to the project)

Description

Somehow an entirely empty how-to got it's way into the database. That caused the main how-to page to entirely crash for admins who could see the post (even though it wasn't published for everyone else).

benfurber avatar Apr 06 '24 13:04 benfurber

Codecov Report

Attention: Patch coverage is 75.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 66.65%. Comparing base (1f7fc1d) to head (9605ed0). Report is 4 commits behind head on master.

Files Patch % Lines
src/pages/Howto/Content/HowtoList/HowToCard.tsx 0.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3429      +/-   ##
==========================================
- Coverage   66.65%   66.65%   -0.01%     
==========================================
  Files         427      427              
  Lines       13464    13466       +2     
  Branches     2429     2431       +2     
==========================================
+ Hits         8975     8976       +1     
- Misses       4443     4444       +1     
  Partials       46       46              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 06 '24 14:04 codecov[bot]

2 flaky tests on run #5478 ↗︎

0 90 1 0 Flakiness 2

Details:

Merge branch 'master' into fix/how-to-string-util
Project: onearmy-community-platform Commit: 9605ed079e
Status: Passed Duration: 04:40 💡
Started: Apr 30, 2024 12:33 PM Ended: Apr 30, 2024 12:37 PM
Flakiness  howto/write.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
[How To] > [Create a how-to] > [By Authenticated] Test Replay Screenshots Video
Flakiness  profile.spec.ts • 1 flaky test • ci-chrome

View Output Video

Test Artifacts
[Profile] > [By User] > [Can contact profiles by default] Test Replay Screenshots Video

Review all test suite changes for PR #3429 ↗︎

cypress[bot] avatar Apr 06 '24 14:04 cypress[bot]

hmm ideally there should be a conditional when calling the method capitalizeFirstLetter(word || '') as it already only accepts string, not undefined or null. Improving our usage of typescript should help with this kind of bugs.

mariojsnunes avatar Apr 06 '24 14:04 mariojsnunes

@mariojsnunes Have added. How-to's shouldn't have an empty title though, I'd say it's typed correctly otherwise everything would have to be optional?

benfurber avatar Apr 06 '24 14:04 benfurber

Sorry I wasn't clear. I meant to say that your first changes shouldn't be necessary, because capitalizeFirstLetter only accepts a string already, not null/undefined. The root cause is likely somewhere higher up where an assignment to howto.title is undefined.

But this could be merged if urgent.

mariojsnunes avatar Apr 06 '24 16:04 mariojsnunes

@mariojsnunes Oh I understand now. Yes, makes sense and I agree. Not urgent now as I also dealt with the bad data too.

benfurber avatar Apr 08 '24 08:04 benfurber

I had been leaving this open to remind myself to do the bigger fix but I need it now to trigger a release candidate(!) so going to merge it in.

benfurber avatar Apr 30 '24 12:04 benfurber

:tada: This PR is included in version 1.176.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

onearmy-bot avatar Apr 30 '24 13:04 onearmy-bot