Skip to content

Add XCTest target with 49 tests (KeyboardShortcut, PreferencesManager, WindowManager)#174

Merged
pablopunk merged 1 commit into
mainfrom
fractal-Swift-Shift-work-173-add-test-coverage-swiftshift-modules-https-5c9ad6
Jun 20, 2026
Merged

Add XCTest target with 49 tests (KeyboardShortcut, PreferencesManager, WindowManager)#174
pablopunk merged 1 commit into
mainfrom
fractal-Swift-Shift-work-173-add-test-coverage-swiftshift-modules-https-5c9ad6

Conversation

@pablopunk

@pablopunk pablopunk commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Closes #173

What

Adds the project's first test target with 49 unit tests covering the three most testable modules.

Test suites

  • KeyboardShortcutTests (26) — encoding/decoding, display strings, modifier flags, equatable, JSON roundtrip
  • PreferencesManagerTests (17) — ignored app CRUD, caching, migration, system app protection
  • WindowManagerTests (6) — coordinate conversion, window bounds calculation

Changes

  • New SwiftShiftTests unit test bundle with @testable import Swift_Shift_Dev
  • make test target added to Makefile
  • CI workflow updated with parallel test job on PRs and main pushes
  • Scheme updated with code coverage disabled (avoids SPM linking issue)

Not in scope

  • MouseTracker, ShortcutsManager, CGEventSupervisor — tightly coupled to system event taps/AXUIElement, need refactoring for testability

Summary by CodeRabbit

  • Chores

    • Updated build pipeline to include automated testing.
    • Added test infrastructure and build configurations to project.
  • Tests

    • Introduced comprehensive test suites for keyboard shortcuts, preferences, and window management functionality.

…ger, WindowManager

- New SwiftShiftTests unit test bundle with @testable import
- 26 KeyboardShortcut tests: encoding, display strings, modifier flags, equatable
- 17 PreferencesManager tests: ignored app CRUD, caching, migration, system protection
- 6 WindowManager tests: coordinate conversion, window bounds calculation
- Added 'make test' target to Makefile
- Updated CI workflow with parallel test job on PRs and main pushes
- Closes #173
@codesandbox

codesandbox Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
swiftshift-app Ready Ready Preview, Comment Jun 20, 2026 9:12pm

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The PR introduces a SwiftShiftTests XCTest unit-test target into the Xcode project, wired with BUNDLE_LOADER/TEST_HOST pointing at the main app executable, a PBXTargetDependency on the Swift Shift target, and ENABLE_TESTABILITY = YES on the app's Debug configuration. The shared scheme is updated to build and run SwiftShiftTests.xctest. A test target is added to the Makefile and a new test job is added to the GitHub Actions workflow, both invoking xcodebuild test with code signing disabled. Three test suites are added: KeyboardShortcutTests, PreferencesManagerTests, and WindowManagerTests.

Possibly related issues

  • #173 – Add test coverage for SwiftShift modules: This PR directly addresses the issue by adding a SwiftShiftTests XCTest target with unit tests for WindowManager, PreferencesManager, and KeyboardShortcut, and integrates test execution into GitHub Actions CI.

Possibly related PRs

  • pablopunk/SwiftShift#112: Both PRs modify the Makefile's xcodebuild invocation to disable code signing — the prior PR for the build target, this PR for the new test target.
  • pablopunk/SwiftShift#134: This PR's KeyboardShortcutTests directly exercises KeyboardShortcut model behavior and modifier-mask logic that was introduced or changed in the retrieved PR's ShortcutsManager.swift.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.37% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an XCTest target with 49 tests for three core modules.
Linked Issues check ✅ Passed The PR successfully implements XCTest unit tests covering WindowManager, KeyboardShortcut, and PreferencesManager as identified in #173.
Out of Scope Changes check ✅ Passed All changes are scope-appropriate: test infrastructure (Makefile, workflow, scheme), test target setup (xcodeproj), and test files for specified modules only.

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


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (1)
SwiftShiftTests/PreferencesManagerTests.swift (1)

