Skip to content

Commit

Permalink
chore: upgrade versions to support xcode 16 (#457)
Browse files Browse the repository at this point in the history
* chore: upgrade versions to support xcode 16

* chore: bump ViewInspector too

* fix: mark tests using inspection with @mainactor

* fix tests

* fix logical merge conflict

* fix HomeMapViewUITests not starting permissions request

* request location permissions automatically

* try calling on change at self before searching

* don't fail the map tests

---------

Co-authored-by: Melody Horn <[email protected]>
  • Loading branch information
KaylaBrady and boringcactus authored Oct 16, 2024
1 parent a92d47b commit 144af58
Show file tree
Hide file tree
Showing 20 changed files with 270 additions and 119 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ agp = "8.5.2"
# and https://developer.android.com/jetpack/androidx/releases/compose for release notes
compose-bom = "2024.09.03"
datastorePreferencesCore = "1.1.1"
kotlin = "2.0.10"
kotlin = "2.0.20"
javaphoenixclient = "1.3.1"
junit = "4.13.2"
koin-bom = "3.5.6"
Expand Down
6 changes: 5 additions & 1 deletion iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
8CA1FB752BF7EB3500384658 /* TripDetailsStopListSplitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CA1FB742BF7EB3500384658 /* TripDetailsStopListSplitView.swift */; };
8CA1FB772BF813F500384658 /* TripDetailsStopListSplitViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CA1FB762BF813F500384658 /* TripDetailsStopListSplitViewTests.swift */; };
8CA485B82BDC679A00E84E1F /* VehicleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CA485B72BDC679A00E84E1F /* VehicleExtension.swift */; };
8CA606A92CC02FBC0019C448 /* ViewInspectorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CA606A82CC02FBC0019C448 /* ViewInspectorExtensions.swift */; };
8CB28DB92C2CC5AD0036258E /* MapViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CB28DB82C2CC5AD0036258E /* MapViewModel.swift */; };
8CB823D62BC5E85C002C87E0 /* SheetNavigationStackEntryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CB823D52BC5E85C002C87E0 /* SheetNavigationStackEntryTests.swift */; };
8CB823D92BC5EDD2002C87E0 /* StopDetailsRouteViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CB823D82BC5EDD2002C87E0 /* StopDetailsRouteViewTests.swift */; };
Expand Down Expand Up @@ -321,6 +322,7 @@
8CA1FB742BF7EB3500384658 /* TripDetailsStopListSplitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TripDetailsStopListSplitView.swift; sourceTree = "<group>"; };
8CA1FB762BF813F500384658 /* TripDetailsStopListSplitViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TripDetailsStopListSplitViewTests.swift; sourceTree = "<group>"; };
8CA485B72BDC679A00E84E1F /* VehicleExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleExtension.swift; sourceTree = "<group>"; };
8CA606A82CC02FBC0019C448 /* ViewInspectorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewInspectorExtensions.swift; sourceTree = "<group>"; };
8CB28DB82C2CC5AD0036258E /* MapViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewModel.swift; sourceTree = "<group>"; };
8CB823D52BC5E85C002C87E0 /* SheetNavigationStackEntryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetNavigationStackEntryTests.swift; sourceTree = "<group>"; };
8CB823D82BC5EDD2002C87E0 /* StopDetailsRouteViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopDetailsRouteViewTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -519,6 +521,7 @@
9A5B275D2BB242EF009A6FC6 /* Pages */,
6EE745822B965B8D0052227E /* Phoenix */,
9ADB849E2BAD1B6B006581CE /* Utils */,
8CA606A82CC02FBC0019C448 /* ViewInspectorExtensions.swift */,
6EFEE4292BEC0FF000810319 /* ViewModels */,
6EED5EA92B3DF1BF0052A1B8 /* Views */,
);
Expand Down Expand Up @@ -1250,6 +1253,7 @@
9A52B3362C6A93390028EEAB /* AlertDetailsTests.swift in Sources */,
8C2106F52CA6159600228287 /* ErrorBannerTests.swift in Sources */,
6E4C375E2C4BDC9F00EA67CF /* ContentViewModelTests.swift in Sources */,
8CA606A92CC02FBC0019C448 /* ViewInspectorExtensions.swift in Sources */,
9A7B7CA92B98E41B0045214F /* NonNilModifierTests.swift in Sources */,
6E973DA92C178BF500CBF341 /* ActionButtonTests.swift in Sources */,
6EED5EAB2B3E1B550052A1B8 /* ContentViewTests.swift in Sources */,
Expand Down Expand Up @@ -2106,7 +2110,7 @@
repositoryURL = "https://github.com/nalexn/ViewInspector";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.9.11;
minimumVersion = 0.10.0;
};
};
9AB3F50B2BE44B49008D9E40 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
Expand Down
20 changes: 10 additions & 10 deletions iosApp/iosApp.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -96,26 +96,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-common-ios.git",
"state" : {
"revision" : "15aed0b292a0fe0672113c1b69be04bd350c8bb3",
"version" : "24.3.1"
"revision" : "25d2799f6116d7921b707b6eb217cf976e0a664a",
"version" : "24.7.0"
}
},
{
"identity" : "mapbox-core-maps-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-core-maps-ios.git",
"state" : {
"revision" : "3638d2841f8a2ef6a995c659457d6133a6f0d1be",
"version" : "11.3.0"
"revision" : "b191fddd85c19c7372b6a5b93bb883ba04ea0cbe",
"version" : "11.7.0"
}
},
{
"identity" : "mapbox-maps-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/mapbox-maps-ios.git",
"state" : {
"revision" : "935c658a4d4d454de0e81e0b49ed291bd2c756a9",
"version" : "11.3.0"
"revision" : "1dfa477626cde82d4df9b680027a7cd64e87b140",
"version" : "11.7.0"
}
},
{
Expand Down Expand Up @@ -167,17 +167,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mapbox/turf-swift.git",
"state" : {
"revision" : "213050191cfcb3d5aa76e1fa90c6ff1e182a42ca",
"version" : "2.8.0"
"revision" : "1997fb3c3dc0d8181690a1ec192ed907bcead9e8",
"version" : "3.0.0"
}
},
{
"identity" : "viewinspector",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nalexn/ViewInspector",
"state" : {
"revision" : "7b1732802ffe30e6a67754bda6c7819e5cb0eb70",
"version" : "0.9.11"
"revision" : "5acfa0a3c095ac9ad050abe51c60d1831e8321da",
"version" : "0.10.0"
}
}
],
Expand Down
3 changes: 0 additions & 3 deletions iosApp/iosApp/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@
},
"Crossing Malfunction" : {
"comment" : "Possible alert cause"
},
"Custom message" : {

},
"Demonstration" : {
"comment" : "Possible alert cause"
Expand Down
3 changes: 3 additions & 0 deletions iosApp/iosApp/Pages/Map/HomeMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ struct HomeMapView: View {
*/
nearbyVM.selectingLocation = true
}
.onAppear {
locationDataManager.locationFetcher.requestWhenInUseAuthorization()
}
.onDisappear {
mapVM.layerManager = nil
}
Expand Down
4 changes: 1 addition & 3 deletions iosApp/iosAppTests/Mocks/MockLocationFetcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class MockLocationFetcher: LocationFetcher {
handleStartUpdatingLocation?()
}

func requestWhenInUseAuthorization() {
XCTFail("should not have requested when-in-use authorization")
}
func requestWhenInUseAuthorization() {}

func updateLocations(locations: [CLLocation]) {
locationFetcherDelegate?.locationFetcher(self, didUpdateLocations: locations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ final class NearbyTransitPageViewTests: XCTestCase {
objects: .init(),
patternIdsByStop: [:]
)
try view.find(NearbyTransitView.self).vStack().callOnChange(newValue: newCameraState.center)
try view.find(NearbyTransitView.self).implicitAnyView().vStack()
.callOnChange(newValue: newCameraState.center)
}

ViewHosting.host(view: sut)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ final class StopDetailsPageTests: XCTestCase {
wait(for: [joinExpectation], timeout: 1)
}

@MainActor
func testUpdatesDeparturesOnPredictionsChange() throws {
let objects = ObjectCollectionBuilder()
let route = objects.route()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ final class TripDetailsPageTests: XCTestCase {
vehicleRepository: FakeVehicleRepository(response: .init(vehicle: nil))
)

try sut.inspect().vStack().callOnChange(newValue: "newTripId", index: 0)
try sut.inspect().implicitAnyView().vStack().callOnChange(newValue: "newTripId", index: 0)

wait(for: [predictionsLeaveExp, predictionsJoinExp], timeout: 2)
}
Expand Down Expand Up @@ -574,7 +574,7 @@ final class TripDetailsPageTests: XCTestCase {
)

// Index 1 because first onChange of a string is for tripId
try sut.inspect().vStack().callOnChange(newValue: "newTripId", index: 1)
try sut.inspect().implicitAnyView().vStack().callOnChange(newValue: "newTripId", index: 1)

wait(for: [vehicleLeaveExp, vehicleJoinExp], timeout: 2)
}
Expand Down
9 changes: 6 additions & 3 deletions iosApp/iosAppTests/Utils/ScenePhaseChangeModifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ final class ScenePhaseChangeModifierTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().callOnChange(newValue: ScenePhase.active)
try sut.inspect().find(ViewType.Text.self).modifier(ScenePhaseChangeModifier.self).implicitAnyView()
.viewModifierContent().callOnChange(newValue: ScenePhase.active)

wait(for: [activeCalledExpectation], timeout: 1)
}
Expand All @@ -41,7 +42,8 @@ final class ScenePhaseChangeModifierTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().callOnChange(newValue: ScenePhase.inactive)
try sut.inspect().find(ViewType.Text.self).modifier(ScenePhaseChangeModifier.self).implicitAnyView()
.viewModifierContent().callOnChange(newValue: ScenePhase.inactive)

