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#28

Open
tomerqodo wants to merge 6 commits into
qodo_action_req_1_base__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2from
qodo_action_req_1_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#28
tomerqodo wants to merge 6 commits into
qodo_action_req_1_base__refactor_fxios-12796_swift_6_migration_fix_main_actor_isolation_warnings_that_are_swift_6_errors_in_the_xcuitests_suite_-_batch_2_pr2from
qodo_action_req_1_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

Benchmark PR from agentic-review-benchmarks#2

@qodo-code-review
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (3) 📎 Requirement gaps (0)

Grey Divider


Action required

1. A11yUtils.swift missing MPL header 📘 Rule violation ✓ Correctness
Description
• The Swift file no longer begins with the required Mozilla Public License v2.0 header comment
  block.
• This violates the licensing requirement for Swift source files and can create legal/compliance
  risk for redistributed source.
• The file currently starts directly with import XCTest, indicating the header is absent from the
  top of the file.
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/A11yUtils.swift[R1-4]

import XCTest

+@MainActor
class A11yUtils: XCTestCase {
Evidence
PR Compliance ID 7 requires the exact MPL v2.0 header at the very top of every .swift file. The
current A11yUtils.swift begins with import XCTest and contains no MPL header at the top.

AGENTS.md
firefox-ios/firefox-ios-tests/Tests/XCUITests/A11yUtils.swift[1-4]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`A11yUtils.swift` is missing the required Mozilla Public License v2.0 header at the top of the file.

## Issue Context
Compliance requires every `.swift` file to start with the exact MPL v2.0 header text.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/A11yUtils.swift[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. HomePageSettingsUITest.swift bad suffix 📘 Rule violation ✓ Correctness
Description
• The test file name HomePageSettingsUITest.swift does not follow the required *Test.swift /
  *Tests.swift naming convention.
• This reduces discoverability/consistency and violates the enforced test file naming standard.
• The file is actively modified in this PR (e.g., setUp signature), so it should be renamed to
  comply.
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/HomePageSettingsUITest.swift[R25-26]

+    override func setUp() async throws {
        // Test name looks like: "[Class testFunc]", parse out the function name
Evidence
PR Compliance ID 16 requires test files to end with Test.swift or Tests.swift. The modified file
path is HomePageSettingsUITest.swift, which ends with UITest.swift instead of the required
suffix.

AGENTS.md
firefox-ios/firefox-ios-tests/Tests/XCUITests/HomePageSettingsUITest.swift[1-26]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test file name does not comply with the required `*Test.swift` / `*Tests.swift` naming convention.

## Issue Context
The file is modified in this PR, so it should be renamed to meet the test naming standard and keep the suite consistent.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/HomePageSettingsUITest.swift[1-30]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. goToCopiedLink lacks access control 📘 Rule violation ✓ Correctness 👎 Not Recommended
Description
• New/modified top-level properties (e.g., goToCopiedLink, newPrivateSearch, urlBarAddress)
  are declared without an explicit access control modifier.
• This violates the requirement to declare explicit and minimal visibility
  (private/internal/public) and can unintentionally broaden API surface.
• Add explicit access control appropriate to intended scope (likely private for file-local
  globals; internal if shared across tests).
Recommendation (Dogfooding)
-----------------------------
Judge DogFooding
-----------------------------
• Judge Decision: 👎 NOT RECOMMENDED
• Reason: Repo already has many implicit-access top-level test globals; explicit modifiers likely
not enforced here.
• Reference PRs: None
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/TodayWidgetTests.swift[R15-22]

+@MainActor
+var goToCopiedLink = springboard.buttons["Go to Copied Link"]
+@MainActor
+var newPrivateSearch = springboard.buttons["New Private Search"]
+@MainActor
+var newSearch = springboard.buttons["New Search"]
+@MainActor
+var clearPrivateTabs = springboard.buttons["Clear Private Tabs"]
Evidence
PR Compliance ID 17 requires explicit access modifiers for properties/methods. The shown top-level
var/let declarations have no private/internal/public modifier, so their access level is
implicit.

AGENTS.md
firefox-ios/firefox-ios-tests/Tests/XCUITests/TodayWidgetTests.swift[14-22]
firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[10-16]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Several top-level properties/constants are declared with implicit access control, which violates the requirement for explicit and appropriate access modifiers.

## Issue Context
These globals were modified as part of Swift 6 concurrency changes (e.g., adding `@MainActor`), but still rely on implicit `internal` access.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/TodayWidgetTests.swift[14-42]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (4)
4. Missing try await 🐞 Bug ✓ Correctness
Description
IpadOnlyTestCase.setUp() calls await super.setUp() even though the superclass setUp() is
  async throws.
• This is a compile-time error that will block building the UI test target.
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[R508-512]

+    override func setUp() async throws {
        specificForPlatform = .pad
        if iPad() {
-            super.setUp()
+            await super.setUp()
        }
Evidence
BaseTestCase.setUp() is declared async throws, so any call to it must use try await.
IpadOnlyTestCase uses await without try, unlike IphoneOnlyTestCase which correctly uses `try
await`.

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[112-117]
firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[507-523]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`IpadOnlyTestCase.setUp()` calls a throwing async method without `try`, which is a compile error.

### Issue Context
`BaseTestCase.setUp()` is `async throws`, so platform-specific subclasses must call it with `try await`.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[507-523]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Restart helper now wrong 🐞 Bug ⛯ Reliability
Description
BaseTestCase.setUp/tearDown were migrated to async throws, but forceRestartApp() still calls
  synchronous tearDown()/setUp().
• This likely calls XCTest’s synchronous lifecycle methods (not BaseTestCase’s async ones), so the
  app may not actually restart and the screen graph may not be rebuilt.
• Tests relying on forceRestartApp() to validate persistence across restart become
  incorrect/flaky.
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[R112-122]

+    override func setUp() async throws {
+        try await super.setUp()
        continueAfterFailure = false
        setUpApp()
        setUpScreenGraph()
    }

-    override func tearDown() {
+    override func tearDown() async throws {
        app.terminate()
-        super.tearDown()
+        try await super.tearDown()
    }
Evidence
After the migration, the lifecycle hooks that contain the actual launch/terminate logic are the
async overrides. forceRestartApp() is synchronous and calls tearDown()/setUp() without
await, so it cannot invoke those async overrides. This helper is used by tests explicitly checking
behavior “after app restart”, so the behavioral change is impactful.

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[112-122]
firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[139-142]
firefox-ios/firefox-ios-tests/Tests/XCUITests/AuthenticationTest.swift[49-54]
firefox-ios/firefox-ios-tests/Tests/XCUITests/BookmarksTests.swift[396-404]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`forceRestartApp()` is synchronous but `BaseTestCase` lifecycle is now `async throws`. The helper can no longer reliably restart the app / rebuild state.

### Issue Context
Tests use `forceRestartApp()` to verify persistence across restart.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[112-122]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[139-142]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Sync tearDown skipped 🐞 Bug ⛯ Reliability
Description
• Several BaseTestCase-derived test classes still override *synchronous* tearDown() and call
  super.tearDown() (sync).
• With BaseTestCase now implementing tearDown() async throws, XCTest will use the async tear
  down path, so these synchronous overrides’ cleanup (orientation/theme reset, downloads cleanup) can
  be skipped.
• This risks cross-test pollution and UI-test flakiness (e.g., device left in landscape).
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[R119-122]

+    override func tearDown() async throws {
        app.terminate()
-        super.tearDown()
+        try await super.tearDown()
    }
Evidence
The base class now defines tearDown() async throws. The listed tests still override a different
method signature (tearDown() sync) and call super.tearDown() sync, so their cleanup logic is no
longer part of the async teardown flow provided by BaseTestCase.

firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[119-122]
firefox-ios/firefox-ios-tests/Tests/XCUITests/ToolbarMenuTests.swift[8-12]
firefox-ios/firefox-ios-tests/Tests/XCUITests/SettingsTests.swift[7-19]
firefox-ios/firefox-ios-tests/Tests/XCUITests/DownloadsTests.swift[15-41]
firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift[26-31]
firefox-ios/firefox-ios-tests/Tests/XCUITests/SwipingTabsTests.swift[8-12]
firefox-ios/firefox-ios-tests/Tests/XCUITests/HomeButtonTests.swift[7-11]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Some test classes still override synchronous `tearDown()`, which is now disconnected from the async teardown path.

### Issue Context
`BaseTestCase` teardown is now `async throws`. Subclasses should override the same signature to ensure cleanup runs.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[119-122]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/ToolbarMenuTests.swift[8-12]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/SettingsTests.swift[10-19]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/DownloadsTests.swift[18-41]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift[28-31]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/SwipingTabsTests.swift[9-12]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/HomeButtonTests.swift[8-11]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Feature suite order crash 🐞 Bug ✓ Correctness
Description
FeatureFlaggedTestSuite.setUp() now calls setUpApp() before setUpExperimentVariables().
• But setUpApp() immediately uses jsonFileName/featureName, which are String! and documented
  to be set inside setUpExperimentVariables().
• If this base class is used, it can crash with an unexpected nil unwrap during setup.
Code

firefox-ios/firefox-ios-tests/Tests/XCUITests/FeatureFlaggedTestBase.swift[R46-52]

+    override func setUp() async throws {
        continueAfterFailure = false
-        setUpExperimentVariables()
        setUpApp()
+        setUpExperimentVariables()
        setUpLaunchArguments()
        setUpScreenGraph()
    }
Evidence
jsonFileName and featureName are implicitly-unwrapped optionals intended to be initialized by
setUpExperimentVariables(). The new call order invokes setUpApp() first, which uses those IUOs
immediately.

firefox-ios/firefox-ios-tests/Tests/XCUITests/FeatureFlaggedTestBase.swift[37-52]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`FeatureFlaggedTestSuite.setUp()` uses IUO properties before they are initialized.

### Issue Context
`jsonFileName` / `featureName` are expected to be set by `setUpExperimentVariables()`.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/FeatureFlaggedTestBase.swift[37-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



ⓘ The new review experience is currently in Beta. Learn more

Qodo Logo

Comment on lines 1 to 4
import XCTest

@MainActor
class A11yUtils: XCTestCase {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. a11yutils.swift missing mpl header 📘 Rule violation ✓ Correctness

• The Swift file no longer begins with the required Mozilla Public License v2.0 header comment
  block.
• This violates the licensing requirement for Swift source files and can create legal/compliance
  risk for redistributed source.
• The file currently starts directly with import XCTest, indicating the header is absent from the
  top of the file.
Agent prompt
## Issue description
`A11yUtils.swift` is missing the required Mozilla Public License v2.0 header at the top of the file.

## Issue Context
Compliance requires every `.swift` file to start with the exact MPL v2.0 header text.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/A11yUtils.swift[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +25 to 26
override func setUp() async throws {
// Test name looks like: "[Class testFunc]", parse out the function name
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. homepagesettingsuitest.swift bad suffix 📘 Rule violation ✓ Correctness

• The test file name HomePageSettingsUITest.swift does not follow the required *Test.swift /
  *Tests.swift naming convention.
• This reduces discoverability/consistency and violates the enforced test file naming standard.
• The file is actively modified in this PR (e.g., setUp signature), so it should be renamed to
  comply.
Agent prompt
## Issue description
The test file name does not comply with the required `*Test.swift` / `*Tests.swift` naming convention.

## Issue Context
The file is modified in this PR, so it should be renamed to meet the test naming standard and keep the suite consistent.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/HomePageSettingsUITest.swift[1-30]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +15 to +22
@MainActor
var goToCopiedLink = springboard.buttons["Go to Copied Link"]
@MainActor
var newPrivateSearch = springboard.buttons["New Private Search"]
@MainActor
var newSearch = springboard.buttons["New Search"]
@MainActor
var clearPrivateTabs = springboard.buttons["Clear Private Tabs"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. gotocopiedlink lacks access control 📘 Rule violation ✓ Correctness

• New/modified top-level properties (e.g., goToCopiedLink, newPrivateSearch, urlBarAddress)
  are declared without an explicit access control modifier.
• This violates the requirement to declare explicit and minimal visibility
  (private/internal/public) and can unintentionally broaden API surface.
• Add explicit access control appropriate to intended scope (likely private for file-local
  globals; internal if shared across tests).
Agent prompt
## Issue description
Several top-level properties/constants are declared with implicit access control, which violates the requirement for explicit and appropriate access modifiers.

## Issue Context
These globals were modified as part of Swift 6 concurrency changes (e.g., adding `@MainActor`), but still rely on implicit `internal` access.

## Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/TodayWidgetTests.swift[14-42]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[10-16]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

Action required

4. Missing try await 🐞 Bug ✓ Correctness

IpadOnlyTestCase.setUp() calls await super.setUp() even though the superclass setUp() is
  async throws.
• This is a compile-time error that will block building the UI test target.
Agent prompt
### Issue description
`IpadOnlyTestCase.setUp()` calls a throwing async method without `try`, which is a compile error.

### Issue Context
`BaseTestCase.setUp()` is `async throws`, so platform-specific subclasses must call it with `try await`.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[507-523]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +112 to 122
override func setUp() async throws {
try await super.setUp()
continueAfterFailure = false
setUpApp()
setUpScreenGraph()
}

override func tearDown() {
override func tearDown() async throws {
app.terminate()
super.tearDown()
try await super.tearDown()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

5. Restart helper now wrong 🐞 Bug ⛯ Reliability

BaseTestCase.setUp/tearDown were migrated to async throws, but forceRestartApp() still calls
  synchronous tearDown()/setUp().
• This likely calls XCTest’s synchronous lifecycle methods (not BaseTestCase’s async ones), so the
  app may not actually restart and the screen graph may not be rebuilt.
• Tests relying on forceRestartApp() to validate persistence across restart become
  incorrect/flaky.
Agent prompt
### Issue description
`forceRestartApp()` is synchronous but `BaseTestCase` lifecycle is now `async throws`. The helper can no longer reliably restart the app / rebuild state.

### Issue Context
Tests use `forceRestartApp()` to verify persistence across restart.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[112-122]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[139-142]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +119 to 122
override func tearDown() async throws {
app.terminate()
super.tearDown()
try await super.tearDown()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

6. Sync teardown skipped 🐞 Bug ⛯ Reliability

• Several BaseTestCase-derived test classes still override *synchronous* tearDown() and call
  super.tearDown() (sync).
• With BaseTestCase now implementing tearDown() async throws, XCTest will use the async tear
  down path, so these synchronous overrides’ cleanup (orientation/theme reset, downloads cleanup) can
  be skipped.
• This risks cross-test pollution and UI-test flakiness (e.g., device left in landscape).
Agent prompt
### Issue description
Some test classes still override synchronous `tearDown()`, which is now disconnected from the async teardown path.

### Issue Context
`BaseTestCase` teardown is now `async throws`. Subclasses should override the same signature to ensure cleanup runs.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/BaseTestCase.swift[119-122]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/ToolbarMenuTests.swift[8-12]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/SettingsTests.swift[10-19]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/DownloadsTests.swift[18-41]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/DragAndDropTests.swift[28-31]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/SwipingTabsTests.swift[9-12]
- firefox-ios/firefox-ios-tests/Tests/XCUITests/HomeButtonTests.swift[8-11]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +46 to 52
override func setUp() async throws {
continueAfterFailure = false
setUpExperimentVariables()
setUpApp()
setUpExperimentVariables()
setUpLaunchArguments()
setUpScreenGraph()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

7. Feature suite order crash 🐞 Bug ✓ Correctness

FeatureFlaggedTestSuite.setUp() now calls setUpApp() before setUpExperimentVariables().
• But setUpApp() immediately uses jsonFileName/featureName, which are String! and documented
  to be set inside setUpExperimentVariables().
• If this base class is used, it can crash with an unexpected nil unwrap during setup.
Agent prompt
### Issue description
`FeatureFlaggedTestSuite.setUp()` uses IUO properties before they are initialized.

### Issue Context
`jsonFileName` / `featureName` are expected to be set by `setUpExperimentVariables()`.

### Fix Focus Areas
- firefox-ios/firefox-ios-tests/Tests/XCUITests/FeatureFlaggedTestBase.swift[37-52]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

2 participants