-
Notifications
You must be signed in to change notification settings - Fork 2
files core monitortests weatherviewmodeltests swift 9996602c
ventaphobia edited this page Apr 23, 2026
·
1 revision
- Area: Tests.
- This page records the file's current repository role, source metadata, and recent commit history.
- Review nearby tests and commit pages before changing this file.
| Field | Value |
|---|---|
| Source path | Core-MonitorTests/WeatherViewModelTests.swift |
| Wiki area | Tests |
| Exists in current checkout | True |
| Size | 10024 bytes |
| Binary | False |
| Line count | 265 |
| Extension | .swift |
Combine, CoreLocation, XCTest
| Kind | Name | Line |
|---|---|---|
| class | WeatherViewModelTests |
4 |
| func | testRefreshNowUsesFallbackLocationWhenAccessIsNotDetermined |
8 |
| func | testRefreshNowUsesFallbackProviderWhenWeatherKitCapabilityIsMissing |
32 |
| func | testRefreshNowRequestsLiveLocationBeforeUsingFallback |
65 |
| func | testRefreshNowUsesFallbackLocationWhenAuthorizedWithoutAvailableCurrentLocation |
86 |
| func | testStartDoesNotRequestLocationAuthorizationOnLaunch |
108 |
| func | testStartRefreshesImmediatelyWhenLocationAccessChanges |
121 |
| func | testRefreshNowUsesFallbackProviderWhenLiveProviderFails |
153 |
| class | RecordingWeatherProvider |
181 |
| func | currentWeather |
185 |
| class | FailingWeatherProvider |
203 |
| struct | TestError |
205 |
| func | currentWeather |
208 |
| class | MockWeatherLocationAccess |
213 |
| func | requestAccess |
236 |
| func | refreshStatus |
240 |
| func | requestCurrentLocation |
244 |
| func | emitChange |
249 |
| Commit | Date | Subject |
|---|---|---|
bd80f00 |
2026-04-17 | Fix fan helper recovery and weather fallback |
44eb999 |
2026-04-16 | Harden touch bar customization and weather fallback |
8bfc685 |
2026-04-16 | Stabilize signing and WeatherKit release packaging |
6e7215b |
2026-04-16 | Refresh weather after location access changes |
e235eca |
2026-04-16 | Add regression coverage for weather permission gating |
- Prefer focused changes that respect the ownership described above.
- If this file touches helper trust, SMC writes, startup, or permissions, update the relevant support docs and tests.
- If this file is generated or an asset manifest, verify the producing workflow instead of hand-editing generated payloads.
import XCTest
import CoreLocation
import Combine
@testable import Core_Monitor
@MainActor
final class WeatherViewModelTests: XCTestCase {
func testRefreshNowUsesFallbackLocationWhenAccessIsNotDetermined() async {
let provider = RecordingWeatherProvider()
let locationAccess = MockWeatherLocationAccess(status: .notDetermined, currentLocation: nil)
let viewModel = WeatherViewModel(provider: provider, locationAccess: locationAccess)
await viewModel.refreshNow()
guard let requestedLocation = provider.requestedLocation else {
return XCTFail("Expected the weather provider to receive a fallback location.")
}
XCTAssertEqual(requestedLocation.coordinate.latitude, 37.3346, accuracy: 0.0001)
XCTAssertEqual(requestedLocation.coordinate.longitude, -122.0090, accuracy: 0.0001)
switch viewModel.state {
case .loaded(let snapshot):
XCTAssertEqual(snapshot.locationName, "Recorded")
default:
XCTFail("Expected a loaded fallback weather snapshot.")
}
XCTAssertEqual(locationAccess.requestAccessCallCount, 0)
XCTAssertEqual(locationAccess.requestCurrentLocationCallCount, 0)
}
func testRefreshNowUsesFallbackProviderWhenWeatherKitCapabilityIsMissing() async {
let provider = RecordingWeatherProvider()
let fallbackProvider = RecordingWeatherProvider()
let locationAccess = MockWeatherLocationAccess(status: .authorizedWhenInUse, currentLocation: nil)
let viewModel = WeatherViewModel(
provider: provider,
locationAccess: locationAccess,
fallbackProvider: fallbackProvider,
- Home
- Start Here
- Product Overview
- Runtime Architecture
- Monitoring Pipeline
- Fan Control
- Privileged Helper
- Touch Bar
- Release Automation
- Security Model
- File Index (279)
- Every Commit (401)
- Chronological Change Log
- Removed Parts
- All Deleted Paths
- Branches And Tags
- Wiki Manifest
- Start Here
- Product Overview
- Source Map
- Runtime Architecture
- App Startup And Lifecycle
- Dashboard Architecture
- Menu Bar Architecture
- Monitoring Pipeline
- Snapshot Trends And Freshness
- CPU GPU Memory Disk Network
- Battery Power And Thermals
- SMC And Apple Silicon
- Fan Control
- Custom Fan Curves
- Privileged Helper
- XPC Trust Boundary
- Helper Diagnostics
- Touch Bar Architecture
- Touch Bar Customization
- Weather And Location
- Privacy And Permissions
- Onboarding And Help
- Legacy Alerts
- Kernel Panic Weird Mode