wait(for: [inactiveCalledExpectation], timeout: 1)
}
Expand All @@ -55,7 +57,8 @@ final class ScenePhaseChangeModifierTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().callOnChange(newValue: ScenePhase.background)
try sut.inspect().find(ViewType.Text.self).modifier(ScenePhaseChangeModifier.self).implicitAnyView()
.viewModifierContent().callOnChange(newValue: ScenePhase.background)

wait(for: [backgroundCalledExpectation], timeout: 1)
}
Expand Down
32 changes: 32 additions & 0 deletions iosApp/iosAppTests/ViewInspectorExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// ViewInspectorExtensions.swift
// iosAppTests
//
// Created by Horn, Melody on 2024-10-16.
// Copyright © 2024 MBTA. All rights reserved.
//

import Foundation
import SwiftUI
import ViewInspector

extension InspectableView {
func findAndCallOnChange(
relation: ViewSearch.Relation = .child,
newValue value: some Equatable,
index: Int = 0
) throws {
do {
try callOnChange(newValue: value, index: index)
return
} catch {}
_ = try find(relation: relation, where: { child in
do {
try child.callOnChange(newValue: value, index: index)
return true
} catch {
return false
}
})
}
}
2 changes: 1 addition & 1 deletion iosApp/iosAppTests/Views/ActionButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ActionButtonTests: XCTestCase {
exp.fulfill()
}
XCTAssertNotNil(try sut.inspect().find(viewWithAccessibilityLabel: "Close"))
try sut.inspect().button().tap()
try sut.inspect().implicitAnyView().button().tap()
wait(for: [exp], timeout: 1)
}
}
22 changes: 14 additions & 8 deletions iosApp/iosAppTests/Views/ContentViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ final class ContentViewTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().vStack().callOnChange(newValue: ScenePhase.background)
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack().callOnChange(newValue: ScenePhase.background)
wait(for: [disconnectedExpectation], timeout: 5)
}