147-158: ⚡ Quick win

Avoid hardcoding one specific default app bundle ID in this behavior test.

Using a literal default ID makes this test fail on harmless default-list updates. Assert against DEFAULT_IGNORED_APP_BUNDLE_ID instead.

Proposed test hardening
-        // Default apps are initially ignored
-        XCTAssertTrue(PreferencesManager.isAppIgnored("pl.maketheweb.cleanshotx"))
+        // At least one default app should be initially ignored
+        XCTAssertTrue(
+            DEFAULT_IGNORED_APP_BUNDLE_ID.contains { PreferencesManager.isAppIgnored($0) }
+        )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SwiftShiftTests/PreferencesManagerTests.swift` around lines 147 - 158, The
testIsAppIgnored_checksBothLists test is hardcoding a specific default app
bundle ID ("pl.maketheweb.cleanshotx") in the assertion which makes the test
brittle to default list updates. Replace the hardcoded bundle ID string in the
XCTAssertTrue call with a reference to the DEFAULT_IGNORED_APP_BUNDLE_ID
constant instead, ensuring the test validates the behavior of checking default
ignored apps without depending on a specific app remaining in that list.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build.yml:
- Line 1: The workflow file is missing an explicit permissions block at the top
level, which causes it to use broader default GITHUB_TOKEN scopes than
necessary. Add a permissions block immediately after the name field in the Build
& Test workflow that specifies only the minimum required permissions needed by
the workflow's jobs. This should follow GitHub's least-privilege principle and
restrict token access to only what is necessary for the workflow to function.
- Line 24: The actions/checkout action at line 24 uses a tag-based reference
(v4) instead of a pinned commit SHA, and does not disable credential
persistence. Replace the tag reference with a specific commit SHA (e.g.,
actions/checkout@<full-commit-hash>) and add a with section that sets
persist-credentials to false to reduce supply-chain and token exposure risks.
Apply this same fix consistently to the actions/checkout references at line 18
in build.yml and in www.yml as mentioned in the comment.

In `@Swift` Shift.xcodeproj/project.pbxproj:
- Around line 595-630: The SwiftShiftTests target has a higher deployment target
than the app, blocking tests from running on supported environments. Lower the
MACOSX_DEPLOYMENT_TARGET setting from 14.0 to 13.0 in both the Release
configuration (291EF055A6868417DA4ECDEC) and Debug configuration
(47FCE1967DC1C8CDFFAFC909) for SwiftShiftTests to match the app target
deployment version.
- Line 94: The Foundation.framework file reference F8B92CDB5F568BDAA9756F45 has
a hard-coded path that includes a specific SDK version (MacOSX15.0.sdk), which
breaks across machines with different SDK installations. Replace the hard-coded
SDK version path with a relative reference or use Xcode build variables. Either
remove the explicit path to let Xcode resolve the framework from the current
SDK, or use dynamic build variables like $(SDKROOT) in the path to make it
adaptive to the developer's installed Xcode version.

In `@Swift` Shift.xcodeproj/xcshareddata/xcschemes/Swift Shift.xcscheme:
- Around line 31-35: The BlueprintIdentifier value for the SwiftShiftTests
target in the scheme file does not match the actual target ID defined in the
project.pbxproj file, causing test resolution failures. Locate the correct
BlueprintIdentifier for the SwiftShiftTests target by checking the
project.pbxproj file, then update the BlueprintIdentifier attribute in the
BuildableReference elements for SwiftShiftTests in both the BuildActionEntry
section and the TestableReference section of the scheme to use the correct
matching target ID.

In `@SwiftShiftTests/PreferencesManagerTests.swift`:
- Around line 192-206: The testMigration_addsDefaultAppsWhenMissing test only
validates that the custom app and migration flag are present, but it does not
actually verify that the default apps were merged during migration. Add
assertions after retrieving apps from PreferencesManager.getUserIgnoredApps() to
check that the returned apps collection contains the expected default app
identifiers (in addition to the custom "com.example.only" entry). This ensures
the migration logic is truly adding defaults instead of just setting a flag.

---

Nitpick comments:
In `@SwiftShiftTests/PreferencesManagerTests.swift`:
- Around line 147-158: The testIsAppIgnored_checksBothLists test is hardcoding a
specific default app bundle ID ("pl.maketheweb.cleanshotx") in the assertion
which makes the test brittle to default list updates. Replace the hardcoded
bundle ID string in the XCTAssertTrue call with a reference to the
DEFAULT_IGNORED_APP_BUNDLE_ID constant instead, ensuring the test validates the
behavior of checking default ignored apps without depending on a specific app
remaining in that list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78dafc08-352f-45a9-987a-b3f54c04bf57

📥 Commits

Reviewing files that changed from the base of the PR and between 3456dd4 and 3b68520.

📒 Files selected for processing (7)
  • .github/workflows/build.yml
  • Makefile
  • Swift Shift.xcodeproj/project.pbxproj
  • Swift Shift.xcodeproj/xcshareddata/xcschemes/Swift Shift.xcscheme
  • SwiftShiftTests/KeyboardShortcutTests.swift
  • SwiftShiftTests/PreferencesManagerTests.swift
  • SwiftShiftTests/WindowManagerTests.swift

@@ -1,4 +1,4 @@
name: Build
name: Build & Test

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 | 🟠 Major | ⚡ Quick win

Set explicit least-privilege token permissions for this workflow.

Without a permissions block, the workflow uses broader default GITHUB_TOKEN scopes than needed.

🔧 Suggested fix
 name: Build & Test
+
+permissions:
+  contents: read
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: Build & Test
name: Build & Test
permissions:
contents: read
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 1-34: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml at line 1, The workflow file is missing an
explicit permissions block at the top level, which causes it to use broader
default GITHUB_TOKEN scopes than necessary. Add a permissions block immediately
after the name field in the Build & Test workflow that specifies only the
minimum required permissions needed by the workflow's jobs. This should follow
GitHub's least-privilege principle and restrict token access to only what is
necessary for the workflow to function.

Source: Linters/SAST tools

test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

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 | 🟠 Major

🧩 Analysis chain

🌐 Web query:

What is the latest stable commit SHA for actions/checkout v4, from the official GitHub repository releases/tags?

💡 Result:

As of June 20, 2026, the latest stable tag for actions/checkout in the v4 series is v4.3.1. The official commit SHA for this tag is 34e114876b6d76451613b52a51d8975971439246 [1]. Please note that while the v4 branch continues to receive maintenance, newer versions of the action (such as v6) are also available [2][3]. Users are encouraged to refer to the official actions/checkout GitHub releases page for the most current information [2].

Citations:


🏁 Script executed:

# Check the build.yml file around line 24
cat -n .github/workflows/build.yml | sed -n '15,35p'

Repository: pablopunk/SwiftShift

Length of output: 749


🏁 Script executed:

# Search for all action usages in the workflows directory to assess scope
rg "uses:" .github/workflows/ -A 1 -B 1

Repository: pablopunk/SwiftShift

Length of output: 750


Pin actions/checkout to a commit SHA and disable credential persistence.

Using tag-based action refs (e.g., v4) instead of commit SHAs and relying on default credential persistence increases supply-chain and token exposure risk.

🔧 Suggested fix
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@34e114876b6d76451613b52a51d8975971439246
+        with:
+          persist-credentials: false

Note: This same issue exists at line 18 of build.yml and in www.yml. Apply the fix consistently across all workflow files.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@34e114876b6d76451613b52a51d8975971439246
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 24-24: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/build.yml at line 24, The actions/checkout action at line
24 uses a tag-based reference (v4) instead of a pinned commit SHA, and does not
disable credential persistence. Replace the tag reference with a specific commit
SHA (e.g., actions/checkout@<full-commit-hash>) and add a with section that sets
persist-credentials to false to reduce supply-chain and token exposure risks.
Apply this same fix consistently to the actions/checkout references at line 18
in build.yml and in www.yml as mentioned in the comment.

Source: Linters/SAST tools

E2D8CFB82B3C3B9B00EBB047 /* PermissionsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermissionsManager.swift; sourceTree = "<group>"; };
E2E6F5E92B3EF03C005B0D96 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
F400D7AF72C65A047C5C9D19 /* Constants.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Constants.swift; path = "Swift Shift/src/Constants.swift"; sourceTree = "<group>"; };
F8B92CDB5F568BDAA9756F45 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };

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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether SDK-version-pinned system framework paths exist in pbxproj.
rg -n 'MacOSX[0-9]+\.[0-9]+\.sdk/.*/Foundation\.framework' "Swift Shift.xcodeproj/project.pbxproj"

Repository: pablopunk/SwiftShift

Length of output: 358


🏁 Script executed:

cat -n "Swift Shift.xcodeproj/project.pbxproj" | sed -n '90,120p'

Repository: pablopunk/SwiftShift

Length of output: 2208


🏁 Script executed:

# Search for all SDK-version-pinned framework paths in the pbxproj
rg -n 'MacOSX[0-9]+\.[0-9]+\.sdk.*\.framework' "Swift Shift.xcodeproj/project.pbxproj"

Repository: pablopunk/SwiftShift

Length of output: 358


Hard-coded SDK path for Foundation is brittle across Xcode versions.

The file reference at line 94 points to a versioned SDK path (MacOSX15.0.sdk) under DEVELOPER_DIR. This can break project loading/builds on machines with different installed SDK versions.

🔧 Suggested fix
- F8B92CDB5F568BDAA9756F45 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
+ F8B92CDB5F568BDAA9756F45 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Swift` Shift.xcodeproj/project.pbxproj at line 94, The Foundation.framework
file reference F8B92CDB5F568BDAA9756F45 has a hard-coded path that includes a
specific SDK version (MacOSX15.0.sdk), which breaks across machines with
different SDK installations. Replace the hard-coded SDK version path with a
relative reference or use Xcode build variables. Either remove the explicit path
to let Xcode resolve the framework from the current SDK, or use dynamic build
variables like $(SDKROOT) in the path to make it adaptive to the developer's
installed Xcode version.

