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

[PM-16667] Followup clarifying work #12665

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[PM-16667] Followup clarifying work #12665

wants to merge 3 commits into from

Conversation

jprusik
Copy link
Contributor

@jprusik jprusik commented Jan 2, 2025

🎟️ Tracking

PM-16667

📔 Objective

  • Followup work/cleanup from [PM-16667] Fix flaky card expiry tests #12659
  • remove ts-strict-ignore and make necessary changes
  • In [PM-16667] Fix flaky card expiry tests #12659 we introduced a new codepath where we return true if the month is not provided/invalid, and the year is the current year. However, isCardExpired is meant to return false in uncertain cases (put another way, we're asking "is the card definitely expired?"). The outcome of this change is that the expiration notice/banner would have appeared if the user specified the current year in their card expiry but no month. After these changes, the banner will not appear in this case.

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

["0", `${currentYear}`, true], // invalid month
["0", `${currentYear}`, false], // invalid month
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated test expectation to match consistency changes for uncertain cases

@jprusik jprusik marked this pull request as ready for review January 2, 2025 20:37
@jprusik jprusik requested a review from a team as a code owner January 2, 2025 20:37
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Logo
Checkmarx One – Scan Summary & Details96c700e6-4c5d-4317-983a-ddf7538d8916

No New Or Fixed Issues Found

@@ -53,7 +51,7 @@ export function normalizeExpiryYearFormat(yearInput: string | number): Year | nu

/**
* Takes a cipher card view and returns "true" if the month and year affirmativey indicate
* the card is expired.
* the card is expired. Uncertain cases return "false".
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ I usually use ticks to indicate literal values instead of strings to avoid confusion.

Suggested change
* the card is expired. Uncertain cases return "false".
* the card is expired. Uncertain cases return `false`.

Comment on lines 68 to +69
const normalizedYear = normalizeExpiryYearFormat(expYear);
const parsedYear = parseInt(normalizedYear, 10);
const parsedYear = normalizedYear ? parseInt(normalizedYear, 10) : NaN;
Copy link
Member

Choose a reason for hiding this comment

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

🎨 Consider using nullish resolution (??) instead of a ternary if normalizeExpiryYearFormat returns undefined or null. If it returns a false value consider using a lazy or (||). If it returns a falsy value (e.g. 0) then test for the value directly.

Comment on lines +88 to +90
// If the parsed month value is 0, we don't know when the expiry passes this year, so do not treat it as expired
if (!parsedMonthIsValid) {
return false;
Copy link
Member

@audreyality audreyality Jan 2, 2025

Choose a reason for hiding this comment

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

👍🏻 Thank you for addressing my feedback from the other review!

}

const normalizedParsedYear = normalizeExpiryYearFormat(parsedYear);
const normalizedParsedYear = parsedYear ? normalizeExpiryYearFormat(parsedYear) : null;
Copy link
Member

Choose a reason for hiding this comment

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

⛏️ Fun fact! null should be avoided where you don't need to distinguish it from undefined.

💭 My fun facts are not very fun.

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 88.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 33.73%. Comparing base (af4311f) to head (85c2b1d).
Report is 12 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
libs/common/src/autofill/utils.ts 88.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12665      +/-   ##
==========================================
- Coverage   33.74%   33.73%   -0.01%     
==========================================
  Files        2918     2918              
  Lines       90911    90920       +9     
  Branches    17180    17187       +7     
==========================================
- Hits        30677    30676       -1     
- Misses      57841    57848       +7     
- Partials     2393     2396       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jprusik jprusik added the needs-qa Marks a PR as requiring QA approval label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-qa Marks a PR as requiring QA approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants