Skip to content

Commit

Permalink
fix: resolve phoenix crashes (#392)
Browse files Browse the repository at this point in the history
* fix: resolve phoenix crashes

* test(ContentView): repair tests now that socket isn't attached onAppear
  • Loading branch information
KaylaBrady authored Sep 6, 2024
1 parent 64464d3 commit fc15fe3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2045,8 +2045,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/davidstump/SwiftPhoenixClient";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.3.3;
kind = revision;
revision = 4e548e4ce4d46574a20b8a539d52d367fb0eae24;
};
};
6EED5EAC2B3E1BA80052A1B8 /* XCRemoteSwiftPackageReference "ViewInspector" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/davidstump/SwiftPhoenixClient",
"state" : {
"revision" : "f7098ca53af4c9eb2a5e43267c5db5a306c98335",
"version" : "5.3.3"
"revision" : "4e548e4ce4d46574a20b8a539d52d367fb0eae24"
}
},
{
Expand Down
2 changes: 0 additions & 2 deletions iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ struct ContentView: View {
mapWithSheets
}
.onAppear {
socketProvider.socket.attach()
nearbyVM.joinAlertsChannel()
Task {
await contentVM.loadSettings()
}
Expand Down
9 changes: 3 additions & 6 deletions iosApp/iosAppTests/Views/ContentViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,23 @@ final class ContentViewTests: XCTestCase {
}

func testDisconnectsSocketAfterBackgrounding() throws {
let connectedExpectation = expectation(description: "Socket has connected")
let disconnectedExpectation = expectation(description: "Socket has disconnected")

let fakeSocketWithExpectations = FakeSocket(connectedExpectation: connectedExpectation,
disconnectedExpectation: disconnectedExpectation)
let fakeSocketWithExpectations = FakeSocket(disconnectedExpectation: disconnectedExpectation)

let sut = withDefaultEnvironmentObjects(sut: ContentView(contentVM: .init()),
socketProvider: SocketProvider(socket: fakeSocketWithExpectations))

ViewHosting.host(view: sut)

wait(for: [connectedExpectation], timeout: 1)
try sut.inspect().vStack().callOnChange(newValue: ScenePhase.background)
wait(for: [disconnectedExpectation], timeout: 5)
}

func testReconnectsSocketAfterBackgroundingAndReactivating() throws {
let disconnectedExpectation = expectation(description: "Socket has disconnected")
let connectedExpectation = expectation(description: "Socket has connected")
connectedExpectation.expectedFulfillmentCount = 2
connectedExpectation.expectedFulfillmentCount = 1
connectedExpectation.assertForOverFulfill = true

let fakeSocketWithExpectations = FakeSocket(connectedExpectation: connectedExpectation,
Expand All @@ -69,7 +66,7 @@ final class ContentViewTests: XCTestCase {
func testJoinsAlertsOnActive() throws {
let joinAlertsExp = expectation(description: "Alerts channel joined")
// joins in onAppear & on active
joinAlertsExp.expectedFulfillmentCount = 2
joinAlertsExp.expectedFulfillmentCount = 1
joinAlertsExp.assertForOverFulfill = true

let fakeNearbyVM: NearbyViewModel = .init(alertsRepository: CallbackAlertsRepository(connectExp: joinAlertsExp))
Expand Down

0 comments on commit fc15fe3

Please sign in to comment.