Show PL Program Info Page even without Programs Offered#49421
Conversation
| // If no current workshops for a course | ||
| if ( | ||
| partnerInfo.pl_programs_offered.includes(collection.key) | ||
| ) { |
There was a problem hiding this comment.
This .includes(...) was where the error was previously being thrown since pl_programs_offered was null
There was a problem hiding this comment.
Wait, why would this run if pl_programs_offered is null? We're in a
appState !== WorkshopApplicationStates.now_closed &&
partnerInfo.pl_programs_offered
condition.
And if it is run, should we use optional chaining? I.e. partnerInfo.pl_programs_offered?.includes()
There was a problem hiding this comment.
Ahh, I see –– you added that conditional up top
There was a problem hiding this comment.
It should not run if it's null, it was previously throwing an error calling "includes" on a null object. What is optional chaining?
There was a problem hiding this comment.
Okay sorry –– should've waited until I fully understood the logic.
There was a problem hiding this comment.
No worries at all :)
There was a problem hiding this comment.
Thanks for addressing this! I have a questions and some ideas for refactors:
- Should
pl_programs_offeredorsummer_workshopsdictate what gets shown? We're using both here in different places and I don't understand why. It looks likepl_programs_offeredrelies on the RP correctly filling out their info on their Regional Partner page, whereassummer_workshopswe get by querying our workshops. I'm not sure what we should rely on (and it might be a product question). - We have conditional logic in both
workshopCollectionsandpartnerInfo–– for readability, can you consolidate this logic so that it lives in one place? This is related to the attributes named in (1). - I should've caught this the first time, but I'm reading the
workshopCollectionsand am getting confused by the information it contains. Could you consider renaming some things:workshopCollections,collections, andkeyaren't helping me figure out what information lives here. - I think some of the logic here could be consolidated and/or simplified by using Optional Chaining. Instead of
partnerInfo && partnerInfo.summer_workshops.filter()
It could bepartnerInfo?.summer_workshops?.filter()which covers BOTH ifpartnerInfois nil and ifsummer_workshopsis nil. Another option is to set some default values so that you don't need to keep checking these. - I made a test file recently to ensure the
StartApplicationButtonwas showing at the right times. I don't think you need to add tests for everything in this whole file (although that would be great!), but since the test file now exists, could you add unit tests for the logic you've added recently? - How urgent is this? I'm in favor of simplifying the logic and adding tests so we can avoid future needs for quick-fixes, but if we're getting lots of reports on this, I can be swayed towards something else.
|
@dmcavoy could you chime in on questions 1 and 5 above? |
Thank you so much for all the feedback! Yes I will get on these changes! I don't think this is that urgent so I can start refactoring and cleaning up! |
So we need both to make the decisions. No Programs offered -> Hide the area since this probably means the regional partner details have not been set yet. Does that help? |
|
For #5 I think just adding tests for the new things that are being added makes sense. |
Got it, thanks! Sounds good. Turner, since both are being used, I think it'd be most readable to access these values using similar logic (either by setting both in the collections object, or accessing them directly using the regionalPartnerInfo prop). |
| heading: `${ActiveCourseWorkshops[courseKey]} Workshops`, | ||
| isOffered: partnerInfo?.pl_programs_offered?.includes(courseKey), | ||
| summerWorkshops: partnerInfo?.summer_workshops?.filter( | ||
| workshop => workshop.course === ActiveCourseWorkshops[courseKey] |
There was a problem hiding this comment.
LOVE this structure using ActiveCourseWorkshops to push!
| workshop_date_range_string: 'Test CSD workshop dates', | ||
| location_name: 'Test CSD workshop location', | ||
| location_address: 'Test CSD workshop address' | ||
| }; |
| }); | ||
| it('shows Not Offering note on workshop card(s) for the program(s) not being offered when other programs are offered', () => { | ||
| createServerResponses(server, true, false, OFFERED_PROGRAMS, [ | ||
| OFFERED_WORKSHOP |
There was a problem hiding this comment.
This is great! And serves as documentation on how we expect data coming in from the backend to look
megcrenshaw
left a comment
There was a problem hiding this comment.
This looks amazing! Nice work –– lots of weird cases to catch, and the tests document them beautifully.
…)" This reverts commit 3f42d05.
A bug on the Professional Learning Program Information page was discovered where no information was being shown for regional partners not offering a program at that time (which was throwing an error in console). It's a bug from this PR where it would try to load the workshop cards but not find any programs offered.
This PR just adds a check to make sure there are programs before trying to render cards for them. If there are no programs offered, it will just show the rest of the information without the workshop cards.
Bug behavior for no programs offered
With fix behavior for no programs offered
Links
Slack thread this was brought up: here
Testing story
Local testing.
PR Checklist: