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

(Release 1.4) Enhancing Boot Notification Service/Handler tests #223

Merged

Conversation

yuvenus
Copy link

@yuvenus yuvenus commented Aug 14, 2024

This PR moves more functionality out of the BootNotification handler in Configuration module into the BootNotificationService and adds the appropriate unit tests for the functionality that was moved

Unfortunately, there are some limitations to what can be moved out due several different sendCall invocations that would be messy to move into the service (such as having to pass functions as a method parameter... 😳). As a result, this PR attempts to refactor some of the immovable logic in the handler away from long if-statements to if-statements that will return right away if the logic cannot move forward. This is partly in hopes that the next refactor can take the remaining chunks and make them unit testable 🤞

Points of interest regarding the aforementioned if-statement refactor:

  1. Lines 240 - 245, this if-statement will throw if the boot notification response message confirmation did not succeed. This replaces an if-statement that wrapped around the remaining code below it.
  2. Lines 268 - 274, this if-statement will prematurely end the handling if the boot notification is not pending or the cached boot status is not null and currently pending, because either of these indicate that the configuration was already started previously. This replaces an if-statement that wrapped around the remaining code below it

Additionally, some if-statement logic was simplified (either by moving into a dedicated variable or unnecessary null checks removed) to aid with readability and yet again hopefully make a future developer's refactor job easier.

Venus Yu added 16 commits August 12, 2024 13:44
…structor to take in a cache + logger to support some of the boot notification handler functionality that was moved into the service
…lity out of Configuration module's BootNotification handler to BootNotificationService + DeviceModelService to prepare for unit tests
…icationService's "cacheChargerActionsPermissions" method
…icationService's "triggerGetBaseReport" method
…ger set variables if pendingBootSetVariables.length > 0, rather than > 1
…able from bootWithRejectedVariables to doNotBootWithRejectedVariables for clarity
…ablesActionsAfterBoot to executeSetVariablesAfterBoot for brevity
…et variables since it's not as easy to do as initially thought
… as a constructor argument for BootNotificationService and instead passing it in to the relevant methods that need it + moving more cache-related calls back into the module since they're not relevant to the methods they were put into
… as a constructor argument from remaining files + adding more comments
…cation-service-tests

# Conflicts:
#	03_Modules/Configuration/test/module/BootNotificationService.test.ts
@elliot-sabitov elliot-sabitov merged commit df6d745 into rc-1.4.0 Aug 16, 2024
3 checks passed
@elliot-sabitov elliot-sabitov mentioned this pull request Aug 16, 2024
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.

2 participants