hex/ios/HEXMobileTests/TranscriptCleanupTests.swift
Dax 74c26f5bf5
ios: optional Apple Intelligence transcript cleanup (experiment) (#1538)
* ios: add off-by-default Apple Intelligence transcript cleanup experiment

* ios: let nonisolated settings read the app group id

* ios: reject added negations and stop cancelled cleanup work
2026-11-08 08:07:11 -05:00

95 lines
3 KiB
Swift

import XCTest
@testable import HEX
final class TranscriptCleanupGuardTests: XCTestCase {
func testAcceptsMisheardWordsAndSpokenSelfCorrections() {
XCTAssertTrue(
TranscriptCleanupGuard.isAcceptable(
original: "we should use cloud code on tuesday, no wait, wednesday",
cleaned: "We should use Claude Code on Wednesday."
)
)
}
func testAcceptsPunctuationAndCaseChanges() {
XCTAssertTrue(
TranscriptCleanupGuard.isAcceptable(
original: "meet at ten on thursday and bring the notes",
cleaned: "Meet at ten on Thursday, and bring the notes."
)
)
}
func testRejectsDigitChanges() {
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "call me at 555 0100",
cleaned: "call me at 555 0101"
)
)
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "see you at ten",
cleaned: "see you at 10"
)
)
}
func testRejectsLostNegation() {
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "do not delete the file",
cleaned: "delete the file"
)
)
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "I don't think that is right",
cleaned: "I think that is right"
)
)
}
func testRejectsAddedNegation() {
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "I will go tomorrow",
cleaned: "I will not go tomorrow"
)
)
}
func testRejectsRunawayLength() {
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "ship it",
cleaned: String(repeating: "ship it ", count: 30)
)
)
}
func testRejectsEmptyOutputAndEmptyInput() {
XCTAssertFalse(TranscriptCleanupGuard.isAcceptable(original: "", cleaned: ""))
XCTAssertFalse(TranscriptCleanupGuard.isAcceptable(original: "ship it", cleaned: " "))
}
func testRejectsAnAnswerWithLittleOverlap() {
XCTAssertFalse(
TranscriptCleanupGuard.isAcceptable(
original: "what time is the meeting",
cleaned: "The weather tomorrow will be sunny and warm."
)
)
}
func testCleanupSettingIsOffByDefaultAndPersists() {
let suite = "AppleIntelligenceCleanupSettingsTests-\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suite)!
defer { defaults.removePersistentDomain(forName: suite) }
XCTAssertFalse(AppleIntelligenceCleanupSettings(defaults: defaults).isEnabled)
AppleIntelligenceCleanupSettings(defaults: defaults).isEnabled = true
XCTAssertTrue(AppleIntelligenceCleanupSettings(defaults: defaults).isEnabled)
}
}