Sign In Sign Up

Refactor update simulation into dedicated file

Extract the update simulation code in @macos/Sources/App/macOS/AppDelegate.swift into a dedicated file in @macos/Sources/Features/Update . This should contain multiple simulation scenarios (happy path, not found, errors, etc.) so that we can easily try different demos.

Done! I've extracted the update simulation code into a dedicated UpdateSimulator.swift file with 7 different scenarios:

  1. .happyPath - Complete successful update flow
  2. .notFound - No updates available
  3. .error - Error during update check with retry
  4. .slowDownload - Slower download for testing progress UI
  5. .permissionRequest - Initial permission flow
  6. .cancelDuringDownload - User cancels during download
  7. .cancelDuringChecking - User cancels during checking

The simulator is now in UpdateSimulator.swift, AppDelegate.swift has been simplified to just call UpdateSimulator.simulate(.happyPath, with: updateViewModel), and I've added a README.md documenting all scenarios.

To try different demos, just change the scenario in AppDelegate.swift line 1010.

Don't create a README. Just document them inline.

Done! I've removed the README and added inline documentation to UpdateSimulator.swift describing each scenario.

I think Scenario can be merged down in UpdateSimulator.

Done! I've flattened the structure. Now you use UpdateSimulator.happyPath.simulate(with: updateViewModel) instead of the nested Scenario enum.

Do all those functions need to really be static anymore?
Edited UpdateSimulator.swift
+18
-18

Done! All the helper functions are now regular private instance methods instead of static methods.