Skip to content

Show PL Program Info Page even without Programs Offered#49421

Merged
TurnerRiley merged 6 commits into
stagingfrom
show-RP-info-without-programs
Dec 15, 2022
Merged

Show PL Program Info Page even without Programs Offered#49421
TurnerRiley merged 6 commits into
stagingfrom
show-RP-info-without-programs

Conversation

@TurnerRiley

@TurnerRiley TurnerRiley commented Dec 9, 2022

Copy link
Copy Markdown
Contributor

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

Original not show PR info

With fix behavior for no programs offered

Show RP info

Links

Slack thread this was brought up: here

Testing story

Local testing.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

// If no current workshops for a course
if (
partnerInfo.pl_programs_offered.includes(collection.key)
) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This .includes(...) was where the error was previously being thrown since pl_programs_offered was null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for pointing this out

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ahh, I see –– you added that conditional up top

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should not run if it's null, it was previously throwing an error calling "includes" on a null object. What is optional chaining?

@megcrenshaw megcrenshaw Dec 9, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Okay sorry –– should've waited until I fully understood the logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No worries at all :)

@TurnerRiley TurnerRiley requested a review from a team December 9, 2022 18:33

@megcrenshaw megcrenshaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for addressing this! I have a questions and some ideas for refactors:

  1. Should pl_programs_offered or summer_workshops dictate what gets shown? We're using both here in different places and I don't understand why. It looks like pl_programs_offered relies on the RP correctly filling out their info on their Regional Partner page, whereas summer_workshops we get by querying our workshops. I'm not sure what we should rely on (and it might be a product question).
  2. We have conditional logic in both workshopCollections and partnerInfo –– for readability, can you consolidate this logic so that it lives in one place? This is related to the attributes named in (1).
  3. I should've caught this the first time, but I'm reading the workshopCollections and am getting confused by the information it contains. Could you consider renaming some things: workshopCollections, collections, and key aren't helping me figure out what information lives here.
  4. 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 be partnerInfo?.summer_workshops?.filter() which covers BOTH if partnerInfo is nil and if summer_workshops is nil. Another option is to set some default values so that you don't need to keep checking these.
  5. I made a test file recently to ensure the StartApplicationButton was 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?
  6. 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.

@megcrenshaw

megcrenshaw commented Dec 9, 2022

Copy link
Copy Markdown

@dmcavoy could you chime in on questions 1 and 5 above?

@TurnerRiley

Copy link
Copy Markdown
Contributor Author

Thanks for addressing this! I have a questions and some ideas for refactors:

  1. Should pl_programs_offered or summer_workshops dictate what gets shown? We're using both here in different places and I don't understand why. It looks like pl_programs_offered relies on the RP correctly filling out their info on their Regional Partner page, whereas summer_workshops we get by querying our workshops. I'm not sure what we should rely on (and it might be a product question).
  2. We have conditional logic in both workshopCollections and partnerInfo –– for readability, can you consolidate this logic so that it lives in one place? This is related to the attributes named in (1).
  3. I should've caught this the first time, but I'm reading the workshopCollections and am getting confused by the information it contains. Could you consider renaming some things: workshopCollections, collections, and key aren't helping me figure out what information lives here.
  4. 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 be partnerInfo?.summer_workshops?.filter() which covers BOTH if partnerInfo is nil and if summer_workshops is nil. Another option is to set some default values so that you don't need to keep checking these.
  5. I made a test file recently to ensure the StartApplicationButton was 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?
  6. 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.

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!

@dmcavoy

dmcavoy commented Dec 12, 2022

Copy link
Copy Markdown
Contributor

Should pl_programs_offered or summer_workshops dictate what gets shown? We're using both here in different places and I don't understand why. It looks like pl_programs_offered relies on the RP correctly filling out their info on their Regional Partner page, whereas summer_workshops we get by querying our workshops. I'm not sure what we should rely on (and it might be a product question).

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.
Program
Some or all programs offered -> For programs offer if workshop has been scheduled show the workshop details otherwise show a message that the workshop details are coming soon. For the programs not offered show a message that tells them they can still apply but that we will have to figure out where to place them since their region is not offering.

Does that help?

@dmcavoy

dmcavoy commented Dec 12, 2022

Copy link
Copy Markdown
Contributor

For #5 I think just adding tests for the new things that are being added makes sense.

@megcrenshaw

Copy link
Copy Markdown

Should pl_programs_offered or summer_workshops dictate what gets shown? We're using both here in different places and I don't understand why. It looks like pl_programs_offered relies on the RP correctly filling out their info on their Regional Partner page, whereas summer_workshops we get by querying our workshops. I'm not sure what we should rely on (and it might be a product question).

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. Program Some or all programs offered -> For programs offer if workshop has been scheduled show the workshop details otherwise show a message that the workshop details are coming soon. For the programs not offered show a message that tells them they can still apply but that we will have to figure out where to place them since their region is not offering.

Does that help?

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).

@TurnerRiley TurnerRiley changed the base branch from staging-next to staging December 14, 2022 21:30
heading: `${ActiveCourseWorkshops[courseKey]} Workshops`,
isOffered: partnerInfo?.pl_programs_offered?.includes(courseKey),
summerWorkshops: partnerInfo?.summer_workshops?.filter(
workshop => workshop.course === ActiveCourseWorkshops[courseKey]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LOVE this structure using ActiveCourseWorkshops to push!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

And the optional chaining 🙌

workshop_date_range_string: 'Test CSD workshop dates',
location_name: 'Test CSD workshop location',
location_address: 'Test CSD workshop address'
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is great!

});
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is great! And serves as documentation on how we expect data coming in from the backend to look

@megcrenshaw megcrenshaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks amazing! Nice work –– lots of weird cases to catch, and the tests document them beautifully.

@TurnerRiley TurnerRiley merged commit 3f42d05 into staging Dec 15, 2022
@TurnerRiley TurnerRiley deleted the show-RP-info-without-programs branch December 15, 2022 21:08
epeach pushed a commit that referenced this pull request Dec 15, 2022
epeach pushed a commit that referenced this pull request Dec 15, 2022
@TurnerRiley TurnerRiley restored the show-RP-info-without-programs branch December 16, 2022 01:16
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