Files
openclaw/apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatReaderScrollStateTests.swift
christopheraaronhogg ab2761f3a5 improve: make native chat scrolling reader-managed (#98258)
* improve native chat scroll behavior

* add native chat scroll proof harnesses

* fix(android): jump native chat to live content

* fix(mobile): harden reader-managed chat scrolling

* fix(android): preserve prompt anchor through completion

* fix(android): gate follow changes on user scroll

* fix(ios): handle optimistic chat rollback

* fix(mobile): harden reader boundary transitions

* fix(mobile): expose newer content after restore

* fix(android): preserve restored reader identity

* test(ios): prove reader pause and resume

* fix(android): scope restored reader state to session

* chore(i18n): sync native chat inventory

* fix(mobile): harden reader scroll recovery

* chore(i18n): sync native inventory after rebase

---------

Co-authored-by: Chris Hogg <chrishogg@Chriss-Mac-mini-3.local>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-03 06:57:16 -07:00

63 lines
1.8 KiB
Swift

import Foundation
import Testing
@testable import OpenClawChatUI
struct ChatReaderScrollStateTests {
@Test func `optimistic turn removal keeps the older user as the baseline`() {
let olderUserID = UUID()
let optimisticUserID = UUID()
let transition = chatReaderUserTransition(
previousID: optimisticUserID,
visibleIDs: [olderUserID])
#expect(transition == .removed(latestRemainingID: olderUserID))
}
@Test func `only user removal clears the user baseline`() {
let optimisticUserID = UUID()
let transition = chatReaderUserTransition(
previousID: optimisticUserID,
visibleIDs: [])
#expect(transition == .removed(latestRemainingID: nil))
}
@Test func `new user after the existing baseline starts a turn`() {
let previousUserID = UUID()
let newUserID = UUID()
let transition = chatReaderUserTransition(
previousID: previousUserID,
visibleIDs: [previousUserID, newUserID])
#expect(transition == .added(newUserID))
}
@Test func `removed transient content does not offer a latest jump`() {
let userID = UUID()
let hasNewerContent = chatReaderHasNewerContent(
after: userID,
visibleIDs: [userID],
hasTransientContent: false)
#expect(!hasNewerContent)
}
@Test func `assistant or transient content after the user offers a latest jump`() {
let userID = UUID()
let assistantID = UUID()
#expect(chatReaderHasNewerContent(
after: userID,
visibleIDs: [userID, assistantID],
hasTransientContent: false))
#expect(chatReaderHasNewerContent(
after: userID,
visibleIDs: [userID],
hasTransientContent: true))
}
}