mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 18:36:08 +00:00
* fix(ios): stop chat snapping back to bottom after system scroll-to-top * chore(i18n): sync native inventory after chat scroll fix
75 lines
2.3 KiB
Swift
75 lines
2.3 KiB
Swift
import Foundation
|
|
import SwiftUI
|
|
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))
|
|
}
|
|
|
|
@Test func `drags and system animated scrolls release the follow target`() {
|
|
#expect(chatReaderScrollReleasesFollow(.interacting))
|
|
#expect(chatReaderScrollReleasesFollow(.animating))
|
|
}
|
|
|
|
@Test func `idle, touch-down, and deceleration phases keep the follow target`() {
|
|
#expect(!chatReaderScrollReleasesFollow(.idle))
|
|
#expect(!chatReaderScrollReleasesFollow(.tracking))
|
|
#expect(!chatReaderScrollReleasesFollow(.decelerating))
|
|
}
|
|
}
|