Skip to content

Created the tests for the navbar interactor#178

Merged
matthew-SG merged 1 commit intomainfrom
175-adish-final-changes
Dec 3, 2025
Merged

Created the tests for the navbar interactor#178
matthew-SG merged 1 commit intomainfrom
175-adish-final-changes

Conversation

@Adish-Singh
Copy link
Copy Markdown
Collaborator

@Adish-Singh Adish-Singh commented Dec 2, 2025

Summary
This pull request introduces a complete JUnit test suite for the NavbarInteractor, along with a mock presenter implementation (NavbarMockPresenter). These tests ensure that navigation requests made through the interactor are correctly delegated to the corresponding presenter methods defined in NavbarOutputBoundary.

Key Additions

  1. NavbarInteractorTests
  • A new test class containing the following:
    - Individual tests for each navigation method:
    - switchToLogin
    - switchToSignUp
    - switchToCommunity
    - switchToGenerateRecipe
    - switchToApproveRecipe
    - switchToProfile
    - switchToGroceryList
    - switchToMealPlan
    - switchToSearchByIngredients
    - switchToLikedRecipeList
  • A sequential test verifying correct behavior when multiple navigation commands are issued consecutively.
  • Assertions ensure that the interactor routes calls to the correct presenter method.
  1. NavbarMockPresenter
  • A lightweight mock implementation of NavbarOutputBoundary enabling verification of interactor behavior:
    - Tracks the last view switched via a lastViewSwitched field.
    - Provides getter for test assertions.
    - Implements all navigation methods expected by the interactor.

Motivation
The navigation system is a key component of the application's user flow.
Prior to this PR, the NavbarInteractor lacked automated tests, leaving its correctness unverified.
This addition improves:
- Reliability of navigation handoff logic
- Confidence in future refactoring
- Compliance with clean architecture testing principles

Testing
All tests pass successfully.
I also checked for 100% line coverage for the interactor.

Files Added
src/test/java/use_case/nav_bar/NavbarInteractorTests.java
src/test/java/use_case/nav_bar/NavbarMockPresenter.java

Impact
No production code is modified.
This PR enhances test coverage and ensures the navigation interactor behaves as designed.

…enter file since navbar does not have anything that implements its output boundary in its use case, i.e. it does not have its own presenter.
Comment thread src/test/java/use_case/nav_bar/NavbarMockPresenter.java
Comment thread src/test/java/use_case/nav_bar/NavbarMockPresenter.java
Comment thread src/test/java/use_case/nav_bar/NavbarMockPresenter.java
Comment thread src/test/java/use_case/nav_bar/NavbarInteractorTests.java
Comment thread src/test/java/use_case/nav_bar/NavbarInteractorTests.java
Comment thread src/test/java/use_case/nav_bar/NavbarInteractorTests.java
Comment thread src/test/java/use_case/nav_bar/NavbarInteractorTests.java
Copy link
Copy Markdown
Owner

@matthew-SG matthew-SG left a comment

Choose a reason for hiding this comment

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

Yeah that makes sense. Appreciate you writing the tests.

@matthew-SG matthew-SG merged commit 92a3b8a into main Dec 3, 2025
1 check passed
@Adish-Singh Adish-Singh changed the title Created the tests for the navbar interactor. Had to create a mockpres… Created the tests for the navbar interactor Dec 3, 2025
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