Fix Swift tests after error handling improvements

This commit is contained in:
Peter Steinberger 2025-06-07 23:02:41 +01:00
parent 94c09b1c7a
commit ebbb75ef1b
4 changed files with 18 additions and 22 deletions

View file

@ -63,6 +63,7 @@ If all checks pass, follow the manual steps below.
2. **Actual NPM Publish:**
- If the dry run is satisfactory, proceed with the actual publish command.
- Use tag "beta" if the version is a beta, else omit tag to do a release version.
- `npm publish --access public --tag <your_tag>`
## Post-Publish Steps

View file

@ -7,9 +7,10 @@ final class ListCommandTests: XCTestCase {
func testListCommandSubcommands() throws {
// Test that ListCommand has the expected subcommands
XCTAssertEqual(ListCommand.configuration.subcommands.count, 2)
XCTAssertEqual(ListCommand.configuration.subcommands.count, 3)
XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == AppsSubcommand.self })
XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == WindowsSubcommand.self })
XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == ServerStatusSubcommand.self })
}
func testAppsSubcommandParsing() throws {

View file

@ -215,20 +215,20 @@ final class ModelsTests: XCTestCase {
}
func testCaptureErrorDescriptions() {
XCTAssertEqual(CaptureError.noDisplaysAvailable.errorDescription, "No displays available for capture")
XCTAssertEqual(CaptureError.noDisplaysAvailable.errorDescription, "No displays available for capture.")
XCTAssertTrue(
CaptureError.capturePermissionDenied.errorDescription!.contains("Screen recording permission denied")
CaptureError.screenRecordingPermissionDenied.errorDescription!.contains("Screen recording permission is required")
)
XCTAssertEqual(CaptureError.invalidDisplayID.errorDescription, "Invalid display ID")
XCTAssertEqual(CaptureError.captureCreationFailed.errorDescription, "Failed to create screen capture")
XCTAssertEqual(CaptureError.windowNotFound.errorDescription, "Window not found")
XCTAssertEqual(CaptureError.windowCaptureFailed.errorDescription, "Failed to capture window")
XCTAssertEqual(CaptureError.invalidDisplayID.errorDescription, "Invalid display ID provided.")
XCTAssertEqual(CaptureError.captureCreationFailed.errorDescription, "Failed to create the screen capture.")
XCTAssertEqual(CaptureError.windowNotFound.errorDescription, "The specified window could not be found.")
XCTAssertEqual(CaptureError.windowCaptureFailed.errorDescription, "Failed to capture the specified window.")
XCTAssertEqual(
CaptureError.fileWriteError("/tmp/test.png").errorDescription,
"Failed to write file to: /tmp/test.png"
"Failed to write capture file to path: /tmp/test.png."
)
XCTAssertEqual(CaptureError.appNotFound("Safari").errorDescription, "Application not found: Safari")
XCTAssertEqual(CaptureError.invalidWindowIndex(5).errorDescription, "Invalid window index: 5")
XCTAssertEqual(CaptureError.appNotFound("Safari").errorDescription, "Application with identifier 'Safari' not found or is not running.")
XCTAssertEqual(CaptureError.invalidWindowIndex(5).errorDescription, "Invalid window index: 5.")
}
func testWindowData() {

View file

@ -63,24 +63,18 @@ final class PermissionsCheckerTests: XCTestCase {
// MARK: - Permission State Tests
func testPermissionErrors() {
// Test permission error types
let screenError = PermissionError.screenRecordingDenied
let accessError = PermissionError.accessibilityDenied
XCTAssertNotNil(screenError)
XCTAssertNotNil(accessError)
}
// MARK: - Error Handling Tests
func testCaptureError() {
// Test error creation for permission denied
let error = CaptureError.capturePermissionDenied
let screenError = CaptureError.screenRecordingPermissionDenied
let accessError = CaptureError.accessibilityPermissionDenied
// CaptureError conforms to LocalizedError, so it has errorDescription
XCTAssertNotNil(error.errorDescription)
XCTAssertTrue(error.errorDescription?.contains("permission") ?? false)
XCTAssertNotNil(screenError.errorDescription)
XCTAssertNotNil(accessError.errorDescription)
XCTAssertTrue(screenError.errorDescription?.contains("Screen recording permission") ?? false)
XCTAssertTrue(accessError.errorDescription?.contains("Accessibility permission") ?? false)
}
// MARK: - Performance Tests