From ebbb75ef1bd191b198dda1ddce5ff927f621f169 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 7 Jun 2025 23:02:41 +0100 Subject: [PATCH] Fix Swift tests after error handling improvements --- docs/RELEASING.md | 1 + .../Tests/peekabooTests/ListCommandTests.swift | 3 ++- .../Tests/peekabooTests/ModelsTests.swift | 18 +++++++++--------- .../PermissionsCheckerTests.swift | 18 ++++++------------ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 6a66fb6..9ad3825 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -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 ` ## Post-Publish Steps diff --git a/peekaboo-cli/Tests/peekabooTests/ListCommandTests.swift b/peekaboo-cli/Tests/peekabooTests/ListCommandTests.swift index ba12c61..80687d9 100644 --- a/peekaboo-cli/Tests/peekabooTests/ListCommandTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/ListCommandTests.swift @@ -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 { diff --git a/peekaboo-cli/Tests/peekabooTests/ModelsTests.swift b/peekaboo-cli/Tests/peekabooTests/ModelsTests.swift index 97a78cf..0722c38 100644 --- a/peekaboo-cli/Tests/peekabooTests/ModelsTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/ModelsTests.swift @@ -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() { diff --git a/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift b/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift index aaf30b2..a0abfc2 100644 --- a/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift @@ -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