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:** 2. **Actual NPM Publish:**
- If the dry run is satisfactory, proceed with the actual publish command. - 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>` - `npm publish --access public --tag <your_tag>`
## Post-Publish Steps ## Post-Publish Steps

View file

@ -7,9 +7,10 @@ final class ListCommandTests: XCTestCase {
func testListCommandSubcommands() throws { func testListCommandSubcommands() throws {
// Test that ListCommand has the expected subcommands // 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 == AppsSubcommand.self })
XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == WindowsSubcommand.self }) XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == WindowsSubcommand.self })
XCTAssertTrue(ListCommand.configuration.subcommands.contains { $0 == ServerStatusSubcommand.self })
} }
func testAppsSubcommandParsing() throws { func testAppsSubcommandParsing() throws {

View file

@ -215,20 +215,20 @@ final class ModelsTests: XCTestCase {
} }
func testCaptureErrorDescriptions() { func testCaptureErrorDescriptions() {
XCTAssertEqual(CaptureError.noDisplaysAvailable.errorDescription, "No displays available for capture") XCTAssertEqual(CaptureError.noDisplaysAvailable.errorDescription, "No displays available for capture.")
XCTAssertTrue( 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.invalidDisplayID.errorDescription, "Invalid display ID provided.")
XCTAssertEqual(CaptureError.captureCreationFailed.errorDescription, "Failed to create screen capture") XCTAssertEqual(CaptureError.captureCreationFailed.errorDescription, "Failed to create the screen capture.")
XCTAssertEqual(CaptureError.windowNotFound.errorDescription, "Window not found") XCTAssertEqual(CaptureError.windowNotFound.errorDescription, "The specified window could not be found.")
XCTAssertEqual(CaptureError.windowCaptureFailed.errorDescription, "Failed to capture window") XCTAssertEqual(CaptureError.windowCaptureFailed.errorDescription, "Failed to capture the specified window.")
XCTAssertEqual( XCTAssertEqual(
CaptureError.fileWriteError("/tmp/test.png").errorDescription, 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.appNotFound("Safari").errorDescription, "Application with identifier 'Safari' not found or is not running.")
XCTAssertEqual(CaptureError.invalidWindowIndex(5).errorDescription, "Invalid window index: 5") XCTAssertEqual(CaptureError.invalidWindowIndex(5).errorDescription, "Invalid window index: 5.")
} }
func testWindowData() { func testWindowData() {

View file

@ -63,24 +63,18 @@ final class PermissionsCheckerTests: XCTestCase {
// MARK: - Permission State Tests // 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 // MARK: - Error Handling Tests
func testCaptureError() { func testCaptureError() {
// Test error creation for permission denied // 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 // CaptureError conforms to LocalizedError, so it has errorDescription
XCTAssertNotNil(error.errorDescription) XCTAssertNotNil(screenError.errorDescription)
XCTAssertTrue(error.errorDescription?.contains("permission") ?? false) XCTAssertNotNil(accessError.errorDescription)
XCTAssertTrue(screenError.errorDescription?.contains("Screen recording permission") ?? false)
XCTAssertTrue(accessError.errorDescription?.contains("Accessibility permission") ?? false)
} }
// MARK: - Performance Tests // MARK: - Performance Tests