Skip to content
Open
Show file tree
Hide file tree
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 @@ -8,13 +8,13 @@ import Storage

@testable import Client

@MainActor
final class StoriesFeedDiffableDataSourceTests: XCTestCase {
var collectionView: UICollectionView?
var diffableDataSource: StoriesFeedDiffableDataSource?

override func setUpWithError() throws {
try super.setUpWithError()

override func setUp() async throws {
try await super.setUp()
collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout())
let collectionView = try XCTUnwrap(collectionView)
diffableDataSource = StoriesFeedDiffableDataSource(
Expand All @@ -25,11 +25,11 @@ final class StoriesFeedDiffableDataSourceTests: XCTestCase {
DependencyHelperMock().bootstrapDependencies()
}

override func tearDown() {
override func tearDown() async throws {
try await super.tearDown()
diffableDataSource = nil
collectionView = nil
DependencyHelperMock().reset()
super.tearDown()
}

func test_updateSnapshot_initialSnapshotHasNoData() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ class SyncContentSettingsViewControllerTests: XCTestCase {
var syncContentSettingsVC: SyncContentSettingsViewController?
let windowUUID: WindowUUID = .XCTestDefaultUUID

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
profile = MockProfile()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: profile)
syncContentSettingsVC = SyncContentSettingsViewController(windowUUID: windowUUID)
syncContentSettingsVC?.profile = profile
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
profile = nil
syncContentSettingsVC = nil
super.tearDown()
try await super.tearDown()
}

func test_syncContentSettingsViewController_generateSettingsCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ class FxAWebViewModelTests: XCTestCase {
var viewModel: FxAWebViewModel!
var deeplinkParams: FxALaunchParams!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
deeplinkParams = FxALaunchParams(entrypoint: .browserMenu, query: ["test_key": "test_value"])
viewModel = FxAWebViewModel(pageType: .settingsPage,
profile: MockProfile(),
deepLinkParams: deeplinkParams,
telemetry: FxAWebViewTelemetry(telemetryWrapper: MockTelemetryWrapper()))
}

override func tearDown() {
override func tearDown() async throws {
deeplinkParams = nil
viewModel = nil
super.tearDown()
try await super.tearDown()
}

func testCreateOutputURLWithValidFileNameAndExtension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class NotificationManagerTests: XCTestCase {
}

func testRequestAuthorization() {
notificationManager.requestAuthorization { (granted, error) in
XCTAssertTrue(granted)
XCTAssertTrue(self.center.requestAuthorizationWasCalled)
notificationManager.requestAuthorization { [center] (granted, error) in
assert(granted, "Authorization should be granted")
assert(center?.requestAuthorizationWasCalled ?? false, "requestAuthorization should be called")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test uses assert instead of XCTAssertTrue

Medium Severity

The testRequestAuthorization test replaced XCTAssertTrue with Swift's assert() function. This is incorrect because assert() is stripped in optimized/release builds and doesn't integrate with XCTest—failures won't be reported as test failures, they'll either crash the process or be silently ignored. Every other test in this file correctly uses XCTAssertTrue and XCTAssertEqual.

Fix in Cursor Fix in Web

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class RatingPromptManagerTests: XCTestCase {
var crashTracker: MockCrashTracker!
var subject: RatingPromptManager!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()

prefs = MockProfilePrefs()
logger = CrashingMockLogger()
Expand All @@ -33,7 +33,8 @@ class RatingPromptManagerTests: XCTestCase {
userDefaults: userDefaults)
}

override func tearDown() {
override func tearDown() async throws {
try await super.tearDown()
prefs.clearAll()
subject.reset()
prefs = nil
Expand All @@ -42,8 +43,6 @@ class RatingPromptManagerTests: XCTestCase {
userDefaults = nil
crashTracker = nil
subject = nil

super.tearDown()
}

func testShouldShowPrompt_forceShow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
import XCTest
@testable import Client

@MainActor
final class EditBookmarkDataSourceTests: XCTestCase {
private let folders = [
Folder(title: "Parent", guid: "ParentFolder", indentation: 0),
Folder(title: "Child", guid: "ChildFolder", indentation: 1)
]
private var tableView: UITableView!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
tableView = UITableView()
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.rootViewController?.view.addSubview(tableView)
window.makeKeyAndVisible()
}

override func tearDown() {
override func tearDown() async throws {
tableView = nil
super.tearDown()
try await super.tearDown()
}

func testOnSnapshotUpdate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Shared

@testable import Client

@MainActor
class EditBookmarkViewModelTests: XCTestCase {
let folder = MockFxBookmarkNode(type: .folder,
guid: "1235",
Expand All @@ -31,18 +30,18 @@ class EditBookmarkViewModelTests: XCTestCase {
var bookmarksSaver: MockBookmarksSaver!
var profile: MockProfile!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
folderFetcher = MockFolderHierarchyFetcher()
bookmarksSaver = MockBookmarksSaver()
profile = MockProfile()
}

override func tearDown() {
override func tearDown() async throws {
folderFetcher = nil
bookmarksSaver = nil
profile = nil
super.tearDown()
try await super.tearDown()
}

func testInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import Common
class HistoryPanelTests: XCTestCase {
let windowUUID: WindowUUID = .XCTestDefaultUUID
private var notificationCenter: MockNotificationCenter!
override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
LegacyFeatureFlagsManager.shared.initializeDeveloperFeatures(with: MockProfile())
DependencyHelperMock().bootstrapDependencies()
notificationCenter = MockNotificationCenter()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
DependencyHelperMock().reset()
notificationCenter = nil
try await super.tearDown()
}

func testHistoryButtons() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ final class MainMenuConfigurationUtilityTests: XCTestCase {
var configUtility: MainMenuConfigurationUtility!
let windowUUID: WindowUUID = .XCTestDefaultUUID

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
configUtility = MainMenuConfigurationUtility()
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
configUtility = nil
super.tearDown()
try await super.tearDown()
}

func testGenerateMenuElements_returnsHomepageSections_whenIsHomepageTrue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import XCTest
final class MainMenuCoordinatorTests: XCTestCase {
private var mockRouter: MockRouter!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
mockRouter = MockRouter(navigationController: MockNavigationController())
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
super.tearDown()
try await super.tearDown()
}

func testInitialState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ final class MainMenuMiddlewareTests: XCTestCase, StoreTestUtility {
var mockGleanWrapper: MockGleanWrapper!
var mockStore: MockStoreForMiddleware<AppState>!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
mockGleanWrapper = MockGleanWrapper()
DependencyHelperMock().bootstrapDependencies()
setupStore()
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
mockGleanWrapper = nil
resetStore()
super.tearDown()
try await super.tearDown()
}

func test_tapNavigateToDestination_findInPageAction_sendTelemetryData() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Common

@testable import Client

@MainActor
final class MainMenuViewControllerTests: XCTestCase {
let windowUUID: WindowUUID = .XCTestDefaultUUID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ final class MicrosurveyCoordinatorTests: XCTestCase {
private var mockRouter: MockRouter!
private var mockTabManager: MockTabManager!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
mockRouter = MockRouter(navigationController: MockNavigationController())
mockTabManager = MockTabManager()
}

override func tearDown() {
override func tearDown() async throws {
DependencyHelperMock().reset()
super.tearDown()
try await super.tearDown()
}

func testInitialState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ final class MicrosurveyMiddlewareIntegrationTests: XCTestCase, StoreTestUtility
var mockStore: MockStoreForMiddleware<AppState>!
var mockMicrosurveyTelemetry: MockMicrosurveyTelemetry!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
mockMicrosurveyTelemetry = MockMicrosurveyTelemetry()
DependencyHelperMock().bootstrapDependencies()
setupStore()
}

override func tearDown() {
override func tearDown() async throws {
mockMicrosurveyTelemetry = nil
DependencyHelperMock().reset()
resetStore()
super.tearDown()
try await super.tearDown()
}

func testDismissSurveyAction() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Common

@testable import Client

@MainActor
final class MicrosurveyViewControllerTests: XCTestCase {
let windowUUID: WindowUUID = .XCTestDefaultUUID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MockNavigationAction: WKNavigationAction {
}

// MARK: - MockURLAuthenticationChallengeSender
class MockURLAuthenticationChallengeSender: NSObject, URLAuthenticationChallengeSender {
final class MockURLAuthenticationChallengeSender: NSObject, URLAuthenticationChallengeSender {
func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge) {}

func continueWithoutCredential(for challenge: URLAuthenticationChallenge) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ final class MockTabQueue: TabQueue, @unchecked Sendable {
return succeed()
}

func getQueuedTabs(completion: @escaping @MainActor ([ShareItem]) -> Void) {
func getQueuedTabs(completion: @MainActor @Sendable @escaping ([ShareItem]) -> Void) {
Task { @MainActor in
completion(queuedTabs)
getQueuedTabsCalled += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
import UserNotifications
@testable import Client

class MockUserNotificationCenter: UserNotificationCenterProtocol {
class MockUserNotificationCenter: UserNotificationCenterProtocol, @unchecked Sendable {
var pendingRequests = [UNNotificationRequest]()

var getSettingsWasCalled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Common

@testable import Client

@MainActor
final class NativeErrorPageViewControllerTests: XCTestCase {
let windowUUID: WindowUUID = .XCTestDefaultUUID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import XCTest
class IntroViewControllerTests: XCTestCase {
var mockNotificationCenter: MockNotificationCenter!

override func setUp() {
super.setUp()
override func setUp() async throws {
try await super.setUp()
DependencyHelperMock().bootstrapDependencies()
mockNotificationCenter = MockNotificationCenter()
}

override func tearDown() {
super.tearDown()
override func tearDown() async throws {
mockNotificationCenter = nil
try await super.tearDown()
}

// Temp. Disabled: https://mozilla-hub.atlassian.net/browse/FXIOS-7505
Expand Down
Loading