Skip to content

Commit

Permalink
Merge branch 'fix/MAILIOS-4230' into 'release/4.13.0'
Browse files Browse the repository at this point in the history
MAILIOS-4230, Empty sender image on drafts with no recipient address

See merge request ProtonMail/protonmail-ios!4012
  • Loading branch information
MargeBot committed Mar 4, 2024
2 parents 55fd5a3 + 8779f18 commit a846875
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ extension MailboxViewController {
let labelId = viewModel.labelID
let isSelected = self.viewModel.selectionContains(id: message.messageID.rawValue)
let contactGroups = viewModel.contactGroups()
let senderRowComponents = mailboxMessageCellHelper.senderRowComponents(
var senderRowComponents = mailboxMessageCellHelper.senderRowComponents(
for: message,
basedOn: replacingEmailsMap,
groupContacts: contactGroups,
shouldReplaceSenderWithRecipients: true
)
if senderRowComponents.isEmpty {
senderRowComponents = [.string("")]
}
let isSending = viewModel.messageService.isMessageBeingSent(id: message.messageID)

var initial = ""
var initial = "?"
if let firstSenderRowComponent = senderRowComponents.first {
initial = [firstSenderRowComponent].initials()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ extension SearchViewModel {

func getMessageCellViewModel(message: MessageEntity) -> NewMailboxMessageViewModel {
let contactGroups = user.contactGroupService.getAllContactGroupVOs()
let senderRowComponents = dependencies.mailboxMessageCellHelper.senderRowComponents(
var senderRowComponents = dependencies.mailboxMessageCellHelper.senderRowComponents(
for: message,
basedOn: sharedReplacingEmailsMap,
groupContacts: contactGroups,
shouldReplaceSenderWithRecipients: true
)
if senderRowComponents.isEmpty {
senderRowComponents = [.string("")]
}
let weekStart = user.userInfo.weekStartValue
let customFolderLabels = user.labelService.getAllLabels(of: .folder)
let isSelected = self.selectedMessages.contains(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import XCTest
import fusion
@testable import ProtonMail

fileprivate struct id {
static let messageTitleLabelIdentifier = "mailboxMessageCell.titleLabel"
Expand All @@ -20,7 +21,8 @@ fileprivate struct id {
* contains actions and verifications for Drafts composer functionality.
*/
class DraftsRobot: MailboxRobotInterface {

static let noRecipientText = "(\(L11n.MailBox.noRecipient))"

var verify = Verify()

override func searchBar() -> SearchRobot {
Expand Down Expand Up @@ -61,6 +63,14 @@ class DraftsRobot: MailboxRobotInterface {
.waitUntilExists()
.checkExists()
}

func messageWithSubjectAndRecipientAndInitialsExists(subject: String, to: String, initials: String) {
let messageCell = cell("NewMailboxMessageCell.\(subject)")
.waitUntilExists()
.checkExists()
let isCorrect = messageCell.label()?.hasPrefix("\(initials), \(subject), \(to),") ?? false
XCTAssertTrue(isCorrect)
}
}
}

16 changes: 16 additions & 0 deletions ProtonMail/ProtonMailUITests/Tests/Drafts/DraftsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ class DraftsTests: FixtureAuthenticatedTestCase {
}
}

func testSaveEmptyRecipientDraft() {
runTestWithScenario(.qaMail001) {
InboxRobot()
.compose()
.draftSubjectBody(subject, body)
.tapCancel()
.menuDrawer()
.drafts()
.verify.messageWithSubjectAndRecipientAndInitialsExists(
subject: subject,
to: DraftsRobot.noRecipientText,
initials: "?"
)
}
}

func testSaveDraftWithAttachment() {
runTestWithScenario(.qaMail001) {
InboxRobot()
Expand Down

0 comments on commit a846875

Please sign in to comment.