Comment on lines +595 to +630
291EF055A6868417DA4ECDEC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift.app/Contents/MacOS/Swift Shift";
};
name = Release;
};
47FCE1967DC1C8CDFFAFC909 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift Dev.app/Contents/MacOS/Swift Shift Dev";
};
name = Debug;
};

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 | 🟠 Major | ⚡ Quick win

Test target deployment target is higher than the app target.

SwiftShiftTests is set to macOS 14.0 while the app target is 13.0. This blocks running tests on environments that can still build/run the app.

🔧 Suggested fix
- MACOSX_DEPLOYMENT_TARGET = 14.0;
+ MACOSX_DEPLOYMENT_TARGET = 13.0;

(Apply in both SwiftShiftTests Debug and Release build settings.)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
291EF055A6868417DA4ECDEC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift.app/Contents/MacOS/Swift Shift";
};
name = Release;
};
47FCE1967DC1C8CDFFAFC909 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift Dev.app/Contents/MacOS/Swift Shift Dev";
};
name = Debug;
};
291EF055A6868417DA4ECDEC /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"`@loader_path/`../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift.app/Contents/MacOS/Swift Shift";
};
name = Release;
};
47FCE1967DC1C8CDFFAFC909 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"`@loader_path/`../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pablopunk.SwiftShiftTests;
PRODUCT_NAME = SwiftShiftTests;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Swift Shift Dev.app/Contents/MacOS/Swift Shift Dev";
};
name = Debug;
};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Swift` Shift.xcodeproj/project.pbxproj around lines 595 - 630, The
SwiftShiftTests target has a higher deployment target than the app, blocking
tests from running on supported environments. Lower the MACOSX_DEPLOYMENT_TARGET
setting from 14.0 to 13.0 in both the Release configuration
(291EF055A6868417DA4ECDEC) and Debug configuration (47FCE1967DC1C8CDFFAFC909)
for SwiftShiftTests to match the app target deployment version.

Comment on lines +31 to +35
BlueprintIdentifier = "D76A70D72EB4AAB358AE0D75"
BuildableName = "SwiftShiftTests.xctest"
BlueprintName = "SwiftShiftTests"
ReferencedContainer = "container:Swift Shift.xcodeproj">
</BuildableReference>

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 | ⚡ Quick win

Scheme references a non-existent test target ID.

The BlueprintIdentifier for SwiftShiftTests in the scheme does not match the target ID defined in Swift Shift.xcodeproj/project.pbxproj, so xcodebuild test can fail to resolve the test bundle.

🔧 Suggested fix
- BlueprintIdentifier = "D76A70D72EB4AAB358AE0D75"
+ BlueprintIdentifier = "4F0E66367D37633ED8A08262"

(Apply to both BuildActionEntry and TestableReference.)

Also applies to: 51-55

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Swift` Shift.xcodeproj/xcshareddata/xcschemes/Swift Shift.xcscheme around
lines 31 - 35, The BlueprintIdentifier value for the SwiftShiftTests target in
the scheme file does not match the actual target ID defined in the
project.pbxproj file, causing test resolution failures. Locate the correct
BlueprintIdentifier for the SwiftShiftTests target by checking the
project.pbxproj file, then update the BlueprintIdentifier attribute in the
BuildableReference elements for SwiftShiftTests in both the BuildActionEntry
section and the TestableReference section of the scheme to use the correct
matching target ID.

