Files
hapi/ios/Packages/HapiKit/Tests/HapiUITests/MarkdownRenderCacheTests.swift
T
weishu c2e3d16b7e feat(native): improve anchored chat scrolling and history loading
Add viewport-driven paging with layout acknowledgements, bounded retries, cancellation gates, and epoch-safe history retention.

Preserve transcript anchors and expansion state, fix tool-group identity collisions, and serialize Android history coordination on Main.

Reduce per-scroll composition and layout work; add native regression tests, CI coverage, and profiling guidance.
2026-09-10 16:22:36 +08:00

25 lines
880 B
Swift

import HapiUI
import Testing
@Suite("Chat markdown cache")
struct MarkdownRenderCacheTests {
@Test func prewarmingMatchesTheExistingRenderer() async {
let cache = MarkdownRenderCache()
let text = "## History\n\n```swift\nlet stable = true\n```"
await cache.prepare([text])
#expect(cache.cached(text) == MarkdownBlockTree.build(from: text))
await cache.prepare([text])
#expect(cache.cached(text) != nil)
}
@Test func retentionIsBoundedAndHugeEntriesDoNotEvictNormalOnes() async {
let cache = MarkdownRenderCache(maxCost: 32)
await cache.prepare(["one"])
await cache.prepare([String(repeating: "x", count: 100)])
#expect(cache.cached("one") != nil)
await cache.prepare(["second"])
#expect(cache.cached("one") == nil)
#expect(cache.cached("second") != nil)
}
}