Skip to content

Refactor FXIOS-12796 [Swift 6 Migration] Fix main actor isolation warnings that are Swift 6 errors in the XCUITests suite - Batch 2#2

Open
tomerqodo wants to merge 6 commits intocoderabbit_full_base__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2from
coderabbit_full_head__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2
Open

Refactor FXIOS-12796 [Swift 6 Migration] Fix main actor isolation warnings that are Swift 6 errors in the XCUITests suite - Batch 2#2
tomerqodo wants to merge 6 commits intocoderabbit_full_base__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2from
coderabbit_full_head__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2

Conversation

@tomerqodo
Copy link
Copy Markdown

@tomerqodo tomerqodo commented Jan 30, 2026

Benchmark PR from agentic-review-benchmarks#2

Summary by CodeRabbit

  • Tests
    • Updated test infrastructure to use asynchronous setup and teardown methods across the test suite for improved async/await compatibility.
    • Added main-thread isolation annotations to test utilities and navigation registration functions to enforce proper concurrency handling.
    • No changes to test logic or behavior; updates support modern Swift concurrency patterns.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

This PR systematically refactors the Firefox iOS test suite to adopt async/throws semantics for lifecycle methods and enforce main-thread safety through @MainActor annotations. Most test classes now have async throwing setUp()/tearDown() methods, while navigation and utility code gains @MainActor isolation markers. One test file removes its license header and replaces unsafe concurrency patterns.

Changes

Cohort / File(s) Summary
Async Lifecycle Updates - Test Classes
A11yOnboardingTests.swift, ActivityStreamTest.swift, BookmarksTests.swift, BrowsingPDFTests.swift, C_AddressesTests.swift, CookiePersistenceTests.swift, DatabaseFixtureTest.swift, DesktopModeTests.swift, DisplaySettingsTests.swift, DomainAutocompleteTests.swift, DragAndDropTests.swift, EngagementNotificationTests.swift, HistoryTests.swift, HomePageSettingsUITest.swift, InactiveTabsTest.swift, IntegrationTests.swift, LoginsTests.swift, MicrosurveyTests.swift, MultiWindowTests.swift, OnboardingTests.swift, PerformanceTests.swift, PhotonActionSheetTests.swift, PrivateBrowsingTest.swift, ReadingListTests.swift, TabsTests.swift, ToolbarTest.swift, URLValidationTests.swift, ZoomingTests.swift
Updated setUp() and/or tearDown() from synchronous to async throws, replacing super calls with try await super.setUp()/tearDown(). Enables async setup/teardown logic and error propagation in test initialization.
@mainactor on Navigation & Registration Functions
registerCommonNavigation.swift, registerContextMenuNavigation.swift, registerFxAccountNavigation.swift, registerHomePanelNavigation.swift, registerLibraryPanelNavigation.swift, registerMiscellanousActions.swift, registerMiscellanousNavigation.swift, registerMobileNavigation.swift, registerOnboardingNavigation.swift, registerSettingsNavigation.swift, registerTabMenuNavigation.swift, registerTabTrayNavigation.swift, registerToolbarNavigation.swift, registerTrackingProtection.swift, registerUrlBarNavigation.swift, registerZoomNavigation.swift
Added @MainActor attribute to registration/navigation functions, enforcing main-thread execution. No functional logic changes; purely concurrency isolation annotations.
Mixed Changes - Test Infrastructure
BaseTestCase.swift, FeatureFlaggedTestBase.swift, ScreenGraphTest.swift
Updated async lifecycle methods; added @MainActor annotations to class or module-level constants (urlBarAddress, homepageSearchBar). ScreenGraphTest gains class-level @MainActor. FeatureFlaggedTestBase reordered setUpExperimentVariables/setUpApp initialization.
@mainactor & Helper Functions
A11yUtils.swift, FxScreenGraph.swift, NavigationRegistry.swift, TodayWidgetTests.swift
Added @MainActor to class/function declarations. TodayWidgetTests replaced nonisolated(unsafe) with @MainActor on globals and introduced new private helper functions (widgetExist, goToTodayWidgetPage, checkPresenceFirefoxWidget, checkFirefoxShortcutsOptions). A11yUtils removed license header.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Poem

