Skip to content

🧪 [Testing Improvement] Add error state test for loadYears in ScheduleViewModel - #188

Closed
alvin000009238 wants to merge 1 commit into
mainfrom
test/schedule-viewmodel-loadyears-error-11772296962705487162
Closed

🧪 [Testing Improvement] Add error state test for loadYears in ScheduleViewModel#188
alvin000009238 wants to merge 1 commit into
mainfrom
test/schedule-viewmodel-loadyears-error-11772296962705487162

Conversation

@alvin000009238

Copy link
Copy Markdown
Owner

🎯 What: Added test coverage for error state updates when repository.getScheduleYears() throws an exception in ScheduleViewModel.loadYears().
📊 Coverage: Added loadYearsErrorUpdatesState to verify the UI state incorrectly sets isLoading to false, isError to true, and captures the error message properly when the API fails.
Result: Improved confidence in ScheduleViewModel error handling and completed testing for ScheduleUiState transitions.


PR created automatically by Jules for task 11772296962705487162 started by @alvin000009238

Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings June 17, 2026 14:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new unit test, loadYearsErrorUpdatesState, to verify that the UI state updates correctly when a network error occurs during the loading of years. The review feedback suggests also asserting that isInitialLoading is set to false in this error state to prevent the UI from getting stuck in an infinite loading screen.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +88 to +90
assertFalse(state.isLoading)
assertTrue(state.isError)
assertEquals("Network error", state.errorMessage)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

It is highly recommended to also assert that isInitialLoading is set to false. In ScheduleViewModel, isInitialLoading is updated to false before loadYears() is called. Verifying this in the error state test ensures that the UI doesn't get stuck in an infinite full-screen loading state when an error occurs.

        assertFalse(state.isLoading)
        assertFalse(state.isInitialLoading)
        assertTrue(state.isError)
        assertEquals("Network error", state.errorMessage)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a unit test to cover ScheduleViewModel.loadYears() error handling when ScheduleRepository.getScheduleYears() throws, ensuring ScheduleUiState transitions to an error state in that scenario.

Changes:

  • Added loadYearsErrorUpdatesState test to assert isLoading=false, isError=true, and errorMessage is propagated when years loading fails.
  • Added the missing assertTrue import needed by the new assertion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alvin000009238
alvin000009238 deleted the test/schedule-viewmodel-loadyears-error-11772296962705487162 branch July 9, 2026 09:30
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