test: remove low-value native validation tests (#38553)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-05 05:35:34 -08:00
committed by GitHub
co-authored by OrcaWin
parent 00b56535c6
commit 7deeabd41f
5 changed files with 0 additions and 252 deletions
@@ -1,89 +0,0 @@
import OrcaComputerUseMacOSCore
import XCTest
final class ActionArgumentValidationTests: XCTestCase {
func testPositiveIntegerAcceptsPositiveValuesAndDefaults() {
XCTAssertEqual(
try ActionArgumentValidation.positiveInteger(nil, defaultValue: 1, name: "clickCount").get(),
1
)
XCTAssertEqual(
try ActionArgumentValidation.positiveInteger(2, defaultValue: 1, name: "clickCount").get(),
2
)
}
func testPositiveIntegerRejectsZeroNegativeAndNonFiniteValues() {
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveInteger(0, defaultValue: 1, name: "clickCount")),
"clickCount must be a positive integer"
)
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveInteger(-1, defaultValue: 1, name: "clickCount")),
"clickCount must be a positive integer"
)
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveInteger(.infinity, defaultValue: 1, name: "clickCount")),
"clickCount must be a positive integer"
)
}
func testPositiveNumberAcceptsPositiveValuesAndDefaults() {
XCTAssertEqual(
try ActionArgumentValidation.positiveNumber(nil, defaultValue: 1, name: "pages").get(),
1
)
XCTAssertEqual(
try ActionArgumentValidation.positiveNumber(0.5, defaultValue: 1, name: "pages").get(),
0.5
)
}
func testPositiveNumberRejectsZeroNegativeAndNonFiniteValues() {
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveNumber(0, defaultValue: 1, name: "pages")),
"pages must be a positive number"
)
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveNumber(-0.5, defaultValue: 1, name: "pages")),
"pages must be a positive number"
)
XCTAssertEqual(
failureMessage(ActionArgumentValidation.positiveNumber(.nan, defaultValue: 1, name: "pages")),
"pages must be a positive number"
)
}
func testMouseButtonDefaultsToLeftAndAcceptsEveryButton() {
XCTAssertEqual(try ActionArgumentValidation.mouseButton(nil).get(), .left)
XCTAssertEqual(try ActionArgumentValidation.mouseButton("left").get(), .left)
XCTAssertEqual(try ActionArgumentValidation.mouseButton("right").get(), .right)
XCTAssertEqual(try ActionArgumentValidation.mouseButton("middle").get(), .middle)
}
func testMouseButtonRejectsUnknownButtons() {
XCTAssertEqual(
failureMessage(ActionArgumentValidation.mouseButton("primary")),
"unsupported mouse button 'primary'"
)
XCTAssertEqual(
failureMessage(ActionArgumentValidation.mouseButton("")),
"unsupported mouse button ''"
)
}
func testScrollDirectionRejectsUnknownDirections() {
XCTAssertEqual(try ActionArgumentValidation.scrollDirection("down").get(), "down")
XCTAssertEqual(
failureMessage(ActionArgumentValidation.scrollDirection("diagonal")),
"unsupported scroll direction: diagonal"
)
}
private func failureMessage<T>(_ result: Result<T, ActionArgumentValidationError>) -> String? {
if case let .failure(error) = result {
return error.message
}
return nil
}
}
@@ -23,18 +23,6 @@ final class AgentConnectionRequestLoopTests: XCTestCase {
XCTAssertEqual(releasedBeforeNextRequest, true)
}
func testServesEveryLineUntilInputEnds() {
var lines = ["a", "b", "c"]
var handled: [String] = []
AgentConnectionRequestLoop.run(readLine: { lines.isEmpty ? nil : lines.removeFirst() }) { line in
handled.append(line)
return true
}
XCTAssertEqual(handled, ["a", "b", "c"])
}
func testStopsReadingWhenTheHandlerClosesTheConnection() {
var lines = ["a", "b", "c"]
var handled: [String] = []
@@ -4,17 +4,6 @@ import XCTest
@testable import OrcaComputerUseMacOSCore
final class AttributeValueCoercionTests: XCTestCase {
func testStringValueRemainsAStringWithoutTrimming() {
let coercion = AttributeValueCoercion(existingValue: "old" as CFString, requested: " new ")
XCTAssertEqual(coercion.writeValue, .string(" new "))
}
func testIntegerValuePreservesIntegerKind() {
let coercion = AttributeValueCoercion(existingValue: NSNumber(value: Int32(2)), requested: "3.0")
XCTAssertEqual(coercion.writeValue, .integer(3))
}
func testIntegerDecimalConversionIsExactAboveDoublePrecision() {
let coercion = AttributeValueCoercion(
@@ -78,69 +67,4 @@ final class AttributeValueCoercionTests: XCTestCase {
XCTAssertEqual(coercion.writeValue, .double(3.0))
}
func testBooleanValueAcceptsWordsAndNumericAliases() {
XCTAssertEqual(
AttributeValueCoercion(existingValue: kCFBooleanFalse, requested: "TRUE").writeValue,
.boolean(true)
)
XCTAssertEqual(
AttributeValueCoercion(existingValue: kCFBooleanTrue, requested: "0").writeValue,
.boolean(false)
)
}
func testUnreadableAndUnhandledValuesUseStringFallback() {
XCTAssertEqual(
AttributeValueCoercion(existingValue: nil, requested: "7").writeValue,
.string("7")
)
XCTAssertEqual(
AttributeValueCoercion(existingValue: [1, 2] as CFArray, requested: "7").writeValue,
.string("7")
)
}
func testInvalidHandledValuesUseStringFallback() {
XCTAssertEqual(
AttributeValueCoercion(existingValue: NSNumber(value: 2), requested: "2.5").writeValue,
.string("2.5")
)
XCTAssertEqual(
AttributeValueCoercion(existingValue: NSNumber(value: 2.5), requested: "many").writeValue,
.string("many")
)
XCTAssertEqual(
AttributeValueCoercion(existingValue: kCFBooleanFalse, requested: "maybe").writeValue,
.string("maybe")
)
}
func testReadbackMatchesEachSupportedType() {
let cases: [(AttributeValueCoercion, CFTypeRef, String)] = [
(AttributeValueCoercion(existingValue: "old" as CFString, requested: "new"), "new" as CFString, "new"),
(AttributeValueCoercion(existingValue: NSNumber(value: 1), requested: "2"), NSNumber(value: 2), "2"),
(AttributeValueCoercion(existingValue: NSNumber(value: 1.5), requested: "2.5"), NSNumber(value: 2.5), "2.5"),
(AttributeValueCoercion(existingValue: kCFBooleanFalse, requested: "true"), kCFBooleanTrue, "true"),
]
for (coercion, readback, preview) in cases {
XCTAssertEqual(coercion.compare(readback: readback), .match(actualPreview: preview))
}
}
func testSupportedMismatchedReadbackIncludesActualPreview() {
let coercion = AttributeValueCoercion(existingValue: NSNumber(value: 1), requested: "2")
XCTAssertEqual(
coercion.compare(readback: NSNumber(value: 3)),
.mismatch(actualPreview: "3")
)
}
func testUnreadableAndUnhandledReadbackAreUnsupported() {
let coercion = AttributeValueCoercion(existingValue: "old" as CFString, requested: "new")
XCTAssertEqual(coercion.compare(readback: nil), .unsupported)
XCTAssertEqual(coercion.compare(readback: ["new"] as CFArray), .unsupported)
}
}
@@ -1,59 +0,0 @@
import Testing
@testable import OrcaComputerUseMacOSCore
@Suite("PermissionTrustSettling")
struct PermissionTrustSettlingTests {
@Test("already-trusted probe returns immediately")
func immediateSuccess() {
var sleeps: [Int] = []
let outcome = PermissionTrustSettling.settle(
sleepMs: { sleeps.append($0) },
probe: { true }
)
#expect(outcome == .init(settled: true, attempts: 1, waitedMs: 0))
#expect(sleeps.isEmpty)
}
@Test("transient denial settles after retries")
func lateGrant() {
var calls = 0
var sleeps: [Int] = []
let outcome = PermissionTrustSettling.settle(
sleepMs: { sleeps.append($0) },
probe: {
calls += 1
return calls >= 4
}
)
#expect(outcome == .init(settled: true, attempts: 4, waitedMs: 300))
#expect(sleeps == [100, 100, 100])
}
@Test("persistent denial stops at the timeout")
func neverGranted() {
let outcome = PermissionTrustSettling.settle(
timeoutMs: 1_000,
intervalMs: 300,
sleepMs: { _ in },
probe: { false }
)
#expect(outcome == .init(settled: false, attempts: 5, waitedMs: 1_000))
}
@Test("final interval is clamped to the timeout")
func clampsFinalInterval() {
var sleeps: [Int] = []
let outcome = PermissionTrustSettling.settle(
timeoutMs: 250,
intervalMs: 100,
sleepMs: { sleeps.append($0) },
probe: { false }
)
#expect(sleeps == [100, 100, 50])
#expect(outcome == .init(settled: false, attempts: 4, waitedMs: 250))
}
}
@@ -12,8 +12,6 @@ final class StableElementIndexesTests: XCTestCase {
)
}
func testAnElementInsertedEarlyLeavesEveryOtherIndexAlone() {
let previous: [Previous] = [("window", 0, "AXWindow"), ("search", 1, "AXTextField"), ("row", 2, "AXRow")]
@@ -27,12 +25,6 @@ final class StableElementIndexesTests: XCTestCase {
XCTAssertEqual(result.nextFreshIndex, 4)
}
func testARemovedIndexIsNeverHandedToADifferentNewElement() {
let previous: [Previous] = [("window", 0, "AXWindow"), ("search", 1, "AXTextField")]
@@ -41,12 +33,4 @@ final class StableElementIndexesTests: XCTestCase {
XCTAssertEqual(result.indexes, [0, 7])
}
func testRenumbersOnlyTheLeadingElementIndex() {
let indexes = [3: 41, 12: 3]
XCTAssertEqual(StableElementIndexes.renumber(line: "\t\t3 button Upvote 12", indexes: indexes), "\t\t41 button Upvote 12")
XCTAssertEqual(StableElementIndexes.renumber(line: "12", indexes: indexes), "3")
XCTAssertEqual(StableElementIndexes.renumber(line: "\t... 12 inactive browser tabs omitted", indexes: indexes), "\t... 12 inactive browser tabs omitted")
XCTAssertEqual(StableElementIndexes.renumber(line: "\t12px text", indexes: indexes), "\t12px text")
}
}