Update RoomScreen and UserSessionScreen UI tests (#1400)

* room tests

* User session screen tests

* regenerated keyboard ones

* fixing some minor issues

* code improvement

* fixed the remaining tests

* fixed last two
This commit is contained in:
Mauro 2023-07-26 12:23:15 +02:00 committed by GitHub
parent f2ffded87e
commit ba6ad3236f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 154 additions and 150 deletions

View File

@ -33,43 +33,30 @@ struct TimelineView: View {
var body: some View {
ScrollViewReader { scrollView in
ScrollView {
bottomPin
LazyVStack(spacing: 0) {
ForEach(viewState.itemViewStates.reversed()) { viewState in
RoomTimelineItemView(viewState: viewState)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(timelineStyle.rowInsets)
.scaleEffect(x: 1, y: -1)
timelineScrollView
.introspect(.scrollView, on: .iOS(.v16)) { uiScrollView in
guard uiScrollView != scrollViewAdapter.scrollView else {
return
}
}
topPin
}
.introspect(.scrollView, on: .iOS(.v16)) { uiScrollView in
guard uiScrollView != scrollViewAdapter.scrollView else {
return
scrollViewAdapter.scrollView = uiScrollView
scrollViewAdapter.shouldScrollToTopClosure = { _ in
withElementAnimation {
scrollView.scrollTo(topID)
}
return false
}
// Allows the scroll to top to work properly
uiScrollView.contentOffset.y -= 1
}
scrollViewAdapter.scrollView = uiScrollView
scrollViewAdapter.shouldScrollToTopClosure = { _ in
.scaleEffect(x: 1, y: -1)
.onReceive(scrollToBottomPublisher) { _ in
withElementAnimation {
scrollView.scrollTo(topID)
scrollView.scrollTo(bottomID)
}
return false
}
// Allows the scroll to top to work properly
uiScrollView.contentOffset.y -= 1
}
.scaleEffect(x: 1, y: -1)
.onReceive(scrollToBottomPublisher) { _ in
withElementAnimation {
scrollView.scrollTo(bottomID)
}
}
.scrollDismissesKeyboard(.interactively)
.scrollDismissesKeyboard(.immediately)
}
.overlay(scrollToBottomButton, alignment: .bottomTrailing)
.animation(.elementDefault, value: viewState.itemViewStates)
@ -78,16 +65,19 @@ struct TimelineView: View {
return
}
let offset = scrollView.contentOffset.y + scrollView.contentInset.top
let scrollToBottomButtonVisibleValue = offset > 0
// We give it a bit of tollerance which solves the issue when of it being displayed when the keyboard appears
let scrollToBottomButtonVisibleValue = offset > 5
if scrollToBottomButtonVisibleValue != scrollToBottomButtonVisible {
scrollToBottomButtonVisible = scrollToBottomButtonVisibleValue
}
paginateBackwardsPublisher.send()
// Allows the scroll to top to work properly
if offset == 0 {
scrollView.contentOffset.y -= 1
}
paginateBackwardsPublisher.send()
}
.onReceive(paginateBackwardsPublisher.collect(.byTime(DispatchQueue.main, 0.1))) { _ in
paginateBackwardsIfNeeded()
@ -97,6 +87,21 @@ struct TimelineView: View {
}
}
private var timelineScrollView: some View {
ScrollView {
bottomPin
LazyVStack(spacing: 0) {
ForEach(viewState.itemViewStates.reversed()) { viewState in
RoomTimelineItemView(viewState: viewState)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(timelineStyle.rowInsets)
.scaleEffect(x: 1, y: -1)
}
}
topPin
}
}
/// Used to mark the top of the scroll view and easily scroll to it
private var topPin: some View {
Divider()

View File

@ -75,8 +75,7 @@ class RoomScreenUITests: XCTestCase {
try await app.assertScreenshot(.roomSmallTimelineLargePagination)
}
// This test is DISABLED because it's flakey on the CI
func disabled_testTimelineLayoutInMiddle() async throws {
func testTimelineLayoutInMiddle() async throws {
let client = try UITestsSignalling.Client(mode: .tests)
let app = Application.launch(.roomLayoutMiddle)

Binary file not shown.

Binary file not shown.