Skip to content

Simplify soft assertion example and narrative #2

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

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

Conversation

Guillaume-Docquier
Copy link
Contributor

@Guillaume-Docquier Guillaume-Docquier commented Apr 29, 2025

Problem

When doing the exercise on soft assertions, I found it confusing how to correct the source code, because there were multiple bugs and it wasn't clear what the solution wanted us to do.

The bugs were:

  • monthly subscriptions were not handled properly
  • yearly subscriptions were not handled at all

Also, the solution was a bit overcomplicated (setUTCMonth handles year changes, i.e you can do today.setUTCMonth(20) to set it to 20 months after the first day of that year), which I think brings the attention away from vitest and soft assertions

Proposed solution

Let's simplify the logic so that the bug is a bit more straightforward to fix:

  • monthly subscriptions are handled properly, but not yearly subscriptions
  • change the test system date so that the test fails because of the endAt property

Going further

Maybe we'd want a test for the TrialPlan to guide the students further / provide more context?

…e, there was a bug in the monthly subscriptions and we didn't handle yearly subscriptions. Now, the bug is simply that we handle monthly subscriptions, but not yearly subscriptions.
today.setUTCMonth(today.getUTCMonth() + 1, 1)
break;
case "yearly":
today.setUTCFullYear(today.getUTCFullYear() + 1, 0, 1)
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate the realism here but the subscription logic is largely irrelevant for the exercise. For example, it might as well be that in this app the yearly subscription still expires on the first day of the next month once you cancel it, and you get refunded the unused credits. That doesn't really matter.

But what I want to try to do with your feedback is make the actions of the exercise more streamlined. Thinking about that...

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