Comment on lines +192 to +206
func testMigration_addsDefaultAppsWhenMissing() {
// Reset migration flag
UserDefaults.standard.removeObject(forKey: PreferenceKey.didMigrateDefaultIgnoredApps.rawValue)
PreferencesManager.invalidateIgnoredAppsCache()

// Set a custom list without defaults
PreferencesManager.setUserIgnoredApps(["com.example.only"])

// First call to getUserIgnoredApps should trigger migration
let apps = PreferencesManager.getUserIgnoredApps()
XCTAssertTrue(apps.contains("com.example.only"))

// After migration, the migration flag should be set
XCTAssertTrue(UserDefaults.standard.bool(forKey: PreferenceKey.didMigrateDefaultIgnoredApps.rawValue))
}

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 | 🟠 Major | ⚡ Quick win

Assert the migration effect, not just the migration flag.

testMigration_addsDefaultAppsWhenMissing can pass even if defaults are never merged, because it only checks the custom app and migration flag. Validate that migrated defaults are present in apps.

Proposed test fix
     let apps = PreferencesManager.getUserIgnoredApps()
     XCTAssertTrue(apps.contains("com.example.only"))
+    XCTAssertTrue(
+        DEFAULT_IGNORED_APP_BUNDLE_ID.allSatisfy { apps.contains($0) },
+        "Migration should merge all default ignored apps into the existing user list"
+    )

     // After migration, the migration flag should be set
     XCTAssertTrue(UserDefaults.standard.bool(forKey: PreferenceKey.didMigrateDefaultIgnoredApps.rawValue))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SwiftShiftTests/PreferencesManagerTests.swift` around lines 192 - 206, The
testMigration_addsDefaultAppsWhenMissing test only validates that the custom app
and migration flag are present, but it does not actually verify that the default
apps were merged during migration. Add assertions after retrieving apps from
PreferencesManager.getUserIgnoredApps() to check that the returned apps
collection contains the expected default app identifiers (in addition to the
custom "com.example.only" entry). This ensures the migration logic is truly
adding defaults instead of just setting a flag.

@pablopunk
pablopunk merged commit c33fb5a into main Jun 20, 2026
7 checks passed
@pablopunk
pablopunk deleted the fractal-Swift-Shift-work-173-add-test-coverage-swiftshift-modules-https-5c9ad6 branch June 20, 2026 21:19
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.

Add test coverage for SwiftShift modules

1 participant