Expand onboarding and adaptive keyboard intelligence
Add resilient usage analytics, OOBE gateway flows, clipboard semantic ranking, purchase recovery, style learning, and managed current-information search.
This commit is contained in:
@@ -47,6 +47,55 @@ final class SpeechHistoryRevisionTests: XCTestCase {
|
||||
XCTAssertEqual(updated?.revision, 1)
|
||||
}
|
||||
|
||||
func testMergePreservesCorpusMetadataWhenNewerRevisionCameFromLegacyApp() {
|
||||
let id = UUID()
|
||||
let createdAt = Date(timeIntervalSince1970: 100)
|
||||
let prompt = "历史润色 Prompt"
|
||||
let promptFingerprint = SyncedSpeechHistory.polishStylePromptFingerprint(
|
||||
for: prompt
|
||||
)
|
||||
let corpusEntry = SpeechHistoryEntry(
|
||||
id: id,
|
||||
text: "润色结果",
|
||||
prePolishText: "原始口述",
|
||||
wasTranslation: true,
|
||||
polishStyleID: "builtin.formal",
|
||||
polishStylePromptFingerprint: promptFingerprint,
|
||||
createdAt: createdAt,
|
||||
modifiedAt: createdAt,
|
||||
revision: 0
|
||||
)
|
||||
let legacyEdit = SpeechHistoryEntry(
|
||||
id: id,
|
||||
text: "旧版本设备修改后的结果",
|
||||
createdAt: createdAt,
|
||||
modifiedAt: Date(timeIntervalSince1970: 200),
|
||||
revision: 1
|
||||
)
|
||||
|
||||
let merged = SyncedSpeechHistory.merge(
|
||||
local: SyncedSpeechHistory(
|
||||
entries: [corpusEntry],
|
||||
polishStylePromptSnapshots: [promptFingerprint: prompt]
|
||||
),
|
||||
remote: SyncedSpeechHistory(entries: [legacyEdit])
|
||||
)
|
||||
|
||||
XCTAssertEqual(merged.entries.first?.text, "旧版本设备修改后的结果")
|
||||
XCTAssertEqual(merged.entries.first?.prePolishText, "原始口述")
|
||||
XCTAssertTrue(merged.entries.first?.wasTranslation == true)
|
||||
XCTAssertEqual(merged.entries.first?.polishStyleID, "builtin.formal")
|
||||
XCTAssertEqual(
|
||||
merged.entries.first?.polishStylePromptFingerprint,
|
||||
promptFingerprint
|
||||
)
|
||||
XCTAssertEqual(
|
||||
merged.polishStylePromptSnapshots[promptFingerprint],
|
||||
prompt
|
||||
)
|
||||
XCTAssertEqual(merged.entries.first?.revision, 1)
|
||||
}
|
||||
|
||||
func testReplayingMutationDoesNotBumpRevisionOrDuplicate() throws {
|
||||
let suite = "SpeechHistoryMutationReplayTests.\(UUID().uuidString)"
|
||||
let defaults = try XCTUnwrap(UserDefaults(suiteName: suite))
|
||||
|
||||
Reference in New Issue
Block a user