Skip to content

Conversation

@zehata
Copy link
Contributor

@zehata zehata commented Jan 1, 2026

  • Fixed TA modules cannot be deselected if they are the only one or the last one of their type

Context

Resolves #4280 . As reported by quite a number of users starting at https://t.me/NUSMods/13309 , my implementation in #4225 causes the behavior to be different from the original specification: the last lesson of a lesson type cannot be removed for a TA module.

Implementation

  • Modified the logic to allow any lessons to be removed as long as there is at least 1 left in the module
  • Refactored the logic into a util for more convenient testing
  • Added tests for the intended behavior of the timetable hydration logic

Lessons that are the only one of their lesson type can now be deselected

only_lesson

Lessons that are the last one of their module cannot be deselected

last_lesson_of_module

Lessons in non-TA modules are not affected by this change

non_ta_modules

Other Information

- Fixed TA modules cannot be deselected if they are the only one or the last one of their type
@vercel
Copy link

vercel bot commented Jan 1, 2026

@zehata is attempting to deploy a commit to the modsbot's projects Team on Vercel.

A member of the Team first needs to authorize it.

@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 80.85106% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.00%. Comparing base (988c6fd) to head (28cea77).
⚠️ Report is 163 commits behind head on master.

Files with missing lines Patch % Lines
website/src/views/timetable/TimetableContent.tsx 10.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4279      +/-   ##
==========================================
+ Coverage   54.52%   57.00%   +2.47%     
==========================================
  Files         274      297      +23     
  Lines        6076     6933     +857     
  Branches     1455     1674     +219     
==========================================
+ Hits         3313     3952     +639     
- Misses       2763     2981     +218     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zehata zehata changed the title Patched last TA module behavior Fix last TA module of a lesson type cannot be removed Jan 3, 2026
@vercel
Copy link

vercel bot commented Jan 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nusmods-export Ready Ready Preview, Comment Jan 6, 2026 2:29am
nusmods-website Ready Ready Preview, Comment Jan 6, 2026 2:29am

@zehata
Copy link
Contributor Author

zehata commented Jan 3, 2026

@leslieyip02 Btw, while writing this patch, I realized that there is some refactoring that should be done, but it might be better to do it together with changing TimetableContent to a functional component.

Specifically, currently I am passing a lot of parameters to the getInteractableLessons and hydrateInteractability functions, and I think it would be better to refactor these props as an interface instead

Something I would like to ask for help for is to check if the test cases I wrote for getInteractableLessons is missing any test cases.

Copy link
Member

@leslieyip02 leslieyip02 left a comment

Choose a reason for hiding this comment

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

The deployment preview seems to work fine. Should be good once we add a few more test cases.

Regarding the refactor, I'll leave it up to you but I think it's not too urgent right now.

@zehata
Copy link
Contributor Author

zehata commented Jan 3, 2026

@leslieyip02 Thanks! I will work on fixing the regression and test cases so we can push the fix out to users first. The refactor will come later.

zehata

This comment was marked as resolved.

Copy link
Contributor Author

@zehata zehata left a comment

Choose a reason for hiding this comment

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

While reading your comment
#4279 (comment) I realized that I really should be writing these test in the conditional style instead, so I basically rewrote the entire test. There will be quite a lot of new things to review, sorry about that.

@zehata zehata requested a review from leslieyip02 January 4, 2026 04:45
@zehata
Copy link
Contributor Author

zehata commented Jan 5, 2026

@leslieyip02 I forgot to mention, while writing the tests, I realized we don't have a sample module similar to CG1111A where there are modules with multiple classNos, and each classNo has multiple lessons.

I don't think it's urgent, so I think will add that on once this patch is out.

Copy link
Member

@leslieyip02 leslieyip02 left a comment

Choose a reason for hiding this comment

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

LGTM.

@leslieyip02 leslieyip02 merged commit a7dd837 into nusmodifications:master Jan 6, 2026
6 checks passed
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.

Cannot remove unneeded classes from timetable in TA mode

2 participants