Skip to content

Commit 0def868

Browse files
committed
Add test coverage to double error indicator fix
1 parent 821c0bd commit 0def868

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelTestHelpers.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ class ChatChannelTestHelpers {
7070
return imageAttachments
7171
}()
7272

73+
static func imageAttachment(state: LocalAttachmentState) -> AnyChatMessageAttachment {
74+
let attachmentFile = AttachmentFile(type: .png, size: 0, mimeType: "image/png")
75+
let uploadingState = AttachmentUploadingState(
76+
localFileURL: testURL,
77+
state: state,
78+
file: attachmentFile
79+
)
80+
return ChatMessageImageAttachment(
81+
id: .unique,
82+
type: .image,
83+
payload: ImageAttachmentPayload(
84+
title: "test",
85+
imageRemoteURL: testURL,
86+
extraData: [:]
87+
),
88+
downloadingState: nil,
89+
uploadingState: uploadingState
90+
)
91+
.asAnyAttachment
92+
}
93+
7394
static var giphyAttachments: [AnyChatMessageAttachment] = {
7495
let attachmentFile = AttachmentFile(type: .gif, size: 0, mimeType: "image/gif")
7596
let uploadingState = AttachmentUploadingState(

StreamChatSwiftUITests/Tests/ChatChannel/MessageContainerView_Tests.swift

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,43 @@ class MessageContainerView_Tests: StreamChatTestCase {
261261
// Then
262262
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
263263
}
264-
264+
265+
func test_imageAttachments_failed_snapshot() {
266+
// Given
267+
let message = ChatMessage.mock(
268+
id: .unique,
269+
cid: .unique,
270+
text: "Test message",
271+
author: .mock(id: .unique),
272+
attachments: [ChatChannelTestHelpers.imageAttachment(state: .uploadingFailed)],
273+
localState: .sendingFailed
274+
)
275+
276+
// When
277+
let view = testMessageViewContainer(message: message)
278+
279+
// Then
280+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
281+
}
282+
283+
func test_imageAttachments_failedWhenMessageTextIsEmpty_snapshot() {
284+
// Given
285+
let message = ChatMessage.mock(
286+
id: .unique,
287+
cid: .unique,
288+
text: "",
289+
author: .mock(id: .unique),
290+
attachments: [ChatChannelTestHelpers.imageAttachment(state: .uploadingFailed)],
291+
localState: .sendingFailed
292+
)
293+
294+
// When
295+
let view = testMessageViewContainer(message: message)
296+
297+
// Then
298+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
299+
}
300+
265301
func test_translatedText_participant_snapshot() {
266302
// Given
267303
let message = ChatMessage.mock(
Loading
Loading

0 commit comments

Comments
 (0)