498f407585
Introduce optional Apple account-backed credits with scoped gateway access while preserving local and BYOK paths. Refresh assistant behavior, tests, privacy disclosures, docs, and the website for the 2.0 experience.
55 lines
1.7 KiB
Swift
55 lines
1.7 KiB
Swift
// MacTextInsertionServiceTests.swift
|
|
// OSGKeyboard · Mac tests
|
|
//
|
|
// Regression coverage for clipboard preservation and captured-app context.
|
|
|
|
import AppKit
|
|
@testable import OSGKeyboard
|
|
import XCTest
|
|
|
|
final class MacTextInsertionServiceTests: XCTestCase {
|
|
|
|
func testRestoreRequiresTranscriptToStillOwnPasteboard() {
|
|
XCTAssertTrue(
|
|
MacTextInsertionService.shouldRestorePasteboard(
|
|
transcriptChangeCount: 12,
|
|
currentChangeCount: 12
|
|
)
|
|
)
|
|
XCTAssertFalse(
|
|
MacTextInsertionService.shouldRestorePasteboard(
|
|
transcriptChangeCount: 12,
|
|
currentChangeCount: 13
|
|
),
|
|
"A newer clipboard write must not be overwritten by restoration."
|
|
)
|
|
}
|
|
|
|
func testRestoringOriginallyEmptyPasteboardClearsTranscript() {
|
|
let pasteboard = NSPasteboard(
|
|
name: NSPasteboard.Name("MacTextInsertionServiceTests.\(UUID().uuidString)")
|
|
)
|
|
pasteboard.clearContents()
|
|
pasteboard.setString("transcript", forType: .string)
|
|
|
|
MacTextInsertionService.restoreItems([], to: pasteboard)
|
|
|
|
XCTAssertNil(pasteboard.string(forType: .string))
|
|
}
|
|
|
|
func testCapturedBundleIdentifierDrivesPolishContext() {
|
|
XCTAssertEqual(
|
|
MacAppContextService.detectContext(bundleIdentifier: "com.apple.dt.Xcode"),
|
|
.code
|
|
)
|
|
XCTAssertEqual(
|
|
MacAppContextService.detectContext(bundleIdentifier: "com.tencent.xinWeChat"),
|
|
.chat
|
|
)
|
|
XCTAssertEqual(
|
|
MacAppContextService.detectContext(bundleIdentifier: "com.osgkeyboard.mac"),
|
|
.unknown
|
|
)
|
|
}
|
|
}
|