Expand All @@ -55,9 +56,11 @@ final class ContentViewTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().vStack().callOnChange(newValue: ScenePhase.background)
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack().callOnChange(newValue: ScenePhase.background)
wait(for: [disconnectedExpectation], timeout: 1)
try sut.inspect().vStack().callOnChange(newValue: ScenePhase.active)
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack().callOnChange(newValue: ScenePhase.active)
wait(for: [connectedExpectation], timeout: 1)
}

Expand All @@ -74,7 +77,8 @@ final class ContentViewTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().vStack().callOnChange(newValue: ScenePhase.active)
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack().callOnChange(newValue: ScenePhase.active)
wait(for: [joinAlertsExp], timeout: 5)
}

Expand All @@ -89,7 +93,8 @@ final class ContentViewTests: XCTestCase {

ViewHosting.host(view: sut)

try sut.inspect().vStack().callOnChange(newValue: ScenePhase.background)
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack().callOnChange(newValue: ScenePhase.background)
wait(for: [leavesAlertsExp], timeout: 5)
}

Expand All @@ -112,13 +117,14 @@ final class ContentViewTests: XCTestCase {
let fakeVM = FakeContentVM(
configMapboxCallback: { tokenConfigExpectation.fulfill() }
)
let sut = ContentView(contentVM: fakeVM)
let sut = withDefaultEnvironmentObjects(sut: ContentView(contentVM: fakeVM))

ViewHosting.host(view: withDefaultEnvironmentObjects(sut: sut))
ViewHosting.host(view: sut)

let newConfig: ApiResult<ConfigResponse>? = ApiResultOk(data: .init(mapboxPublicToken: "FAKE_TOKEN"))

try sut.inspect().vStack()
try sut.inspect().implicitAnyView().view(ContentView.self).implicitAnyView().implicitAnyView().implicitAnyView()
.vStack()
.callOnChange(newValue: newConfig)
wait(for: [tokenConfigExpectation], timeout: 5)
}
Expand Down
8 changes: 4 additions & 4 deletions iosApp/iosAppTests/Views/EmptyWhenModifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ final class EmptyWhenModifierTests: XCTestCase {

@MainActor func testEmptyOnFalse() throws {
let sut = Text("hello").emptyWhen(true)
let modifier = try sut.inspect().text().modifier(EmptyWhenModifier.self)
let modifier = try sut.inspect().implicitAnyView().text().modifier(EmptyWhenModifier.self)

XCTAssertNotNil(try modifier.emptyView())
XCTAssertNotNil(try modifier.implicitAnyView().emptyView())
XCTAssertThrowsError(try modifier.viewModifierContent())
}

@MainActor func testNotEmptyOnTrue() throws {
let sut = Text("hello").emptyWhen(false)
let modifier = try sut.inspect().text().modifier(EmptyWhenModifier.self)
let modifier = try sut.inspect().implicitAnyView().text().modifier(EmptyWhenModifier.self)

XCTAssertNotNil(try modifier.viewModifierContent())
XCTAssertNotNil(try modifier.implicitAnyView().viewModifierContent())
XCTAssertThrowsError(try modifier.emptyView())
}
}
2 changes: 1 addition & 1 deletion iosApp/iosAppTests/Views/ErrorBannerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class ErrorBannerTests: XCTestCase {
wait(for: [callsAction], timeout: 1)
}

func testLoadingWhenPredictionsStale() throws {
@MainActor func testLoadingWhenPredictionsStale() throws {
let sut = ErrorBanner(
loadingWhenPredictionsStale: true,
repo: MockErrorBannerStateRepository(state: .StalePredictions(
Expand Down
Loading

0 comments on commit 144af58

Please sign in to comment.