mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Use a Date for the timestamp in all timeline items. (#3590)
* Use a Date for the timestamp in all timeline items. * UI test snapshots. * Update snapshots --------- Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
@@ -116,7 +116,7 @@ class LoggingTests: XCTestCase {
|
||||
// Given timeline items that contain text
|
||||
let textAttributedString = "TextAttributed"
|
||||
let textMessage = TextRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
@@ -125,7 +125,7 @@ class LoggingTests: XCTestCase {
|
||||
content: .init(body: "TextString", formattedBody: AttributedString(textAttributedString)))
|
||||
let noticeAttributedString = "NoticeAttributed"
|
||||
let noticeMessage = NoticeRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
@@ -134,7 +134,7 @@ class LoggingTests: XCTestCase {
|
||||
content: .init(body: "NoticeString", formattedBody: AttributedString(noticeAttributedString)))
|
||||
let emoteAttributedString = "EmoteAttributed"
|
||||
let emoteMessage = EmoteRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
@@ -142,7 +142,7 @@ class LoggingTests: XCTestCase {
|
||||
sender: .init(id: "sender"),
|
||||
content: .init(body: "EmoteString", formattedBody: AttributedString(emoteAttributedString)))
|
||||
let imageMessage = ImageRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
@@ -153,7 +153,7 @@ class LoggingTests: XCTestCase {
|
||||
imageInfo: .mockImage,
|
||||
thumbnailInfo: nil))
|
||||
let videoMessage = VideoRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
@@ -164,7 +164,7 @@ class LoggingTests: XCTestCase {
|
||||
videoInfo: .mockVideo,
|
||||
thumbnailInfo: nil))
|
||||
let fileMessage = FileRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
|
||||
@@ -10,7 +10,7 @@ import XCTest
|
||||
|
||||
final class TextBasedRoomTimelineTests: XCTestCase {
|
||||
func testTextRoomTimelineItemWhitespaceEnd() {
|
||||
let timestamp = "Now"
|
||||
let timestamp = Calendar.current.startOfDay(for: .now).addingTimeInterval(60 * 60) // 1:00 am
|
||||
let timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: timestamp,
|
||||
isOutgoing: true,
|
||||
@@ -19,11 +19,11 @@ final class TextBasedRoomTimelineTests: XCTestCase {
|
||||
isThreaded: false,
|
||||
sender: .init(id: UUID().uuidString),
|
||||
content: .init(body: "Test"))
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.count + 1)
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + 1)
|
||||
}
|
||||
|
||||
func testTextRoomTimelineItemWhitespaceEndLonger() {
|
||||
let timestamp = "10:00 AM"
|
||||
let timestamp = Calendar.current.startOfDay(for: .now).addingTimeInterval(-60) // 11:59 pm
|
||||
let timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: timestamp,
|
||||
isOutgoing: true,
|
||||
@@ -32,11 +32,11 @@ final class TextBasedRoomTimelineTests: XCTestCase {
|
||||
isThreaded: false,
|
||||
sender: .init(id: UUID().uuidString),
|
||||
content: .init(body: "Test"))
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.count + 1)
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + 1)
|
||||
}
|
||||
|
||||
func testTextRoomTimelineItemWhitespaceEndWithEdit() {
|
||||
let timestamp = "Now"
|
||||
let timestamp = Date.mock
|
||||
var timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: timestamp,
|
||||
isOutgoing: true,
|
||||
@@ -47,11 +47,11 @@ final class TextBasedRoomTimelineTests: XCTestCase {
|
||||
content: .init(body: "Test"))
|
||||
timelineItem.properties.isEdited = true
|
||||
let editedCount = L10n.commonEditedSuffix.count
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.count + editedCount + 2)
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + editedCount + 2)
|
||||
}
|
||||
|
||||
func testTextRoomTimelineItemWhitespaceEndWithEditAndAlert() {
|
||||
let timestamp = "Now"
|
||||
let timestamp = Date.mock
|
||||
var timelineItem = TextRoomTimelineItem(id: .randomEvent,
|
||||
timestamp: timestamp,
|
||||
isOutgoing: true,
|
||||
@@ -63,6 +63,6 @@ final class TextBasedRoomTimelineTests: XCTestCase {
|
||||
timelineItem.properties.isEdited = true
|
||||
timelineItem.properties.deliveryStatus = .sendingFailed(.unknown)
|
||||
let editedCount = L10n.commonEditedSuffix.count
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.count + editedCount + 5)
|
||||
XCTAssertEqual(timelineItem.additionalWhitespaces(), timestamp.formattedTime().count + editedCount + 5)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ private extension TextRoomTimelineItem {
|
||||
init(text: String, sender: String, addReactions: Bool = false, addReadReceipts: [ReadReceipt] = []) {
|
||||
let reactions = addReactions ? [AggregatedReaction(accountOwnerID: "bob", key: "🦄", senders: [ReactionSender(id: sender, timestamp: Date())])] : []
|
||||
self.init(id: .randomEvent,
|
||||
timestamp: "10:47 am",
|
||||
timestamp: .mock,
|
||||
isOutgoing: sender == "bob",
|
||||
isEditable: sender == "bob",
|
||||
canBeRepliedTo: true,
|
||||
@@ -448,7 +448,7 @@ private extension SeparatorRoomTimelineItem {
|
||||
private extension TextRoomTimelineItem {
|
||||
init(eventID: String) {
|
||||
self.init(id: .event(uniqueID: .init(id: UUID().uuidString), eventOrTransactionID: .eventId(eventId: eventID)),
|
||||
timestamp: "",
|
||||
timestamp: .mock,
|
||||
isOutgoing: false,
|
||||
isEditable: false,
|
||||
canBeRepliedTo: true,
|
||||
|
||||
Reference in New Issue
Block a user