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

fix: check length on empty array for list price #1211

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

brobro10000
Copy link
Member

Update check on returned list price length to correctly go into the fallback check for price.

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)
  • Ensure English strings are marked for translation. See documentation for more details.

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.41%. Comparing base (b3c1e56) to head (f34670a).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1211   +/-   ##
=======================================
  Coverage   88.41%   88.41%           
=======================================
  Files         399      399           
  Lines        8501     8501           
  Branches     2088     2094    +6     
=======================================
  Hits         7516     7516           
+ Misses        943      942    -1     
- Partials       42       43    +1     

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

Comment on lines -1747 to +1758
useCourseMetadata.mockReturnValue({ data: updatedListPrice || getCoursePrice(updatedCourseMetadata) });
useCourseMetadata.mockReturnValue(
{ data: updatedListPrice.length > 0 ? updatedListPrice : getCoursePrice(updatedCourseMetadata) },
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this missing a sub-key under the data top-level key? When we call useCourseMetdata, it doesn't normally just plop down the price as a value to the data key, does it?

Copy link
Member Author

@brobro10000 brobro10000 Oct 21, 2024

Choose a reason for hiding this comment

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

In this case it does because of how useCourseListPrice utilizes the select within the useCourseMetadata arguments. It passes in the data from the transformed useCourseMetadata return value to resolve within getCoursePrice or the listPrice (acting as a no-op on the original course metadata)

export function useCourseListPrice() {
  const { data: { listPrice } } = useCourseRedemptionEligibility();
  const resolveListPrice = ({ transformed }) => listPrice || getCoursePrice(transformed);
  return useCourseMetadata({
    select: resolveListPrice,
  });
}

@brobro10000 brobro10000 merged commit 01091da into master Oct 21, 2024
6 checks passed
@brobro10000 brobro10000 deleted the hu/ent-bugfix-price branch October 21, 2024 19:13
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.

3 participants