Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

The updater service has logic to disable automatic update checks when updateIntervalMs is set to 0, but this behavior lacked test coverage.

Changes

  • Added test should disable updater when updateIntervalMs is 0 to verify:
    • No initial update check occurs on subscription
    • No periodic checks occur as timers advance
    • Validates existing conditional in start() that skips setInterval when updateIntervalMs !== 0
test('should disable updater when updateIntervalMs is 0', async () => {
  const mock = vi.spyOn(backend, 'checkUpdate').mockReturnValue(mockUpdate(null));
  
  const disabledUpdater = new UpdaterService(backend, posthog, shortcuts, 0);
  const unsubscribe = disabledUpdater.update.subscribe(() => {});
  
  expect(mock).not.toHaveBeenCalled();
  
  await vi.advanceTimersByTimeAsync(3600 * 1000);
  expect(mock).not.toHaveBeenCalled();
  
  unsubscribe();
});
Original prompt

Add a test to updater.test.ts to assert that an updateIntervalMs of 0 disables the updater.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
gitbutler-web Skipped Skipped Dec 19, 2025 11:40am

Copilot AI changed the title [WIP] Add test to disable updater for zero updateIntervalMs Add test for updateIntervalMs=0 disabling updater Dec 19, 2025
Copilot AI requested a review from Byron December 19, 2025 09:56
@Byron Byron marked this pull request as ready for review December 19, 2025 11:40
Copilot AI review requested due to automatic review settings December 19, 2025 11:40
@Byron Byron force-pushed the copilot/add-test-update-interval-zero branch from 22490d1 to ac99db3 Compare December 19, 2025 11:40
@Byron Byron enabled auto-merge December 19, 2025 11:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds test coverage for the updater service's behavior when updateIntervalMs is set to 0, which disables automatic update checks. This validates existing logic in the start() method that conditionally skips setting up the interval timer.

  • Adds a new test case that verifies the updater doesn't perform any automatic checks when disabled
  • Confirms that both initial checks and periodic interval checks are skipped
  • Uses the existing test patterns with fake timers to validate timer-based behavior

Comment on lines +145 to +147
await vi.advanceTimersByTimeAsync(3600 * 1000);
expect(mock).not.toHaveBeenCalled();

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

These two time advances with identical assertions are redundant. Since the test is verifying that no timer was set when updateIntervalMs is 0, a single time advance is sufficient to demonstrate this behavior. Consider removing one of these duplicate checks.

Suggested change
await vi.advanceTimersByTimeAsync(3600 * 1000);
expect(mock).not.toHaveBeenCalled();

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough - I also saw it, but thought it wanted to make extra-sure.

@Byron Byron merged commit f2f3e53 into master Dec 19, 2025
23 checks passed
@Byron Byron deleted the copilot/add-test-update-interval-zero branch December 19, 2025 11:49
Byron added a commit to Byron/gitbutler that referenced this pull request Dec 19, 2025
Byron added a commit to Byron/gitbutler that referenced this pull request Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants