Skip to content

Commit

Permalink
Update RoomScreen and UserSessionScreen UI tests (#1400)
Browse files Browse the repository at this point in the history
* room tests

* User session screen tests

* regenerated keyboard ones

* fixing some minor issues

* code improvement

* fixed the remaining tests

* fixed last two
  • Loading branch information
Velin92 authored Jul 26, 2023
1 parent f2ffded commit ba6ad32
Show file tree
Hide file tree
Showing 62 changed files with 154 additions and 150 deletions.
71 changes: 38 additions & 33 deletions ElementX/Sources/Screens/RoomScreen/View/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions UITests/Sources/RoomScreenUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Loading

0 comments on commit ba6ad32

Please sign in to comment.