Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

No Bug: Fix flakey ManageSiteConnectionsStoreTests #8368

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Combine
import XCTest
import BraveCore
import Data
@testable import Data
import TestHelpers
@testable import BraveWallet

Expand Down Expand Up @@ -79,6 +79,8 @@ class ManageSiteConnectionsStoreTests: CoreDataTestCase {
backgroundSaveAndWaitForExpectation {
store.removeAllPermissions(from: [siteConnectionToRemove])
}
DataController.viewContext.refreshAllObjects()

// verify `siteConnections` is updated
XCTAssertEqual(store.siteConnections.count, 2)
XCTAssertNotEqual(store.siteConnections[0].url, siteConnectionToRemove.url)
Expand All @@ -101,6 +103,7 @@ class ManageSiteConnectionsStoreTests: CoreDataTestCase {
backgroundSaveAndWaitForExpectation {
store.removePermissions(for: .eth, from: [walletAccount], url: URL(string: siteConnectionToRemoveAccount.url)!)
}
DataController.viewContext.refreshAllObjects()

// verify `siteConnections` is updated to remove specific accounts from the `SiteConnection`
XCTAssertEqual(store.siteConnections.count, 3)
Expand All @@ -125,11 +128,14 @@ class ManageSiteConnectionsStoreTests: CoreDataTestCase {
backgroundSaveAndWaitForExpectation {
store.removePermissions(for: .eth, from: [walletAccount], url: URL(string: siteConnectionToRemove.url)!)
}
DataController.viewContext.refreshAllObjects()

// remove `walletAccount2` permissions for this `SiteConnection`
XCTAssertEqual(store.siteConnections[0].connectedAddresses.count, 1)
backgroundSaveAndWaitForExpectation {
store.removePermissions(for: .eth, from: [walletAccount2], url: URL(string: siteConnectionToRemove.url)!)
}
DataController.viewContext.refreshAllObjects()

// verify `siteConnections` is updated to remove the `SiteConnection` as all `connectedAddresses` are removed
XCTAssertEqual(store.siteConnections.count, 2)
Expand Down