🐰 Async hops and main-thread bounds,
Our tests now safely synchronized sound,
With throws and awaits to catch the slip,
The test suite takes its async trip,
Forty files dance in harmony's grip! 🎪

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main change: a Swift 6 migration batch that fixes main actor isolation warnings in XCUITests suite.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tomerqodo
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tomerqodo
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 30, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@talshef
Copy link
Copy Markdown

talshef commented Feb 2, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 2, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift (1)

139-142: ⚠️ Potential issue | 🔴 Critical

Make forceRestartApp() async/throws to call async setUp/tearDown.

setUp() and tearDown() are declared as async throws (lines 112 and 119), so calling them from a sync method is a compile error and drops error handling.

Proposed fix
-    func forceRestartApp() {
-        tearDown()
-        setUp()
-    }
+    func forceRestartApp() async throws {
+        try await tearDown()
+        try await setUp()
+    }
firefox-ios/firefox-ios-tests/Tests/XCUITests/TodayWidgetTests.swift (1)

60-72: ⚠️ Potential issue | 🟠 Major

Bound the swipe loop to avoid hangs.

If the expected element never appears, this loop can run indefinitely and stall CI.

🛠️ Suggested guard against infinite swipes
 private func goToTodayWidgetPage() {
+    let maxSwipes = 5
+    var swipeCount = 0
     // Swipe right until the "Screen Time" icon appears
     if `#unavailable`(iOS 16) {
-        while !springboard.textFields["SpotlightSearchField"].exists {
+        while !springboard.textFields["SpotlightSearchField"].exists && swipeCount < maxSwipes {
             springboard.swipeRight()
+            swipeCount += 1
         }
+        XCTAssertTrue(
+            springboard.textFields["SpotlightSearchField"].exists,
+            "Failed to reach Today Widget page within \(maxSwipes) swipes."
+        )
     } else {
-        while !springboard.icons["Screen Time"].exists {
+        while !springboard.icons["Screen Time"].exists && swipeCount < maxSwipes {
             springboard.swipeRight()
+            swipeCount += 1
         }
+        XCTAssertTrue(
+            springboard.icons["Screen Time"].exists,
+            "Failed to reach Today Widget page within \(maxSwipes) swipes."
+        )
     }
 }
🤖 Fix all issues with AI agents
In `@firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift`:
- Around line 508-512: The call to super.setUp() inside BaseTestCase.setUp() is
missing the required try when awaiting an async throws method; update the
conditional branch where iPad() is true to call try await super.setUp()
(matching the pattern used in IphoneOnlyTestCase.setUp()) so the throwable async
initializer is properly propagated.

Comment on lines +508 to 512
override func setUp() async throws {
specificForPlatform = .pad
if iPad() {
super.setUp()
await super.setUp()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "BaseTestCase.swift" -type f

Repository: agentic-review-benchmarks/firefox-ios-combined-coderabbit

Length of output: 223


🏁 Script executed:

cat -n ./firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift | sed -n '500,520p'

Repository: agentic-review-benchmarks/firefox-ios-combined-coderabbit

Length of output: 797


🏁 Script executed:

cat -n ./firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift | sed -n '1,100p'

Repository: agentic-review-benchmarks/firefox-ios-combined-coderabbit

Length of output: 5195


🏁 Script executed:

cat -n ./firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift | sed -n '100,200p'

Repository: agentic-review-benchmarks/firefox-ios-combined-coderabbit

Length of output: 4097


🏁 Script executed:

cat -n ./firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift | sed -n '507,525p'

Repository: agentic-review-benchmarks/firefox-ios-combined-coderabbit

Length of output: 639


Add try when awaiting super.setUp() in iPad-only setup.
BaseTestCase.setUp() is async throws, so this call must be try await. See IphoneOnlyTestCase.setUp() at line 520 for the correct pattern.

Proposed fix
-        if iPad() {
-            await super.setUp()
-        }
+        if iPad() {
+            try await super.setUp()
+        }
🤖 Prompt for AI Agents
In `@firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift` around
lines 508 - 512, The call to super.setUp() inside BaseTestCase.setUp() is
missing the required try when awaiting an async throws method; update the
conditional branch where iPad() is true to call try await super.setUp()
(matching the pattern used in IphoneOnlyTestCase.setUp()) so the throwable async
initializer is properly propagated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants