IOS-1521 this one needs love IOS-1521+IOS-1495
authorbuff <andreas@pep-project.org>
Tue, 14 May 2019 23:37:38 +0200
branchIOS-1521+IOS-1495
changeset 8619908d9f21f84f
parent 8618 6ee1f9a0b281
child 8620 81e20eeddbe0
IOS-1521 this one needs love
pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModelTest.swift
     1.1 --- a/pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModelTest.swift	Tue May 14 23:08:50 2019 +0200
     1.2 +++ b/pEpForiOSTests/UI/Compose/ViewModel/ComposeViewModelTest.swift	Tue May 14 23:37:38 2019 +0200
     1.3 @@ -1,1912 +1,1920 @@
     1.4 +//!!!: needs love!
     1.5 +
     1.6 +////
     1.7 +////  ComposeViewModelTest.swift
     1.8 +////  pEpForiOSTests
     1.9 +////
    1.10 +////  Created by Andreas Buff on 15.11.18.
    1.11 +////  Copyright © 2018 p≡p Security S.A. All rights reserved.
    1.12 +////
    1.13  //
    1.14 -//  ComposeViewModelTest.swift
    1.15 -//  pEpForiOSTests
    1.16 +//import XCTest
    1.17  //
    1.18 -//  Created by Andreas Buff on 15.11.18.
    1.19 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    1.20 +//@testable import pEpForiOS
    1.21 +//@testable import MessageModel
    1.22 +//import PEPObjCAdapterFramework
    1.23  //
    1.24 -
    1.25 -import XCTest
    1.26 -
    1.27 -@testable import pEpForiOS
    1.28 -@testable import MessageModel
    1.29 -import PEPObjCAdapterFramework
    1.30 -
    1.31 -class ComposeViewModelTest: CoreDataDrivenTestBase {
    1.32 -    private var testDelegate: TestDelegate?
    1.33 -    private var testResultDelegate: TestResultDelegate?
    1.34 -    var vm: ComposeViewModel?
    1.35 -    var outbox: Folder? {
    1.36 -        return account.firstFolder(ofType: .outbox)
    1.37 -    }
    1.38 -    var drafts: Folder? {
    1.39 -        return account.firstFolder(ofType: .drafts)
    1.40 -    }
    1.41 -    var sent: Folder? {
    1.42 -        return account.firstFolder(ofType: .sent)
    1.43 -    }
    1.44 -
    1.45 -    override func setUp() {
    1.46 -        super.setUp()
    1.47 -        vm = ComposeViewModel(resultDelegate: nil,
    1.48 -                              composeMode: nil,
    1.49 -                              prefilledTo: nil,
    1.50 -                              originalMessage: nil)
    1.51 -        assureOutboxExists()
    1.52 -        assureDraftsExists()
    1.53 -        assureSentExists()
    1.54 -    }
    1.55 -
    1.56 -    // MARK: - Test the Test Helper
    1.57 -
    1.58 -    func testAssertHelperTest_doNothing_noCallback() {
    1.59 -        assert(contentChangedMustBeCalled: false,
    1.60 -               focusSwitchedMustBeCalled: false,
    1.61 -               validatedStateChangedMustBeCalled: false,
    1.62 -               modelChangedMustBeCalled: false,
    1.63 -               sectionChangedMustBeCalled: false,
    1.64 -               colorBatchNeedsUpdateMustBeCalled: false,
    1.65 -               hideSuggestionsMustBeCalled: false,
    1.66 -               showSuggestionsMustBeCalled: false,
    1.67 -               showMediaAttachmentPickerMustBeCalled: false,
    1.68 -               hideMediaAttachmentPickerMustBeCalled: false,
    1.69 -               showDocumentAttachmentPickerMustBeCalled: false,
    1.70 -               documentAttachmentPickerDonePickerCalled: false,
    1.71 -               didComposeNewMailMustBeCalled: false,
    1.72 -               didModifyMessageMustBeCalled: false,
    1.73 -               didDeleteMessageMustBeCalled: false)
    1.74 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
    1.75 -    }
    1.76 -
    1.77 -    // MARK: - init
    1.78 -
    1.79 -    func testInit_resultDelegateSet() {
    1.80 -        let resultDelegate = TestResultDelegate()
    1.81 -        let vm = ComposeViewModel(resultDelegate: resultDelegate,
    1.82 -                                  composeMode: nil,
    1.83 -                                  prefilledTo: nil,
    1.84 -                                  originalMessage: nil)
    1.85 -        guard let testee = vm.resultDelegate else {
    1.86 -            XCTFail()
    1.87 -            return
    1.88 -        }
    1.89 -        XCTAssertTrue(testee === resultDelegate)
    1.90 -    }
    1.91 -
    1.92 -    func testInit_stateSetupCorrectly() {
    1.93 -        let mode = ComposeUtil.ComposeMode.replyAll
    1.94 -        let vm = ComposeViewModel(resultDelegate: nil,
    1.95 -                                  composeMode: mode,
    1.96 -                                  prefilledTo: nil,
    1.97 -                                  originalMessage: nil)
    1.98 -        guard
    1.99 -            let testee = vm.state.initData,
   1.100 -            let testeeMode = vm.state.initData?.composeMode,
   1.101 -            let stateDelegate = vm.state.delegate else {
   1.102 -            XCTFail()
   1.103 -            return
   1.104 -        }
   1.105 -        XCTAssertNotNil(testee)
   1.106 -        XCTAssertEqual(testeeMode, mode)
   1.107 -        XCTAssertTrue(vm === stateDelegate)
   1.108 -    }
   1.109 -
   1.110 -    // MARK: - Sections
   1.111 -
   1.112 -    func testSections_setupCorrectly() {
   1.113 -        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: false)
   1.114 -        assertSections(forVMIniitaliizedWith: testOriginalMessage,
   1.115 -                       expectBccWrapperSectionExists: true,
   1.116 -                       expectAccountSectionExists: false,
   1.117 -                       expectAttachmentSectionExists: false)
   1.118 -    }
   1.119 -
   1.120 -    func testSections_unwrappedbcc() {
   1.121 -        let testOriginalMessage = draftMessage(bccSet: true, attachmentsSet: false)
   1.122 -        assertSections(forVMIniitaliizedWith: testOriginalMessage,
   1.123 -                       expectBccWrapperSectionExists: false,
   1.124 -                       expectAccountSectionExists: false,
   1.125 -                       expectAttachmentSectionExists: false)
   1.126 -    }
   1.127 -
   1.128 -    func testSections_accountSelector() {
   1.129 -        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: false)
   1.130 -        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
   1.131 -        secondAccount.save()
   1.132 -        assertSections(forVMIniitaliizedWith: testOriginalMessage,
   1.133 -                       expectBccWrapperSectionExists: true,
   1.134 -                       expectAccountSectionExists: true,
   1.135 -                       expectAttachmentSectionExists: false)
   1.136 -    }
   1.137 -
   1.138 -    func testSections_attachments() {
   1.139 -        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: true)
   1.140 -        assertSections(forVMIniitaliizedWith: testOriginalMessage,
   1.141 -                       expectBccWrapperSectionExists: true,
   1.142 -                       expectAccountSectionExists: false,
   1.143 -                       expectAttachmentSectionExists: true)
   1.144 -    }
   1.145 -
   1.146 -    // MARK: - DocumentAttachmentPickerResultDelegate Handling
   1.147 -
   1.148 -    func testDocumentAttachmentPickerViewModel() {
   1.149 -        let testee = vm?.documentAttachmentPickerViewModel()
   1.150 -        XCTAssertNotNil(testee)
   1.151 -    }
   1.152 -
   1.153 -    func testDidPickDocumentAttachment() {
   1.154 -        let attachmentSectionSection = 4
   1.155 -        assert(contentChangedMustBeCalled: false,
   1.156 -               focusSwitchedMustBeCalled: false,
   1.157 -               validatedStateChangedMustBeCalled: false,
   1.158 -               modelChangedMustBeCalled: false,
   1.159 -               sectionChangedMustBeCalled: true,
   1.160 -               expectedSection: attachmentSectionSection,
   1.161 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.162 -               hideSuggestionsMustBeCalled: false,
   1.163 -               showSuggestionsMustBeCalled: false,
   1.164 -               showMediaAttachmentPickerMustBeCalled: false,
   1.165 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.166 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.167 -               documentAttachmentPickerDonePickerCalled: true,
   1.168 -               didComposeNewMailMustBeCalled: false,
   1.169 -               didModifyMessageMustBeCalled: false,
   1.170 -               didDeleteMessageMustBeCalled: false)
   1.171 -        let countBefore = vm?.state.nonInlinedAttachments.count ?? -1
   1.172 -        let att = attachment()
   1.173 -        vm?.documentAttachmentPickerViewModel(TestDocumentAttachmentPickerViewModel(), didPick: att)
   1.174 -        let countAfter = vm?.state.nonInlinedAttachments.count ?? -1
   1.175 -        XCTAssertEqual(countAfter, countBefore + 1)
   1.176 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.177 -    }
   1.178 -
   1.179 -    func testDocumentAttachmentPickerDone() {
   1.180 -        assert(contentChangedMustBeCalled: false,
   1.181 -               focusSwitchedMustBeCalled: false,
   1.182 -               validatedStateChangedMustBeCalled: false,
   1.183 -               modelChangedMustBeCalled: false,
   1.184 -               sectionChangedMustBeCalled: false,
   1.185 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.186 -               hideSuggestionsMustBeCalled: false,
   1.187 -               showSuggestionsMustBeCalled: false,
   1.188 -               showMediaAttachmentPickerMustBeCalled: false,
   1.189 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.190 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.191 -               documentAttachmentPickerDonePickerCalled: true,
   1.192 -               didComposeNewMailMustBeCalled: false,
   1.193 -               didModifyMessageMustBeCalled: false,
   1.194 -               didDeleteMessageMustBeCalled: false)
   1.195 -        vm?.documentAttachmentPickerViewModelDidCancel(TestDocumentAttachmentPickerViewModel())
   1.196 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.197 -    }
   1.198 -
   1.199 -    // MARK: - MediaAttachmentPickerProviderViewModelResultDelegate Handling
   1.200 -
   1.201 -    func testMediaAttachmentPickerProviderViewModelFactory() {
   1.202 -        let testee = vm?.mediaAttachmentPickerProviderViewModel()
   1.203 -        XCTAssertNotNil(testee)
   1.204 -    }
   1.205 -
   1.206 -    func testDidSelectMediaAttachment_image() {
   1.207 -        let msg = draftMessage()
   1.208 -        let imageAttachment = attachment(ofType: .inline)
   1.209 -        msg.replaceAttachments(with: [imageAttachment])
   1.210 -        assert(originalMessage: msg,
   1.211 -               contentChangedMustBeCalled: false,
   1.212 -               focusSwitchedMustBeCalled: false,
   1.213 -               validatedStateChangedMustBeCalled: false,
   1.214 -               modelChangedMustBeCalled: false,
   1.215 -               sectionChangedMustBeCalled: false,
   1.216 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.217 -               hideSuggestionsMustBeCalled: false,
   1.218 -               showSuggestionsMustBeCalled: false,
   1.219 -               showMediaAttachmentPickerMustBeCalled: false,
   1.220 -               hideMediaAttachmentPickerMustBeCalled: true,
   1.221 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.222 -               documentAttachmentPickerDonePickerCalled: false,
   1.223 -               didComposeNewMailMustBeCalled: false,
   1.224 -               didModifyMessageMustBeCalled: false,
   1.225 -               didDeleteMessageMustBeCalled: false)
   1.226 -        let mediaAtt =
   1.227 -            MediaAttachmentPickerProviderViewModel.MediaAttachment(type: .image,
   1.228 -                                                                   attachment: imageAttachment)
   1.229 -        let countBefore = vm?.state.inlinedAttachments.count ?? -1
   1.230 -        vm?.mediaAttachmentPickerProviderViewModel(
   1.231 -            TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil),
   1.232 -            didSelect: mediaAtt)
   1.233 -        let countAfter = vm?.state.inlinedAttachments.count ?? -1
   1.234 -        XCTAssertEqual(countAfter, countBefore + 1)
   1.235 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.236 -
   1.237 -    }
   1.238 -
   1.239 -    func testDidSelectMediaAttachment_video() {
   1.240 -        let msg = draftMessage()
   1.241 -        let imageAttachment = attachment(ofType: .inline)
   1.242 -        msg.replaceAttachments(with: [imageAttachment])
   1.243 -
   1.244 -        let attachmentSectionSection = 4
   1.245 -
   1.246 -        assert(originalMessage: msg,
   1.247 -               contentChangedMustBeCalled: false,
   1.248 -               focusSwitchedMustBeCalled: false,
   1.249 -               validatedStateChangedMustBeCalled: false,
   1.250 -               modelChangedMustBeCalled: false,
   1.251 -               sectionChangedMustBeCalled: true,
   1.252 -               expectedSection: attachmentSectionSection,
   1.253 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.254 -               hideSuggestionsMustBeCalled: false,
   1.255 -               showSuggestionsMustBeCalled: false,
   1.256 -               showMediaAttachmentPickerMustBeCalled: false,
   1.257 -               hideMediaAttachmentPickerMustBeCalled: true,
   1.258 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.259 -               documentAttachmentPickerDonePickerCalled: false,
   1.260 -               didComposeNewMailMustBeCalled: false,
   1.261 -               didModifyMessageMustBeCalled: false,
   1.262 -               didDeleteMessageMustBeCalled: false)
   1.263 -        let mediaAtt =
   1.264 -            MediaAttachmentPickerProviderViewModel.MediaAttachment(type: .movie,
   1.265 -                                                                   attachment: imageAttachment)
   1.266 -        let countBefore = vm?.state.nonInlinedAttachments.count ?? -1
   1.267 -        vm?.mediaAttachmentPickerProviderViewModel(
   1.268 -            TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil),
   1.269 -            didSelect: mediaAtt)
   1.270 -        let countAfter = vm?.state.nonInlinedAttachments.count ?? -1
   1.271 -        XCTAssertEqual(countAfter, countBefore + 1)
   1.272 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.273 -    }
   1.274 -
   1.275 -    func testMediaPickerDidCancel() {
   1.276 -        assert(contentChangedMustBeCalled: false,
   1.277 -               focusSwitchedMustBeCalled: false,
   1.278 -               validatedStateChangedMustBeCalled: false,
   1.279 -               modelChangedMustBeCalled: false,
   1.280 -               sectionChangedMustBeCalled: false,
   1.281 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.282 -               hideSuggestionsMustBeCalled: false,
   1.283 -               showSuggestionsMustBeCalled: false,
   1.284 -               showMediaAttachmentPickerMustBeCalled: false,
   1.285 -               hideMediaAttachmentPickerMustBeCalled: true,
   1.286 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.287 -               documentAttachmentPickerDonePickerCalled: false,
   1.288 -               didComposeNewMailMustBeCalled: false,
   1.289 -               didModifyMessageMustBeCalled: false,
   1.290 -               didDeleteMessageMustBeCalled: false)
   1.291 -      vm?.mediaAttachmentPickerProviderViewModelDidCancel(
   1.292 -        TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil))
   1.293 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.294 -    }
   1.295 -
   1.296 -    // MARK: - BodyCellViewModelResultDelegate handling
   1.297 -
   1.298 -    private var bodyVm: BodyCellViewModel {
   1.299 -        return vm?.bodyVM ?? BodyCellViewModel(resultDelegate: nil)
   1.300 -    }
   1.301 -
   1.302 -    func testBodyVM() {
   1.303 -        let testee = vm?.bodyVM
   1.304 -        XCTAssertNotNil(testee)
   1.305 -    }
   1.306 -
   1.307 -    func testBodyCellViewModelUserWantsToAddMedia() {
   1.308 -        assert(contentChangedMustBeCalled: false,
   1.309 -               focusSwitchedMustBeCalled: false,
   1.310 -               validatedStateChangedMustBeCalled: false,
   1.311 -               modelChangedMustBeCalled: false,
   1.312 -               sectionChangedMustBeCalled: false,
   1.313 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.314 -               hideSuggestionsMustBeCalled: false,
   1.315 -               showSuggestionsMustBeCalled: false,
   1.316 -               showMediaAttachmentPickerMustBeCalled: true,
   1.317 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.318 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.319 -               documentAttachmentPickerDonePickerCalled: false,
   1.320 -               didComposeNewMailMustBeCalled: false,
   1.321 -               didModifyMessageMustBeCalled: false,
   1.322 -               didDeleteMessageMustBeCalled: false)
   1.323 -        vm?.bodyCellViewModelUserWantsToAddMedia(bodyVm)
   1.324 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.325 -    }
   1.326 -
   1.327 -    func testBodyCellViewModelUserWantsToAddDocument() {
   1.328 -        assert(contentChangedMustBeCalled: false,
   1.329 -               focusSwitchedMustBeCalled: false,
   1.330 -               validatedStateChangedMustBeCalled: false,
   1.331 -               modelChangedMustBeCalled: false,
   1.332 -               sectionChangedMustBeCalled: false,
   1.333 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.334 -               hideSuggestionsMustBeCalled: false,
   1.335 -               showSuggestionsMustBeCalled: false,
   1.336 -               showMediaAttachmentPickerMustBeCalled: false,
   1.337 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.338 -               showDocumentAttachmentPickerMustBeCalled: true,
   1.339 -               documentAttachmentPickerDonePickerCalled: false,
   1.340 -               didComposeNewMailMustBeCalled: false,
   1.341 -               didModifyMessageMustBeCalled: false,
   1.342 -               didDeleteMessageMustBeCalled: false)
   1.343 -        vm?.bodyCellViewModelUserWantsToAddDocument(bodyVm)
   1.344 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.345 -    }
   1.346 -
   1.347 -    func testBodyCellViewModelInlinedAttachmentsChanged_moreAttachments() {
   1.348 -        assert(contentChangedMustBeCalled: false,
   1.349 -               focusSwitchedMustBeCalled: false,
   1.350 -               validatedStateChangedMustBeCalled: false,
   1.351 -               modelChangedMustBeCalled: false,
   1.352 -               sectionChangedMustBeCalled: false,
   1.353 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.354 -               hideSuggestionsMustBeCalled: false,
   1.355 -               showSuggestionsMustBeCalled: false,
   1.356 -               showMediaAttachmentPickerMustBeCalled: false,
   1.357 -               hideMediaAttachmentPickerMustBeCalled: true,
   1.358 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.359 -               documentAttachmentPickerDonePickerCalled: false,
   1.360 -               didComposeNewMailMustBeCalled: false,
   1.361 -               didModifyMessageMustBeCalled: false,
   1.362 -               didDeleteMessageMustBeCalled: false)
   1.363 -        let countBefore = vm?.state.inlinedAttachments.count ?? -1
   1.364 -        vm?.bodyCellViewModel(bodyVm,
   1.365 -                              inlinedAttachmentsChanged: [attachment()])
   1.366 -        let countAfter = vm?.state.inlinedAttachments.count ?? -1
   1.367 -        XCTAssertEqual(countAfter, countBefore + 1)
   1.368 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.369 -    }
   1.370 -
   1.371 -    func testBodyCellViewModelInlinedAttachmentsChanged_lessAttachments() {
   1.372 -        let msg = draftMessage()
   1.373 -        let imageAttachment = attachment(ofType: .inline)
   1.374 -        msg.replaceAttachments(with: [imageAttachment])
   1.375 -        assert(originalMessage: msg,
   1.376 -               contentChangedMustBeCalled: false,
   1.377 -               focusSwitchedMustBeCalled: false,
   1.378 -               validatedStateChangedMustBeCalled: false,
   1.379 -               modelChangedMustBeCalled: false,
   1.380 -               sectionChangedMustBeCalled: false,
   1.381 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.382 -               hideSuggestionsMustBeCalled: false,
   1.383 -               showSuggestionsMustBeCalled: false,
   1.384 -               showMediaAttachmentPickerMustBeCalled: false,
   1.385 -               hideMediaAttachmentPickerMustBeCalled: true,
   1.386 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.387 -               documentAttachmentPickerDonePickerCalled: false,
   1.388 -               didComposeNewMailMustBeCalled: false,
   1.389 -               didModifyMessageMustBeCalled: false,
   1.390 -               didDeleteMessageMustBeCalled: false)
   1.391 -        let lessAttachments = [Attachment]()
   1.392 -        vm?.bodyCellViewModel(bodyVm,
   1.393 -                              inlinedAttachmentsChanged: lessAttachments)
   1.394 -        XCTAssertEqual(vm?.state.inlinedAttachments.count, lessAttachments.count)
   1.395 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.396 -    }
   1.397 -
   1.398 -    func testBodyChangedToPlaintextHtml() {
   1.399 -        assert(contentChangedMustBeCalled: true,
   1.400 -               focusSwitchedMustBeCalled: false,
   1.401 -               validatedStateChangedMustBeCalled: false,
   1.402 -               modelChangedMustBeCalled: false,
   1.403 -               sectionChangedMustBeCalled: false,
   1.404 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.405 -               hideSuggestionsMustBeCalled: false,
   1.406 -               showSuggestionsMustBeCalled: false,
   1.407 -               showMediaAttachmentPickerMustBeCalled: false,
   1.408 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.409 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.410 -               documentAttachmentPickerDonePickerCalled: false,
   1.411 -               didComposeNewMailMustBeCalled: false,
   1.412 -               didModifyMessageMustBeCalled: false,
   1.413 -               didDeleteMessageMustBeCalled: false)
   1.414 -        let newPlaintext = "newPlaitext"
   1.415 -        let newHtml = "<p>fake</p>"
   1.416 -        vm?.bodyCellViewModel(bodyVm,
   1.417 -                              bodyChangedToPlaintext: newPlaintext,
   1.418 -                              html: newHtml)
   1.419 -        XCTAssertEqual(vm?.state.bodyHtml, newHtml)
   1.420 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.421 -    }
   1.422 -
   1.423 -    // MARK: - SubjectCellViewModelResultDelegate Handling
   1.424 -
   1.425 -    private var subjectCellViewModel: SubjectCellViewModel? {
   1.426 -        return viewmodel(ofType: SubjectCellViewModel.self) as? SubjectCellViewModel
   1.427 -    }
   1.428 -
   1.429 -    func testSubjectCellViewModelDidChangeSubject() {
   1.430 -        assert(contentChangedMustBeCalled: true,
   1.431 -               focusSwitchedMustBeCalled: false,
   1.432 -               validatedStateChangedMustBeCalled: false,
   1.433 -               modelChangedMustBeCalled: false,
   1.434 -               sectionChangedMustBeCalled: false,
   1.435 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.436 -               hideSuggestionsMustBeCalled: false,
   1.437 -               showSuggestionsMustBeCalled: false,
   1.438 -               showMediaAttachmentPickerMustBeCalled: false,
   1.439 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.440 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.441 -               documentAttachmentPickerDonePickerCalled: false,
   1.442 -               didComposeNewMailMustBeCalled: false,
   1.443 -               didModifyMessageMustBeCalled: false,
   1.444 -               didDeleteMessageMustBeCalled: false)
   1.445 -        guard let subjectVm = subjectCellViewModel  else {
   1.446 -            XCTFail()
   1.447 -            return
   1.448 -        }
   1.449 -        let newSubject = "testSubjectCellViewModelDidChangeSubject content"
   1.450 -        subjectVm.content = newSubject
   1.451 -        vm?.subjectCellViewModelDidChangeSubject(subjectVm)
   1.452 -        XCTAssertEqual(vm?.state.subject, newSubject)
   1.453 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.454 -    }
   1.455 -
   1.456 -    // MARK: - AccountCellViewModelResultDelegate handling
   1.457 -
   1.458 -    private var accountCellViewModel: AccountCellViewModel? {
   1.459 -        return viewmodel(ofType: AccountCellViewModel.self) as? AccountCellViewModel
   1.460 -    }
   1.461 -
   1.462 -    func testAccountCellViewModelAccountChangedTo() {
   1.463 -        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
   1.464 -        secondAccount.save()
   1.465 -        assert(contentChangedMustBeCalled: true,
   1.466 -               focusSwitchedMustBeCalled: false,
   1.467 -               validatedStateChangedMustBeCalled: true,
   1.468 -               modelChangedMustBeCalled: false,
   1.469 -               sectionChangedMustBeCalled: false,
   1.470 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.471 -               hideSuggestionsMustBeCalled: false,
   1.472 -               showSuggestionsMustBeCalled: false,
   1.473 -               showMediaAttachmentPickerMustBeCalled: false,
   1.474 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.475 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.476 -               documentAttachmentPickerDonePickerCalled: false,
   1.477 -               didComposeNewMailMustBeCalled: false,
   1.478 -               didModifyMessageMustBeCalled: false,
   1.479 -               didDeleteMessageMustBeCalled: false)
   1.480 -        guard let accountVm = accountCellViewModel else {
   1.481 -            XCTFail()
   1.482 -            return
   1.483 -        }
   1.484 -        vm?.accountCellViewModel(accountVm, accountChangedTo: secondAccount)
   1.485 -        XCTAssertEqual(vm?.state.from, secondAccount.user)
   1.486 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.487 -    }
   1.488 -
   1.489 -    // MARK: - RecipientCellViewModelResultDelegate Handling
   1.490 -
   1.491 -    private func recipientCellViewModel(type: RecipientCellViewModel.FieldType) -> RecipientCellViewModel? {
   1.492 -        guard let sections = vm?.sections else {
   1.493 -            XCTFail()
   1.494 -            return nil
   1.495 -        }
   1.496 -        for section in sections {
   1.497 -            for row in section.rows where row is RecipientCellViewModel {
   1.498 -                if let row = row as? RecipientCellViewModel, row.type == type {
   1.499 -                    return row
   1.500 -                }
   1.501 -            }
   1.502 -        }
   1.503 -        return nil
   1.504 -    }
   1.505 -
   1.506 -    func testRecipientCellViewModelDidChangeRecipients_to() {
   1.507 -        assertRecipientCellViewModelDidChangeRecipients(fieldType: .to)
   1.508 -    }
   1.509 -
   1.510 -    func testRecipientCellViewModelDidChangeRecipients_cc() {
   1.511 -        assertRecipientCellViewModelDidChangeRecipients(fieldType: .cc)
   1.512 -    }
   1.513 -
   1.514 -    func testRecipientCellViewModelDidChangeRecipients_bcc() {
   1.515 -        assertRecipientCellViewModelDidChangeRecipients(fieldType: .bcc)
   1.516 -    }
   1.517 -
   1.518 -    func testRecipientCellViewModelDidEndEditing() {
   1.519 -        assert(contentChangedMustBeCalled: false,
   1.520 -               focusSwitchedMustBeCalled: true,
   1.521 -               validatedStateChangedMustBeCalled: true,
   1.522 -               modelChangedMustBeCalled: false,
   1.523 -               sectionChangedMustBeCalled: false,
   1.524 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.525 -               hideSuggestionsMustBeCalled: true,
   1.526 -               showSuggestionsMustBeCalled: false,
   1.527 -               showMediaAttachmentPickerMustBeCalled: false,
   1.528 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.529 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.530 -               documentAttachmentPickerDonePickerCalled: false,
   1.531 -               didComposeNewMailMustBeCalled: false,
   1.532 -               didModifyMessageMustBeCalled: false,
   1.533 -               didDeleteMessageMustBeCalled: false)
   1.534 -        guard let recipientVm = recipientCellViewModel(type: .to) else {
   1.535 -            XCTFail()
   1.536 -            return
   1.537 -        }
   1.538 -        vm?.recipientCellViewModelDidEndEditing(recipientVm)
   1.539 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.540 -    }
   1.541 -
   1.542 -    func testRecipientCellViewModelDidBeginEditing() {
   1.543 -        assert(contentChangedMustBeCalled: false,
   1.544 -               focusSwitchedMustBeCalled: false,
   1.545 -               validatedStateChangedMustBeCalled: false,
   1.546 -               modelChangedMustBeCalled: false,
   1.547 -               sectionChangedMustBeCalled: false,
   1.548 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.549 -               hideSuggestionsMustBeCalled: false,
   1.550 -               showSuggestionsMustBeCalled: true,
   1.551 -               showMediaAttachmentPickerMustBeCalled: false,
   1.552 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.553 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.554 -               documentAttachmentPickerDonePickerCalled: false,
   1.555 -               didComposeNewMailMustBeCalled: false,
   1.556 -               didModifyMessageMustBeCalled: false,
   1.557 -               didDeleteMessageMustBeCalled: false)
   1.558 -        guard let recipientVm = recipientCellViewModel(type: .to) else {
   1.559 -            XCTFail()
   1.560 -            return
   1.561 -        }
   1.562 -        let text = "testRecipientCellViewModelDidBeginEditing text"
   1.563 -        vm?.recipientCellViewModel(recipientVm, didBeginEditing: text)
   1.564 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.565 -    }
   1.566 -
   1.567 -    func testRecipientCellViewModelTextChanged() {
   1.568 -        assert(contentChangedMustBeCalled: true,
   1.569 -               focusSwitchedMustBeCalled: false,
   1.570 -               validatedStateChangedMustBeCalled: true,
   1.571 -               modelChangedMustBeCalled: false,
   1.572 -               sectionChangedMustBeCalled: false,
   1.573 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.574 -               hideSuggestionsMustBeCalled: false,
   1.575 -               showSuggestionsMustBeCalled: true,
   1.576 -               showMediaAttachmentPickerMustBeCalled: false,
   1.577 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.578 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.579 -               documentAttachmentPickerDonePickerCalled: false,
   1.580 -               didComposeNewMailMustBeCalled: false,
   1.581 -               didModifyMessageMustBeCalled: false,
   1.582 -               didDeleteMessageMustBeCalled: false)
   1.583 -        guard let recipientVm = recipientCellViewModel(type: .to) else {
   1.584 -            XCTFail()
   1.585 -            return
   1.586 -        }
   1.587 -        let text = "testRecipientCellViewModelDidBeginEditing text"
   1.588 -        vm?.recipientCellViewModel(recipientVm, textChanged: text)
   1.589 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.590 -    }
   1.591 -
   1.592 -    // MARK: - Cancel Actions
   1.593 -
   1.594 -    /*
   1.595 -    func testShowKeepInOutbox() {
   1.596 -        FolderType.allCases.forEach {
   1.597 -            assertShowKeepInOutbox(forMessageInfolderOfType: $0)
   1.598 -        }
   1.599 -    }
   1.600 - */
   1.601 -
   1.602 -    func testShowCancelActionsv() {
   1.603 -        let msg = message()
   1.604 -        assert(originalMessage: msg)
   1.605 -        guard let testee = vm?.showCancelActions else {
   1.606 -            XCTFail()
   1.607 -            return
   1.608 -        }
   1.609 -        XCTAssertFalse(testee)
   1.610 -    }
   1.611 -
   1.612 -    func testShowCancelActions_edited() {
   1.613 -        let msg = message()
   1.614 -        assert(originalMessage: msg)
   1.615 -        vm?.state.toRecipients = [Identity(address: "testShow@Cancel.Actions")]
   1.616 -        guard let testee = vm?.showCancelActions else {
   1.617 -            XCTFail()
   1.618 -            return
   1.619 -        }
   1.620 -        XCTAssertTrue(testee)
   1.621 -    }
   1.622 -
   1.623 -    func testHandleSaveActionTriggered() {
   1.624 -        assert(originalMessage: nil,
   1.625 -               contentChangedMustBeCalled: false,
   1.626 -               focusSwitchedMustBeCalled: false,
   1.627 -               validatedStateChangedMustBeCalled: false,
   1.628 -               modelChangedMustBeCalled: false,
   1.629 -               sectionChangedMustBeCalled: false,
   1.630 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.631 -               hideSuggestionsMustBeCalled: false,
   1.632 -               showSuggestionsMustBeCalled: false,
   1.633 -               showMediaAttachmentPickerMustBeCalled: false,
   1.634 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.635 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.636 -               documentAttachmentPickerDonePickerCalled: false,
   1.637 -               didComposeNewMailMustBeCalled: false,
   1.638 -               didModifyMessageMustBeCalled: false,
   1.639 -               didDeleteMessageMustBeCalled: false)
   1.640 -
   1.641 -        let testSubject = UUID().uuidString + "testSubject"
   1.642 -        vm?.state.subject = testSubject
   1.643 -
   1.644 -        vm?.handleSaveActionTriggered()
   1.645 -
   1.646 -        guard
   1.647 -            let draftsFolder = drafts,
   1.648 -            let testeeDrafted = Message.by(uid: 0,
   1.649 -                                           folderName: draftsFolder.name,
   1.650 -                                           accountAddress: account.user.address)
   1.651 -            else {
   1.652 -                XCTFail("Message not saved to drafts")
   1.653 -                return
   1.654 -        }
   1.655 -        XCTAssertEqual(testeeDrafted.shortMessage, testSubject)
   1.656 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.657 -    }
   1.658 -
   1.659 -    func testHandleSaveActionTriggered_origOutbox() {
   1.660 -        let testMessageId = UUID().uuidString + "testHandleSaveActionTriggered"
   1.661 -        let originalMessage = message(inFolderOfType: .outbox)
   1.662 -        originalMessage.messageID = testMessageId
   1.663 -        originalMessage.from = account.user
   1.664 -
   1.665 -        assert(originalMessage: originalMessage,
   1.666 -               contentChangedMustBeCalled: false,
   1.667 -               focusSwitchedMustBeCalled: false,
   1.668 -               validatedStateChangedMustBeCalled: false,
   1.669 -               modelChangedMustBeCalled: false,
   1.670 -               sectionChangedMustBeCalled: false,
   1.671 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.672 -               hideSuggestionsMustBeCalled: false,
   1.673 -               showSuggestionsMustBeCalled: false,
   1.674 -               showMediaAttachmentPickerMustBeCalled: false,
   1.675 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.676 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.677 -               documentAttachmentPickerDonePickerCalled: false,
   1.678 -               didComposeNewMailMustBeCalled: false,
   1.679 -               didModifyMessageMustBeCalled: false,
   1.680 -               didDeleteMessageMustBeCalled: true)
   1.681 -        vm?.handleSaveActionTriggered()
   1.682 -        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
   1.683 -                                              uuid: originalMessage.uuid,
   1.684 -                                              folderName: originalMessage.parent.name,
   1.685 -                                              accountAddress: account.user.address)
   1.686 -        XCTAssertNil(msgWithTestMessageId,
   1.687 -                     "original message must be deleted, a copy is safed to drafts")
   1.688 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.689 -    }
   1.690 -
   1.691 -    func testHandleSaveActionTriggered_origDrafts() {
   1.692 -        let testMessageId = UUID().uuidString + "testHandleSaveActionTriggered"
   1.693 -        let originalMessage = message(inFolderOfType: .drafts)
   1.694 -        originalMessage.messageID = testMessageId
   1.695 -        originalMessage.from = account.user
   1.696 -
   1.697 -        assert(originalMessage: originalMessage,
   1.698 -               contentChangedMustBeCalled: false,
   1.699 -               focusSwitchedMustBeCalled: false,
   1.700 -               validatedStateChangedMustBeCalled: false,
   1.701 -               modelChangedMustBeCalled: false,
   1.702 -               sectionChangedMustBeCalled: false,
   1.703 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.704 -               hideSuggestionsMustBeCalled: false,
   1.705 -               showSuggestionsMustBeCalled: false,
   1.706 -               showMediaAttachmentPickerMustBeCalled: false,
   1.707 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.708 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.709 -               documentAttachmentPickerDonePickerCalled: false,
   1.710 -               didComposeNewMailMustBeCalled: false,
   1.711 -               didModifyMessageMustBeCalled: true,
   1.712 -               didDeleteMessageMustBeCalled: true)
   1.713 -        vm?.handleSaveActionTriggered()
   1.714 -        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
   1.715 -                                              uuid: originalMessage.uuid,
   1.716 -                                              folderName: originalMessage.parent.name,
   1.717 -                                              accountAddress: account.user.address,
   1.718 -                                              includingDeleted: true)
   1.719 -        XCTAssertTrue(msgWithTestMessageId?.imapFlags.deleted ?? false,
   1.720 -                     "The user edited draft. Technically we save a new message, thus the original" +
   1.721 -            " must be deleted.")
   1.722 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.723 -    }
   1.724 -
   1.725 -    func testHandleDeleteActionTriggered_normal() {
   1.726 -        assert(originalMessage: nil,
   1.727 -               contentChangedMustBeCalled: false,
   1.728 -               focusSwitchedMustBeCalled: false,
   1.729 -               validatedStateChangedMustBeCalled: false,
   1.730 -               modelChangedMustBeCalled: false,
   1.731 -               sectionChangedMustBeCalled: false,
   1.732 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.733 -               hideSuggestionsMustBeCalled: false,
   1.734 -               showSuggestionsMustBeCalled: false,
   1.735 -               showMediaAttachmentPickerMustBeCalled: false,
   1.736 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.737 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.738 -               documentAttachmentPickerDonePickerCalled: false,
   1.739 -               didComposeNewMailMustBeCalled: false,
   1.740 -               didModifyMessageMustBeCalled: false,
   1.741 -               didDeleteMessageMustBeCalled: false)
   1.742 -        vm?.handleSaveActionTriggered() 
   1.743 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.744 -    }
   1.745 -
   1.746 -    func testHandleDeleteActionTriggered_origOutbox() {
   1.747 -        let testMessageId = UUID().uuidString + "testHandleDeleteActionTriggered_origOutbox"
   1.748 -        let originalMessage = message(inFolderOfType: .outbox)
   1.749 -        originalMessage.messageID = testMessageId
   1.750 -        originalMessage.from = account.user
   1.751 -
   1.752 -        assert(originalMessage: originalMessage,
   1.753 -               contentChangedMustBeCalled: false,
   1.754 -               focusSwitchedMustBeCalled: false,
   1.755 -               validatedStateChangedMustBeCalled: false,
   1.756 -               modelChangedMustBeCalled: false,
   1.757 -               sectionChangedMustBeCalled: false,
   1.758 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.759 -               hideSuggestionsMustBeCalled: false,
   1.760 -               showSuggestionsMustBeCalled: false,
   1.761 -               showMediaAttachmentPickerMustBeCalled: false,
   1.762 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.763 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.764 -               documentAttachmentPickerDonePickerCalled: false,
   1.765 -               didComposeNewMailMustBeCalled: false,
   1.766 -               didModifyMessageMustBeCalled: false,
   1.767 -               didDeleteMessageMustBeCalled: true)
   1.768 -        vm?.handleSaveActionTriggered()
   1.769 -        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
   1.770 -                                              uuid: originalMessage.uuid,
   1.771 -                                              folderName: originalMessage.parent.name,
   1.772 -                                              accountAddress: account.user.address)
   1.773 -        XCTAssertNil(msgWithTestMessageId,
   1.774 -                     "original message must be deleted, a copy is safed to drafts")
   1.775 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.776 -    }
   1.777 -
   1.778 -    // MARK: - Suggestions
   1.779 -
   1.780 -    func testSuggestViewModel() {
   1.781 -        let testee = vm?.suggestViewModel()
   1.782 -        XCTAssertNotNil(testee)
   1.783 -        XCTAssertTrue(testee?.resultDelegate === vm)
   1.784 -    }
   1.785 -
   1.786 -    // showSuggestions and hideSuggestions are tested altering recipients
   1.787 -
   1.788 -    func testShowSuggestionsScrollFocus_nonEmpty() {
   1.789 -        let expectedSuggestionsVisibility = true
   1.790 -        assert(contentChangedMustBeCalled: false,
   1.791 -               focusSwitchedMustBeCalled: false,
   1.792 -               validatedStateChangedMustBeCalled: false,
   1.793 -               expectedIsValidated: nil,
   1.794 -               modelChangedMustBeCalled: false,
   1.795 -               sectionChangedMustBeCalled: false,
   1.796 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.797 -               hideSuggestionsMustBeCalled: false,
   1.798 -               showSuggestionsMustBeCalled: false,
   1.799 -               suggestionsScrollFocusChangedMustBeCalled: true,
   1.800 -               expectedNewSuggestionsScrollFocusIsVisible: expectedSuggestionsVisibility,
   1.801 -               showMediaAttachmentPickerMustBeCalled: false,
   1.802 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.803 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.804 -               documentAttachmentPickerDonePickerCalled: false,
   1.805 -               didComposeNewMailMustBeCalled: false,
   1.806 -               didModifyMessageMustBeCalled: false,
   1.807 -               didDeleteMessageMustBeCalled: false)
   1.808 -        let _ = vm?.suggestViewModel(SuggestViewModel(),
   1.809 -                                     didToggleVisibilityTo: expectedSuggestionsVisibility)
   1.810 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.811 -    }
   1.812 -
   1.813 -    func testShowSuggestionsScrollFocus_empty() {
   1.814 -        let expectedSuggestionsVisibility = false
   1.815 -        assert(contentChangedMustBeCalled: false,
   1.816 -               focusSwitchedMustBeCalled: false,
   1.817 -               validatedStateChangedMustBeCalled: false,
   1.818 -               expectedIsValidated: nil,
   1.819 -               modelChangedMustBeCalled: false,
   1.820 -               sectionChangedMustBeCalled: false,
   1.821 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.822 -               hideSuggestionsMustBeCalled: false,
   1.823 -               showSuggestionsMustBeCalled: false,
   1.824 -               suggestionsScrollFocusChangedMustBeCalled: true,
   1.825 -               expectedNewSuggestionsScrollFocusIsVisible: expectedSuggestionsVisibility,
   1.826 -               showMediaAttachmentPickerMustBeCalled: false,
   1.827 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.828 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.829 -               documentAttachmentPickerDonePickerCalled: false,
   1.830 -               didComposeNewMailMustBeCalled: false,
   1.831 -               didModifyMessageMustBeCalled: false,
   1.832 -               didDeleteMessageMustBeCalled: false)
   1.833 -        let _ = vm?.suggestViewModel(SuggestViewModel(),
   1.834 -                                     didToggleVisibilityTo: expectedSuggestionsVisibility)
   1.835 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.836 -    }
   1.837 -
   1.838 -// MARK: - ComposeViewModelStateDelegate Handling
   1.839 -
   1.840 -    func testComposeViewModelStateDidChangeValidationStateTo() {
   1.841 -        let expectedIsValid = true
   1.842 -        assert(contentChangedMustBeCalled: false,
   1.843 -               focusSwitchedMustBeCalled: false,
   1.844 -               validatedStateChangedMustBeCalled: true,
   1.845 -               expectedIsValidated: expectedIsValid,
   1.846 -               modelChangedMustBeCalled: false,
   1.847 -               sectionChangedMustBeCalled: false,
   1.848 -               colorBatchNeedsUpdateMustBeCalled: false,
   1.849 -               hideSuggestionsMustBeCalled: false,
   1.850 -               showSuggestionsMustBeCalled: false,
   1.851 -               showMediaAttachmentPickerMustBeCalled: false,
   1.852 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.853 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.854 -               documentAttachmentPickerDonePickerCalled: false,
   1.855 -               didComposeNewMailMustBeCalled: false,
   1.856 -               didModifyMessageMustBeCalled: false,
   1.857 -               didDeleteMessageMustBeCalled: false)
   1.858 -        guard let state = vm?.state else {
   1.859 -            XCTFail()
   1.860 -            return
   1.861 -        }
   1.862 -        vm?.composeViewModelState(state, didChangeValidationStateTo: expectedIsValid)
   1.863 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.864 -    }
   1.865 -
   1.866 -    func testComposeViewModelDidChangePEPRatingTo() {
   1.867 -        let expectedRating = PEPRating.reliable
   1.868 -        vm?.state.pEpProtection = true
   1.869 -        let expectedProtection = vm?.state.pEpProtection ?? false
   1.870 -        assert(contentChangedMustBeCalled: false,
   1.871 -               focusSwitchedMustBeCalled: false,
   1.872 -               validatedStateChangedMustBeCalled: false,
   1.873 -               modelChangedMustBeCalled: false,
   1.874 -               sectionChangedMustBeCalled: false,
   1.875 -               colorBatchNeedsUpdateMustBeCalled: true,
   1.876 -               expectedRating: expectedRating,
   1.877 -               expectedProtectionEnabled: expectedProtection,
   1.878 -               hideSuggestionsMustBeCalled: false,
   1.879 -               showSuggestionsMustBeCalled: false,
   1.880 -               showMediaAttachmentPickerMustBeCalled: false,
   1.881 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.882 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.883 -               documentAttachmentPickerDonePickerCalled: false,
   1.884 -               didComposeNewMailMustBeCalled: false,
   1.885 -               didModifyMessageMustBeCalled: false,
   1.886 -               didDeleteMessageMustBeCalled: false)
   1.887 -        guard let state = vm?.state else {
   1.888 -            XCTFail()
   1.889 -            return
   1.890 -        }
   1.891 -        vm?.composeViewModelState(state, didChangePEPRatingTo: expectedRating)
   1.892 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.893 -    }
   1.894 -
   1.895 -    // MARK: - Delegate Setter Side Effect
   1.896 -
   1.897 -    func testDelegateSetter() {
   1.898 -        let expectedRating = PEPRating.undefined
   1.899 -        let expectedProtection = true
   1.900 -        assert(contentChangedMustBeCalled: false,
   1.901 -               focusSwitchedMustBeCalled: false,
   1.902 -               validatedStateChangedMustBeCalled: false,
   1.903 -               modelChangedMustBeCalled: false,
   1.904 -               sectionChangedMustBeCalled: false,
   1.905 -               colorBatchNeedsUpdateMustBeCalled: true,
   1.906 -               expectedRating: expectedRating,
   1.907 -               expectedProtectionEnabled: expectedProtection,
   1.908 -               hideSuggestionsMustBeCalled: false,
   1.909 -               showSuggestionsMustBeCalled: false,
   1.910 -               showMediaAttachmentPickerMustBeCalled: false,
   1.911 -               hideMediaAttachmentPickerMustBeCalled: false,
   1.912 -               showDocumentAttachmentPickerMustBeCalled: false,
   1.913 -               documentAttachmentPickerDonePickerCalled: false,
   1.914 -               didComposeNewMailMustBeCalled: false,
   1.915 -               didModifyMessageMustBeCalled: false,
   1.916 -               didDeleteMessageMustBeCalled: false)
   1.917 -        vm?.delegate = testDelegate
   1.918 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
   1.919 -    }
   1.920 -
   1.921 -    // MARK: - isAttachmentSection
   1.922 -
   1.923 -    func testIsAttachmentSection() {
   1.924 -        let msgWithAttachment = draftMessage(attachmentsSet: true)
   1.925 -        assert(originalMessage: msgWithAttachment)
   1.926 -        guard
   1.927 -            let lastSection = vm?.sections.last,
   1.928 -            let numSections = vm?.sections.count else {
   1.929 -                XCTFail()
   1.930 -                return
   1.931 -        }
   1.932 -        let numRows = lastSection.rows.count
   1.933 -        let idxPath = IndexPath(row: numRows - 1, section: numSections - 1)
   1.934 -        XCTAssertTrue(vm?.isAttachmentSection(indexPath: idxPath) ?? false,
   1.935 -                      "Last row in last section must be attachment")
   1.936 -    }
   1.937 -
   1.938 -    // MARK: - handleRemovedRow
   1.939 -
   1.940 -    func testHandleRemovedRow_removeAttachment() {
   1.941 -        let msgWithAttachments = draftMessage(attachmentsSet: true)
   1.942 -        msgWithAttachments.appendToAttachments(attachment(ofType: .attachment))
   1.943 -        msgWithAttachments.save()
   1.944 -        assert(originalMessage: msgWithAttachments)
   1.945 -        vm?.state.nonInlinedAttachments = msgWithAttachments.attachments.array
   1.946 -        guard
   1.947 -            let lastSectionBefore = vm?.sections.last,
   1.948 -            let numSectionsBefore = vm?.sections.count,
   1.949 -            let numNonIlinedAttachmentsBefore = vm?.state.nonInlinedAttachments.count
   1.950 -            else {
   1.951 -                XCTFail()
   1.952 -                return
   1.953 -        }
   1.954 -        let numRowsBefore  = lastSectionBefore.rows.count
   1.955 -        let attachmentIdxPath = IndexPath(row: numRowsBefore - 1,
   1.956 -                                          section: numSectionsBefore - 1)
   1.957 -        // Test
   1.958 -        vm?.handleRemovedRow(at: attachmentIdxPath)
   1.959 -        guard
   1.960 -            let lastSectionAfter = vm?.sections.last,
   1.961 -            let numSectionsAfter = vm?.sections.count,
   1.962 -            let numNonIlinedAttachmentsAfter = vm?.state.nonInlinedAttachments.count
   1.963 -            else {
   1.964 -                XCTFail()
   1.965 -                return
   1.966 -        }
   1.967 -        let numRowsAfter = lastSectionAfter.rows.count
   1.968 -        XCTAssertEqual(numNonIlinedAttachmentsAfter, numNonIlinedAttachmentsBefore - 1)
   1.969 -        XCTAssertEqual(numSectionsAfter, numSectionsBefore)
   1.970 -        XCTAssertEqual(numRowsAfter, numRowsBefore - 1, "Attachment is removed")
   1.971 -    }
   1.972 -
   1.973 -    // MARK: - handleUserClickedSendButton
   1.974 -
   1.975 -    func testHandleUserClickedSendButton() {
   1.976 -        assert()
   1.977 -        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
   1.978 -        vm?.state.toRecipients = [toRecipient]
   1.979 -        vm?.state.from = account.user
   1.980 -        let outMsgsBefore = Folder.by(account: account, folderType: .outbox)?
   1.981 -            .allMessagesNonThreaded()
   1.982 -            .count ?? -1
   1.983 -        vm?.handleUserClickedSendButton()
   1.984 -        let outMsgsAfter = Folder.by(account: account, folderType: .outbox)?
   1.985 -            .allMessagesNonThreaded()
   1.986 -            .count ?? -1
   1.987 -        XCTAssertEqual(outMsgsAfter, outMsgsBefore + 1)
   1.988 -        XCTAssertGreaterThan(outMsgsAfter, 0)
   1.989 -    }
   1.990 -
   1.991 -    func testHandleUserClickedSendButton_origDraft() {
   1.992 -        let testMessageId = UUID().uuidString + #function
   1.993 -        let originalMessage = draftMessage()
   1.994 -        originalMessage.messageID = testMessageId
   1.995 -        originalMessage.from = account.user
   1.996 -        originalMessage.save()
   1.997 -        XCTAssertNotNil(Message.by(uid: originalMessage.uid,
   1.998 -                                   uuid: originalMessage.uuid,
   1.999 -                                   folderName: originalMessage.parent.name,
  1.1000 -                                   accountAddress: account.user.address))
  1.1001 -        assert(originalMessage: originalMessage)
  1.1002 -        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
  1.1003 -        vm?.state.toRecipients = [toRecipient]
  1.1004 -        vm?.state.from = account.user
  1.1005 -        vm?.handleUserClickedSendButton()
  1.1006 -        guard
  1.1007 -            let originalDraftedMessageDeleted =
  1.1008 -            Message.by(uid: originalMessage.uid,
  1.1009 -                       uuid: originalMessage.uuid,
  1.1010 -                       folderName: originalMessage.parent.name,
  1.1011 -                       accountAddress: account.user.address,
  1.1012 -                       includingDeleted: true)?.imapFlags.deleted
  1.1013 -            else {
  1.1014 -                XCTFail()
  1.1015 -                return
  1.1016 -        }
  1.1017 -        XCTAssertTrue(originalDraftedMessageDeleted,
  1.1018 -                      "original drafted message must be flagged deleted")
  1.1019 -    }
  1.1020 -
  1.1021 -    func testHandleUserClickedSendButton_origOutbox() {
  1.1022 -        let testMessageId = UUID().uuidString + #function
  1.1023 -        let originalMessage = message(inFolderOfType: .outbox)
  1.1024 -        originalMessage.messageID = testMessageId
  1.1025 -        originalMessage.from = account.user
  1.1026 -        originalMessage.save()
  1.1027 -        XCTAssertNotNil(Message.by(uid: originalMessage.uid,
  1.1028 -                                   uuid: originalMessage.uuid,
  1.1029 -                                   folderName: originalMessage.parent.name,
  1.1030 -                                   accountAddress: account.user.address))
  1.1031 -        assert(originalMessage: originalMessage)
  1.1032 -        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
  1.1033 -        vm?.state.toRecipients = [toRecipient]
  1.1034 -        vm?.state.from = account.user
  1.1035 -        vm?.handleUserClickedSendButton()
  1.1036 -        if let _ = Message.by(uid: originalMessage.uid,
  1.1037 -                              uuid: originalMessage.uuid,
  1.1038 -                              folderName: originalMessage.parent.name,
  1.1039 -                              accountAddress: account.user.address) {
  1.1040 -            XCTFail("original message must not exist (must be deleted)")
  1.1041 -            return
  1.1042 -        }
  1.1043 -    }
  1.1044 -
  1.1045 -    // MARK: - handleUserChangedProtectionStatus
  1.1046 -
  1.1047 -    func testHandleUserChangedProtectionStatus_change() {
  1.1048 -        let expectedRating = PEPRating.undefined
  1.1049 -        let expectedProtection = false
  1.1050 -        assert(contentChangedMustBeCalled: false,
  1.1051 -               focusSwitchedMustBeCalled: false,
  1.1052 -               validatedStateChangedMustBeCalled: false,
  1.1053 -               modelChangedMustBeCalled: false,
  1.1054 -               sectionChangedMustBeCalled: false,
  1.1055 -               colorBatchNeedsUpdateMustBeCalled: true,
  1.1056 -               expectedRating: expectedRating,
  1.1057 -               expectedProtectionEnabled: expectedProtection,
  1.1058 -               hideSuggestionsMustBeCalled: false,
  1.1059 -               showSuggestionsMustBeCalled: false,
  1.1060 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1061 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1062 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1063 -               documentAttachmentPickerDonePickerCalled: false,
  1.1064 -               didComposeNewMailMustBeCalled: false,
  1.1065 -               didModifyMessageMustBeCalled: false,
  1.1066 -               didDeleteMessageMustBeCalled: false)
  1.1067 -        vm?.handleUserChangedProtectionStatus(to: false)
  1.1068 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1069 -    }
  1.1070 -
  1.1071 -    func testHandleUserChangedProtectionStatus_noChange() {
  1.1072 -        assert(contentChangedMustBeCalled: false,
  1.1073 -               focusSwitchedMustBeCalled: false,
  1.1074 -               validatedStateChangedMustBeCalled: false,
  1.1075 -               modelChangedMustBeCalled: false,
  1.1076 -               sectionChangedMustBeCalled: false,
  1.1077 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1078 -               hideSuggestionsMustBeCalled: false,
  1.1079 -               showSuggestionsMustBeCalled: false,
  1.1080 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1081 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1082 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1083 -               documentAttachmentPickerDonePickerCalled: false,
  1.1084 -               didComposeNewMailMustBeCalled: false,
  1.1085 -               didModifyMessageMustBeCalled: false,
  1.1086 -               didDeleteMessageMustBeCalled: false)
  1.1087 -        vm?.handleUserChangedProtectionStatus(to: true)
  1.1088 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1089 -    }
  1.1090 -
  1.1091 -    // MARK: - handleUserSelectedRow
  1.1092 -
  1.1093 -    func testHandleUserSelectedRow_ccWrapped_wrapperCellSelected() {
  1.1094 -        assert(contentChangedMustBeCalled: false,
  1.1095 -               focusSwitchedMustBeCalled: false,
  1.1096 -               validatedStateChangedMustBeCalled: false,
  1.1097 -               modelChangedMustBeCalled: false,
  1.1098 -               sectionChangedMustBeCalled: true,
  1.1099 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1100 -               hideSuggestionsMustBeCalled: false,
  1.1101 -               showSuggestionsMustBeCalled: false,
  1.1102 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1103 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1104 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1105 -               documentAttachmentPickerDonePickerCalled: false,
  1.1106 -               didComposeNewMailMustBeCalled: false,
  1.1107 -               didModifyMessageMustBeCalled: false,
  1.1108 -               didDeleteMessageMustBeCalled: false)
  1.1109 -        guard
  1.1110 -            let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self),
  1.1111 -            let idxPath = indexPath(for: wrapperVM) else {
  1.1112 -                XCTFail("No VM")
  1.1113 -                return
  1.1114 -        }
  1.1115 -        vm?.handleUserSelectedRow(at: idxPath)
  1.1116 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1117 -    }
  1.1118 -
  1.1119 -    func testHandleUserSelectedRow_ccWrapped_recipientCellSelected() {
  1.1120 -        assert(contentChangedMustBeCalled: false,
  1.1121 -               focusSwitchedMustBeCalled: false,
  1.1122 -               validatedStateChangedMustBeCalled: false,
  1.1123 -               modelChangedMustBeCalled: false,
  1.1124 -               sectionChangedMustBeCalled: false,
  1.1125 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1126 -               hideSuggestionsMustBeCalled: false,
  1.1127 -               showSuggestionsMustBeCalled: false,
  1.1128 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1129 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1130 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1131 -               documentAttachmentPickerDonePickerCalled: false,
  1.1132 -               didComposeNewMailMustBeCalled: false,
  1.1133 -               didModifyMessageMustBeCalled: false,
  1.1134 -               didDeleteMessageMustBeCalled: false)
  1.1135 -        let idxPathToRecipients = IndexPath(row: 0, section: 0)
  1.1136 -        vm?.handleUserSelectedRow(at: idxPathToRecipients)
  1.1137 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1138 -    }
  1.1139 -
  1.1140 -    func testHandleUserSelectedRow_ccUnwrapped_recipientCellSelected() {
  1.1141 -        let originalMessage = draftMessage()
  1.1142 -        assert(originalMessage: originalMessage,
  1.1143 -               contentChangedMustBeCalled: false,
  1.1144 -               focusSwitchedMustBeCalled: false,
  1.1145 -               validatedStateChangedMustBeCalled: false,
  1.1146 -               modelChangedMustBeCalled: false,
  1.1147 -               sectionChangedMustBeCalled: false,
  1.1148 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1149 -               hideSuggestionsMustBeCalled: false,
  1.1150 -               showSuggestionsMustBeCalled: false,
  1.1151 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1152 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1153 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1154 -               documentAttachmentPickerDonePickerCalled: false,
  1.1155 -               didComposeNewMailMustBeCalled: false,
  1.1156 -               didModifyMessageMustBeCalled: false,
  1.1157 -               didDeleteMessageMustBeCalled: false)
  1.1158 -        let idxPathToRecipients = IndexPath(row: 0, section: 0)
  1.1159 -        vm?.handleUserSelectedRow(at: idxPathToRecipients)
  1.1160 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1161 -    }
  1.1162 -
  1.1163 -    // MARK: - viewModel(for:)
  1.1164 -
  1.1165 -    func testViewModelForIndexPath() {
  1.1166 -        assert(contentChangedMustBeCalled: false,
  1.1167 -               focusSwitchedMustBeCalled: false,
  1.1168 -               validatedStateChangedMustBeCalled: false,
  1.1169 -               modelChangedMustBeCalled: false,
  1.1170 -               sectionChangedMustBeCalled: false,
  1.1171 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1172 -               hideSuggestionsMustBeCalled: false,
  1.1173 -               showSuggestionsMustBeCalled: false,
  1.1174 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1175 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1176 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1177 -               documentAttachmentPickerDonePickerCalled: false,
  1.1178 -               didComposeNewMailMustBeCalled: false,
  1.1179 -               didModifyMessageMustBeCalled: false,
  1.1180 -               didDeleteMessageMustBeCalled: false)
  1.1181 -        guard
  1.1182 -            let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self),
  1.1183 -            let idxPath = indexPath(for: wrapperVM) else {
  1.1184 -                XCTFail("No VM")
  1.1185 -                return
  1.1186 -        }
  1.1187 -        guard let testee = vm?.viewModel(for: idxPath) else {
  1.1188 -            XCTFail()
  1.1189 -            return
  1.1190 -        }
  1.1191 -        XCTAssertTrue(testee === wrapperVM)
  1.1192 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1193 -    }
  1.1194 -
  1.1195 -    func testViewModelForIndexPath_notAlwaysWrapper() {
  1.1196 -        assert()
  1.1197 -        guard let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self) else {
  1.1198 -                XCTFail("No VM")
  1.1199 -                return
  1.1200 -        }
  1.1201 -        let toRecipientsIdxPath = IndexPath(row: 0, section: 0)
  1.1202 -        guard let testee = vm?.viewModel(for: toRecipientsIdxPath) else {
  1.1203 -            XCTFail()
  1.1204 -            return
  1.1205 -        }
  1.1206 -        XCTAssertFalse(testee === wrapperVM)
  1.1207 -    }
  1.1208 -
  1.1209 -    // MARK: - beforePickerFocus
  1.1210 -
  1.1211 -    func testBeforePickerFocus() {
  1.1212 -        assert()
  1.1213 -        guard let bodyVm = vm?.bodyVM else {
  1.1214 -            XCTFail()
  1.1215 -            return
  1.1216 -        }
  1.1217 -        let beforeFocus = indexPath(for: bodyVm)
  1.1218 -        let testee = vm?.beforePickerFocus()
  1.1219 -        XCTAssertEqual(testee, beforeFocus)
  1.1220 -        let toRecipientsIndPath = IndexPath(row: 0, section: 0)
  1.1221 -        XCTAssertNotEqual(testee, toRecipientsIndPath)
  1.1222 -    }
  1.1223 -
  1.1224 -    // MARK: - initialFocus
  1.1225 -
  1.1226 -    func testInitialFocus_emptyTo() {
  1.1227 -        let originalMessage = draftMessage()
  1.1228 -        originalMessage.replaceTo(with: [])
  1.1229 -        originalMessage.save()
  1.1230 -        assert(originalMessage: originalMessage,
  1.1231 -               contentChangedMustBeCalled: false,
  1.1232 -               focusSwitchedMustBeCalled: false,
  1.1233 -               validatedStateChangedMustBeCalled: false,
  1.1234 -               modelChangedMustBeCalled: false,
  1.1235 -               sectionChangedMustBeCalled: false,
  1.1236 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1237 -               hideSuggestionsMustBeCalled: false,
  1.1238 -               showSuggestionsMustBeCalled: false,
  1.1239 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1240 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1241 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1242 -               documentAttachmentPickerDonePickerCalled: false,
  1.1243 -               didComposeNewMailMustBeCalled: false,
  1.1244 -               didModifyMessageMustBeCalled: false,
  1.1245 -               didDeleteMessageMustBeCalled: false)
  1.1246 -        guard let testee = vm?.initialFocus() else {
  1.1247 -            XCTFail()
  1.1248 -            return
  1.1249 -        }
  1.1250 -        let toRecipientsIndPath = IndexPath(row: 0, section: 0)
  1.1251 -        XCTAssertEqual(testee, toRecipientsIndPath)
  1.1252 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1253 -    }
  1.1254 -
  1.1255 -    func testInitialFocus_toSet() {
  1.1256 -        let originalMessage = draftMessage()
  1.1257 -        originalMessage.replaceTo(with: [account.user])
  1.1258 -        originalMessage.save()
  1.1259 -        assert(originalMessage: originalMessage,
  1.1260 -               contentChangedMustBeCalled: false,
  1.1261 -               focusSwitchedMustBeCalled: false,
  1.1262 -               validatedStateChangedMustBeCalled: false,
  1.1263 -               modelChangedMustBeCalled: false,
  1.1264 -               sectionChangedMustBeCalled: false,
  1.1265 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1266 -               hideSuggestionsMustBeCalled: false,
  1.1267 -               showSuggestionsMustBeCalled: false,
  1.1268 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1269 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1270 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1271 -               documentAttachmentPickerDonePickerCalled: false,
  1.1272 -               didComposeNewMailMustBeCalled: false,
  1.1273 -               didModifyMessageMustBeCalled: false,
  1.1274 -               didDeleteMessageMustBeCalled: false)
  1.1275 -        guard
  1.1276 -            let testee = vm?.initialFocus(),
  1.1277 -            let bodyVM = vm?.bodyVM,
  1.1278 -            let bodyIndexPath = indexPath(for: bodyVM)
  1.1279 -            else {
  1.1280 -                XCTFail()
  1.1281 -                return
  1.1282 -        }
  1.1283 -        let toRecipientsIndexPath = IndexPath(row: 0, section: 0)
  1.1284 -        XCTAssertEqual(testee, bodyIndexPath)
  1.1285 -        XCTAssertNotEqual(testee, toRecipientsIndexPath)
  1.1286 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1287 -    }
  1.1288 -
  1.1289 -    // MARK: - Helper
  1.1290 -
  1.1291 -    private func indexPath(for cellViewModel: CellViewModel) -> IndexPath? {
  1.1292 -        guard let vm = vm else {
  1.1293 -            XCTFail("No VM")
  1.1294 -            return nil
  1.1295 -        }
  1.1296 -        for s in 0..<vm.sections.count {
  1.1297 -            let section = vm.sections[s]
  1.1298 -            for r in 0..<section.rows.count {
  1.1299 -                let row = section.rows[r]
  1.1300 -                if row === cellViewModel {
  1.1301 -                    return IndexPath(row: r, section: s)
  1.1302 -                }
  1.1303 -            }
  1.1304 -        }
  1.1305 -        return nil
  1.1306 -    }
  1.1307 -
  1.1308 -    private func assureOutboxExists() {
  1.1309 -        if outbox == nil {
  1.1310 -            let createe = Folder(name: "outbox", parent: nil, account: account, folderType: .outbox)
  1.1311 -            createe.save()
  1.1312 -        }
  1.1313 -        XCTAssertNotNil(outbox)
  1.1314 -    }
  1.1315 -
  1.1316 -    private func assureDraftsExists() {
  1.1317 -        if drafts == nil {
  1.1318 -            let createe = Folder(name: "drafts",
  1.1319 -                                 parent: nil,
  1.1320 -                                 account: account,
  1.1321 -                                 folderType: .drafts)
  1.1322 -            createe.save()
  1.1323 -        }
  1.1324 -        XCTAssertNotNil(drafts)
  1.1325 -    }
  1.1326 -
  1.1327 -    private func assureSentExists() {
  1.1328 -        if sent == nil {
  1.1329 -            let createe = Folder(name: "sent",
  1.1330 -                                 parent: nil,
  1.1331 -                                 account: account,
  1.1332 -                                 folderType: .sent)
  1.1333 -            createe.save()
  1.1334 -        }
  1.1335 -        XCTAssertNotNil(sent)
  1.1336 -    }
  1.1337 -
  1.1338 -    private func assertShowKeepInOutbox(forMessageInfolderOfType type: FolderType) {
  1.1339 -        let msg = message(inFolderOfType: type)
  1.1340 -        assert(originalMessage: msg,
  1.1341 -               contentChangedMustBeCalled: false,
  1.1342 -               focusSwitchedMustBeCalled: false,
  1.1343 -               validatedStateChangedMustBeCalled: false,
  1.1344 -               modelChangedMustBeCalled: false,
  1.1345 -               sectionChangedMustBeCalled: false,
  1.1346 -               colorBatchNeedsUpdateMustBeCalled: false,
  1.1347 -               hideSuggestionsMustBeCalled: false,
  1.1348 -               showSuggestionsMustBeCalled: false,
  1.1349 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1350 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1351 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1352 -               documentAttachmentPickerDonePickerCalled: false,
  1.1353 -               didComposeNewMailMustBeCalled: false,
  1.1354 -               didModifyMessageMustBeCalled: false,
  1.1355 -               didDeleteMessageMustBeCalled: false)
  1.1356 -        let testee = vm?.showKeepInOutbox
  1.1357 -        XCTAssertEqual(testee, type == .outbox)
  1.1358 -        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1359 -    }
  1.1360 -
  1.1361 -    private func assertRecipientCellViewModelDidChangeRecipients(
  1.1362 -        fieldType type: RecipientCellViewModel.FieldType) {
  1.1363 -        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
  1.1364 -        secondAccount.save()
  1.1365 -        let om = draftMessage(bccSet: true, attachmentsSet: false)
  1.1366 -        assert(originalMessage: om,
  1.1367 -               contentChangedMustBeCalled: false,
  1.1368 -               focusSwitchedMustBeCalled: false,
  1.1369 -               validatedStateChangedMustBeCalled: true,
  1.1370 -               modelChangedMustBeCalled: false,
  1.1371 -               sectionChangedMustBeCalled: false,
  1.1372 -               colorBatchNeedsUpdateMustBeCalled: true,
  1.1373 -               hideSuggestionsMustBeCalled: false,
  1.1374 -               showSuggestionsMustBeCalled: false,
  1.1375 -               showMediaAttachmentPickerMustBeCalled: false,
  1.1376 -               hideMediaAttachmentPickerMustBeCalled: false,
  1.1377 -               showDocumentAttachmentPickerMustBeCalled: false,
  1.1378 -               documentAttachmentPickerDonePickerCalled: false,
  1.1379 -               didComposeNewMailMustBeCalled: false,
  1.1380 -               didModifyMessageMustBeCalled: false,
  1.1381 -               didDeleteMessageMustBeCalled: false)
  1.1382 -        guard let recipientVm = recipientCellViewModel(type: type) else {
  1.1383 -            XCTFail()
  1.1384 -            return
  1.1385 -        }
  1.1386 -
  1.1387 -        let beforeCount: Int
  1.1388 -        switch type {
  1.1389 -        case .to:
  1.1390 -            beforeCount = vm?.state.toRecipients.count ?? -2
  1.1391 -        case .cc:
  1.1392 -            beforeCount = vm?.state.ccRecipients.count ?? -2
  1.1393 -        case .bcc:
  1.1394 -            beforeCount = vm?.state.bccRecipients.count ?? -2
  1.1395 -        }
  1.1396 -
  1.1397 -        let newRecipients = [account.user, secondAccount.user]
  1.1398 -        vm?.recipientCellViewModel(recipientVm, didChangeRecipients: newRecipients)
  1.1399 -
  1.1400 -        let afterCount: Int
  1.1401 -        switch type {
  1.1402 -        case .to:
  1.1403 -            afterCount = vm?.state.toRecipients.count ?? -2
  1.1404 -        case .cc:
  1.1405 -            afterCount = vm?.state.ccRecipients.count ?? -2
  1.1406 -        case .bcc:
  1.1407 -            afterCount = vm?.state.bccRecipients.count ?? -2
  1.1408 -        }
  1.1409 -        XCTAssertNotEqual(afterCount, beforeCount)
  1.1410 -        XCTAssertEqual(afterCount, newRecipients.count)
  1.1411 -        waitForExpectations(timeout: UnitTestUtils.asyncWaitTime) // Async calls involved (get pEp color)
  1.1412 -    }
  1.1413 -
  1.1414 -    private func viewmodel(ofType vmType: AnyClass) -> CellViewModel? {
  1.1415 -        guard let sections = vm?.sections else {
  1.1416 -            XCTFail()
  1.1417 -            return nil
  1.1418 -        }
  1.1419 -        for section in sections {
  1.1420 -            guard let vm = section.rows.first else {
  1.1421 -                continue
  1.1422 -            }
  1.1423 -            if type(of: vm) == vmType {
  1.1424 -                return  section.rows.first
  1.1425 -            }
  1.1426 -        }
  1.1427 -        return nil
  1.1428 -    }
  1.1429 -
  1.1430 -    private func draftMessage(bccSet: Bool = false, attachmentsSet: Bool = false) -> Message {
  1.1431 -        return message(inFolderOfType: .drafts, bccSet: bccSet, attachmentsSet: attachmentsSet)
  1.1432 -    }
  1.1433 -
  1.1434 -    private func message(inFolderOfType parentType: FolderType = .inbox,
  1.1435 -                         bccSet: Bool = false,
  1.1436 -                         attachmentsSet: Bool = false) -> Message {
  1.1437 -        let folder = Folder(name: "\(parentType)",
  1.1438 -            parent: parentType == .inbox ? nil : account.firstFolder(ofType: .inbox),
  1.1439 -            account: account,
  1.1440 -            folderType: parentType)
  1.1441 -        folder.save()
  1.1442 -        let createe = Message(uuid: UUID().uuidString, parentFolder: folder)
  1.1443 -        if bccSet {
  1.1444 -            createe.replaceBcc(with: [account.user])
  1.1445 -        }
  1.1446 -        if attachmentsSet {
  1.1447 -            let att = attachment()
  1.1448 -            createe.replaceAttachments(with: [att])
  1.1449 -        }
  1.1450 -        createe.save()
  1.1451 -        return createe
  1.1452 -    }
  1.1453 -
  1.1454 -    private func attachment(
  1.1455 -        ofType type: Attachment.ContentDispositionType = .attachment ) -> Attachment {
  1.1456 -        let imageFileName = "PorpoiseGalaxy_HubbleFraile_960.jpg"
  1.1457 -        guard
  1.1458 -            let imageData = TestUtil.loadData(fileName: imageFileName),
  1.1459 -            let image = UIImage(data: imageData) else {
  1.1460 -            XCTFail()
  1.1461 -            return Attachment(data: nil, mimeType: "meh", contentDisposition: .attachment)
  1.1462 -        }
  1.1463 -        let createe: Attachment
  1.1464 -        if type == .inline {
  1.1465 -            createe = Attachment(data: image.jpegData(compressionQuality: 1.0), mimeType: "image/jpg", contentDisposition: type)
  1.1466 -            createe.image = image
  1.1467 -        } else {
  1.1468 -            createe = Attachment(data: imageData,
  1.1469 -                                 mimeType: "video/quicktime",
  1.1470 -                                 contentDisposition: type)
  1.1471 -        }
  1.1472 -        createe.fileName = UUID().uuidString
  1.1473 -        return createe
  1.1474 -    }
  1.1475 -
  1.1476 -    private func assertSections(forVMIniitaliizedWith originalMessage: Message,
  1.1477 -                                expectBccWrapperSectionExists: Bool = true,
  1.1478 -                                expectAccountSectionExists: Bool = false,
  1.1479 -                                expectAttachmentSectionExists: Bool = false) {
  1.1480 -        let vm = ComposeViewModel(resultDelegate: nil,
  1.1481 -                                  composeMode: .normal,
  1.1482 -                                  prefilledTo: nil,
  1.1483 -                                  originalMessage: originalMessage)
  1.1484 -        let testee = vm.sections
  1.1485 -        let recipientSection = 1
  1.1486 -        let bccWrapperSection = expectBccWrapperSectionExists ? 1 : 0
  1.1487 -        let accountSelectorSection = expectAccountSectionExists ? 1 : 0
  1.1488 -        let subjectSection = 1
  1.1489 -        let bodySection = 1
  1.1490 -        let attachmentSection = expectAttachmentSectionExists ? 1 : 0
  1.1491 -        XCTAssertEqual(testee.count,  recipientSection +
  1.1492 -            bccWrapperSection +
  1.1493 -            accountSelectorSection +
  1.1494 -            subjectSection +
  1.1495 -            bodySection +
  1.1496 -            attachmentSection)
  1.1497 -    }
  1.1498 -
  1.1499 -    private func assert(composeMode: ComposeUtil.ComposeMode? = nil,
  1.1500 -                        prefilledTo: Identity? = nil,
  1.1501 -                        originalMessage: Message? = nil,
  1.1502 -                        contentChangedMustBeCalled: Bool? = nil,/*TestDelegate realted params*/
  1.1503 -                        expectedContentChangedIndexPath: IndexPath? = nil,
  1.1504 -                        focusSwitchedMustBeCalled: Bool? = nil,
  1.1505 -                        validatedStateChangedMustBeCalled: Bool? = nil,
  1.1506 -                        expectedIsValidated: Bool? = nil,
  1.1507 -                        modelChangedMustBeCalled: Bool? = nil,
  1.1508 -                        sectionChangedMustBeCalled: Bool? = nil,
  1.1509 -                        expectedSection: Int? = nil,
  1.1510 -                        colorBatchNeedsUpdateMustBeCalled: Bool? = nil,
  1.1511 -                        expectedRating: PEPRating? = nil,
  1.1512 -                        expectedProtectionEnabled: Bool? = nil,
  1.1513 -                        hideSuggestionsMustBeCalled: Bool? = nil,
  1.1514 -                        showSuggestionsMustBeCalled: Bool? = nil,
  1.1515 -                        expectedShowSuggestionsIndexPath: IndexPath? = nil,
  1.1516 -                        suggestionsScrollFocusChangedMustBeCalled: Bool? = nil,
  1.1517 -                        expectedNewSuggestionsScrollFocusIsVisible: Bool? = nil,
  1.1518 -                        showMediaAttachmentPickerMustBeCalled: Bool? = nil,
  1.1519 -                        hideMediaAttachmentPickerMustBeCalled: Bool? = nil,
  1.1520 -                        showDocumentAttachmentPickerMustBeCalled: Bool? = nil,
  1.1521 -                        documentAttachmentPickerDonePickerCalled: Bool? = nil,
  1.1522 -                        didComposeNewMailMustBeCalled: Bool? = nil,/*TestResultDelegate realted params*/
  1.1523 -                        didModifyMessageMustBeCalled: Bool? = nil,
  1.1524 -                        didDeleteMessageMustBeCalled: Bool? = nil) {
  1.1525 -        // TestDelegate
  1.1526 -        var expContentChangedCalled: XCTestExpectation? = nil
  1.1527 -        if let exp = contentChangedMustBeCalled {
  1.1528 -            expContentChangedCalled =
  1.1529 -                expectation(description: "expContentChangedCalled")
  1.1530 -            expContentChangedCalled?.isInverted = !exp
  1.1531 -        }
  1.1532 -
  1.1533 -        var expFocusSwitchedCalled: XCTestExpectation? = nil
  1.1534 -        if let exp = focusSwitchedMustBeCalled {
  1.1535 -            expFocusSwitchedCalled =
  1.1536 -                expectation(description: "expFocusSwitchedCalled")
  1.1537 -            expFocusSwitchedCalled?.isInverted = !exp
  1.1538 -        }
  1.1539 -
  1.1540 -        var expValidatedStateChangedCalled: XCTestExpectation? = nil
  1.1541 -        if let exp = validatedStateChangedMustBeCalled {
  1.1542 -            expValidatedStateChangedCalled =
  1.1543 -                expectation(description: "expValidatedStateChangedCalled")
  1.1544 -            expValidatedStateChangedCalled?.isInverted = !exp
  1.1545 -        }
  1.1546 -
  1.1547 -        var expModelChangedCalled: XCTestExpectation? = nil
  1.1548 -        if let exp = modelChangedMustBeCalled {
  1.1549 -            expModelChangedCalled =
  1.1550 -                expectation(description: "expModelChangedCalled")
  1.1551 -            expModelChangedCalled?.isInverted = !exp
  1.1552 -        }
  1.1553 -
  1.1554 -        var expSectionChangedCalled: XCTestExpectation? = nil
  1.1555 -        if let exp = sectionChangedMustBeCalled {
  1.1556 -            expSectionChangedCalled =
  1.1557 -                expectation(description: "expSectionChangedCalled")
  1.1558 -            expSectionChangedCalled?.isInverted = !exp
  1.1559 -            // Overfulfill is espected. When unwrapping CcBcc fields, wrapper section AND
  1.1560 -            // recipinets section changes.
  1.1561 -            expSectionChangedCalled?.assertForOverFulfill = false
  1.1562 -        }
  1.1563 -
  1.1564 -        var expColorBatchNeedsUpdateCalled: XCTestExpectation? = nil
  1.1565 -        if let exp = colorBatchNeedsUpdateMustBeCalled {
  1.1566 -            expColorBatchNeedsUpdateCalled =
  1.1567 -                expectation(description: "expColorBatchNeedsUpdateCalled")
  1.1568 -            expColorBatchNeedsUpdateCalled?.isInverted = !exp
  1.1569 -        }
  1.1570 -
  1.1571 -        var expHideSuggestionsCalled: XCTestExpectation? = nil
  1.1572 -        if let exp = hideSuggestionsMustBeCalled {
  1.1573 -            expHideSuggestionsCalled =
  1.1574 -                expectation(description: "expHideSuggestionsCalled")
  1.1575 -            expHideSuggestionsCalled?.isInverted = !exp
  1.1576 -        }
  1.1577 -
  1.1578 -        var expSuggestionsScrollFocusChangedCalled: XCTestExpectation? = nil
  1.1579 -        if let exp = suggestionsScrollFocusChangedMustBeCalled {
  1.1580 -            expSuggestionsScrollFocusChangedCalled =
  1.1581 -                expectation(description: "expSuggestionsScrollFocusChangedCalled")
  1.1582 -            expSuggestionsScrollFocusChangedCalled?.isInverted = !exp
  1.1583 -        }
  1.1584 -
  1.1585 -        var expShowSuggestionsCalled: XCTestExpectation? = nil
  1.1586 -        if let exp = showSuggestionsMustBeCalled {
  1.1587 -            expShowSuggestionsCalled =
  1.1588 -                expectation(description: "expShowSuggestionsCalled")
  1.1589 -            expShowSuggestionsCalled?.isInverted = !exp
  1.1590 -        }
  1.1591 -
  1.1592 -        var expShowMediaAttachmentPickerCalled: XCTestExpectation? = nil
  1.1593 -        if let exp = showMediaAttachmentPickerMustBeCalled {
  1.1594 -            expShowMediaAttachmentPickerCalled =
  1.1595 -                expectation(description: "expShowMediaAttachmentPickerCalled")
  1.1596 -            expShowMediaAttachmentPickerCalled?.isInverted = !exp
  1.1597 -        }
  1.1598 -
  1.1599 -        var expHideMediaAttachmentPickerCalled: XCTestExpectation? = nil
  1.1600 -        if let exp = hideMediaAttachmentPickerMustBeCalled {
  1.1601 -            expHideMediaAttachmentPickerCalled =
  1.1602 -                expectation(description: "expHideMediaAttachmentPickerCalled")
  1.1603 -            expHideMediaAttachmentPickerCalled?.isInverted = !exp
  1.1604 -        }
  1.1605 -
  1.1606 -        var expShowDocumentAttachmentPickerCalled: XCTestExpectation? = nil
  1.1607 -        if let exp = showDocumentAttachmentPickerMustBeCalled {
  1.1608 -            expShowDocumentAttachmentPickerCalled =
  1.1609 -                expectation(description: "expShowDocumentAttachmentPickerCalled")
  1.1610 -            expShowDocumentAttachmentPickerCalled?.isInverted = !exp
  1.1611 -        }
  1.1612 -
  1.1613 -        var expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation? = nil
  1.1614 -        if let exp = documentAttachmentPickerDonePickerCalled {
  1.1615 -            expDocumentAttachmentPickerDonePickerCalled =
  1.1616 -                expectation(description: "expDocumentAttachmentPickerDonePickerCalled")
  1.1617 -            expDocumentAttachmentPickerDonePickerCalled?.isInverted = !exp
  1.1618 -        }
  1.1619 -
  1.1620 -        testDelegate =
  1.1621 -            TestDelegate(expContentChangedCalled: expContentChangedCalled,
  1.1622 -                         expectedContentChangedIndexPath: expectedContentChangedIndexPath,
  1.1623 -                         expFocusSwitchedCalled: expFocusSwitchedCalled,
  1.1624 -                         expValidatedStateChangedCalled: expValidatedStateChangedCalled,
  1.1625 -                         expectedIsValidated: expectedIsValidated,
  1.1626 -                         expModelChangedCalled: expModelChangedCalled,
  1.1627 -                         expSectionChangedCalled: expSectionChangedCalled,
  1.1628 -                         expectedSection: expectedSection,
  1.1629 -                         expColorBatchNeedsUpdateCalled: nil,
  1.1630 -                         expectedRating: expectedRating,
  1.1631 -                         expectedProtectionEnabled: expectedProtectionEnabled,
  1.1632 -                         expHideSuggestionsCalled: expHideSuggestionsCalled,
  1.1633 -                         expShowSuggestionsCalled: expShowSuggestionsCalled,
  1.1634 -                         expSuggestionsScrollFocusChangedCalled: expSuggestionsScrollFocusChangedCalled,
  1.1635 -                         expectedScrollFocus: expectedNewSuggestionsScrollFocusIsVisible,
  1.1636 -                         expectedShowSuggestionsIndexPath: expectedShowSuggestionsIndexPath,
  1.1637 -                         expShowMediaAttachmentPickerCalled: expShowMediaAttachmentPickerCalled,
  1.1638 -                         expHideMediaAttachmentPickerCalled: expHideMediaAttachmentPickerCalled,
  1.1639 -                         expShowDocumentAttachmentPickerCalled: expShowDocumentAttachmentPickerCalled,
  1.1640 -                         expDocumentAttachmentPickerDonePickerCalled:
  1.1641 -                expDocumentAttachmentPickerDonePickerCalled)
  1.1642 -
  1.1643 -        // TestResultDelegate
  1.1644 -
  1.1645 -        var expDidComposeNewMailCalled: XCTestExpectation? = nil
  1.1646 -        if let exp = didComposeNewMailMustBeCalled {
  1.1647 -            expDidComposeNewMailCalled =
  1.1648 -                expectation(description: "expDidComposeNewMailCalled")
  1.1649 -            expDidComposeNewMailCalled?.isInverted = !exp
  1.1650 -        }
  1.1651 -
  1.1652 -        var expDidModifyMessageCalled: XCTestExpectation? = nil
  1.1653 -        if let exp = didModifyMessageMustBeCalled {
  1.1654 -            expDidModifyMessageCalled =
  1.1655 -                expectation(description: "expDidModifyMessageCalled")
  1.1656 -            expDidModifyMessageCalled?.isInverted = !exp
  1.1657 -        }
  1.1658 -
  1.1659 -        var expDidDeleteMessageCalled: XCTestExpectation? = nil
  1.1660 -        if let exp = didDeleteMessageMustBeCalled {
  1.1661 -            expDidDeleteMessageCalled =
  1.1662 -                expectation(description: "expDidDeleteMessageCalled")
  1.1663 -            expDidDeleteMessageCalled?.isInverted = !exp
  1.1664 -            expDidDeleteMessageCalled?.assertForOverFulfill = false
  1.1665 -        }
  1.1666 -
  1.1667 -        testResultDelegate =
  1.1668 -            TestResultDelegate(expDidComposeNewMailCalled: expDidComposeNewMailCalled,
  1.1669 -                               expDidModifyMessageCalled: expDidModifyMessageCalled,
  1.1670 -                               expDidDeleteMessageCalled: expDidDeleteMessageCalled)
  1.1671 -        vm = ComposeViewModel(resultDelegate: testResultDelegate,
  1.1672 -                              composeMode: composeMode,
  1.1673 -                              prefilledTo: prefilledTo,
  1.1674 -                              originalMessage: originalMessage)
  1.1675 -        vm?.delegate = testDelegate
  1.1676 -        // Set _after_ the delegate is set because at this point we are not interested in callbacks
  1.1677 -        // triggered by setting the delegate.
  1.1678 -        testDelegate?.expColorBatchNeedsUpdateCalled = expColorBatchNeedsUpdateCalled
  1.1679 -    }
  1.1680 -
  1.1681 -    private class TestResultDelegate: ComposeViewModelResultDelegate {
  1.1682 -        let expDidComposeNewMailCalled: XCTestExpectation?
  1.1683 -        let expDidModifyMessageCalled: XCTestExpectation?
  1.1684 -        let expDidDeleteMessageCalled: XCTestExpectation?
  1.1685 -
  1.1686 -        init(expDidComposeNewMailCalled: XCTestExpectation? = nil,
  1.1687 -             expDidModifyMessageCalled: XCTestExpectation? = nil,
  1.1688 -             expDidDeleteMessageCalled: XCTestExpectation? = nil) {
  1.1689 -            self.expDidComposeNewMailCalled = expDidComposeNewMailCalled
  1.1690 -            self.expDidModifyMessageCalled = expDidModifyMessageCalled
  1.1691 -            self.expDidDeleteMessageCalled = expDidDeleteMessageCalled
  1.1692 -
  1.1693 -        }
  1.1694 -
  1.1695 -        func composeViewModelDidComposeNewMail(message: Message) {
  1.1696 -            guard let exp = expDidComposeNewMailCalled else {
  1.1697 -                // We ignore called or not
  1.1698 -                return
  1.1699 -            }
  1.1700 -            exp.fulfill()
  1.1701 -        }
  1.1702 -
  1.1703 -        func composeViewModelDidModifyMessage(message: Message) {
  1.1704 -            guard let exp = expDidModifyMessageCalled else {
  1.1705 -                // We ignore called or not
  1.1706 -                return
  1.1707 -            }
  1.1708 -            exp.fulfill()
  1.1709 -        }
  1.1710 -
  1.1711 -        func composeViewModelDidDeleteMessage(message: Message) {
  1.1712 -            guard let exp = expDidDeleteMessageCalled else {
  1.1713 -                // We ignore called or not
  1.1714 -                return
  1.1715 -            }
  1.1716 -            exp.fulfill()
  1.1717 -        }
  1.1718 -    }
  1.1719 -
  1.1720 -    private class TestDelegate:  ComposeViewModelDelegate {
  1.1721 -        let expContentChangedCalled: XCTestExpectation?
  1.1722 -        let expectedContentChangedIndexPath: IndexPath?
  1.1723 -
  1.1724 -        let expFocusSwitchedCalled: XCTestExpectation?
  1.1725 -
  1.1726 -        let expValidatedStateChangedCalled: XCTestExpectation?
  1.1727 -        let expectedIsValidated: Bool?
  1.1728 -
  1.1729 -        let expModelChangedCalled: XCTestExpectation?
  1.1730 -
  1.1731 -        let expSectionChangedCalled: XCTestExpectation?
  1.1732 -        let expectedSection: Int?
  1.1733 -
  1.1734 -        var expColorBatchNeedsUpdateCalled: XCTestExpectation?
  1.1735 -        let expectedRating: PEPRating?
  1.1736 -        let expectedProtectionEnabled: Bool?
  1.1737 -
  1.1738 -        let expHideSuggestionsCalled: XCTestExpectation?
  1.1739 -
  1.1740 -        let expShowSuggestionsCalled: XCTestExpectation?
  1.1741 -        let expectedShowSuggestionsIndexPath: IndexPath?
  1.1742 -
  1.1743 -        let expSuggestionsScrollFocusChangedCalled: XCTestExpectation?
  1.1744 -        let expectedScrollFocus: Bool?
  1.1745 -
  1.1746 -        let expShowMediaAttachmentPickerCalled: XCTestExpectation?
  1.1747 -
  1.1748 -        let expHideMediaAttachmentPickerCalled: XCTestExpectation?
  1.1749 -
  1.1750 -        let expShowDocumentAttachmentPickerCalled: XCTestExpectation?
  1.1751 -
  1.1752 -        let expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation?
  1.1753 -
  1.1754 -        init(expContentChangedCalled: XCTestExpectation?,
  1.1755 -             expectedContentChangedIndexPath: IndexPath?,
  1.1756 -             expFocusSwitchedCalled: XCTestExpectation?,
  1.1757 -             expValidatedStateChangedCalled: XCTestExpectation?,
  1.1758 -             expectedIsValidated: Bool?,
  1.1759 -             expModelChangedCalled: XCTestExpectation?,
  1.1760 -             expSectionChangedCalled: XCTestExpectation?,
  1.1761 -             expectedSection: Int?,
  1.1762 -             expColorBatchNeedsUpdateCalled: XCTestExpectation?,
  1.1763 -             expectedRating: PEPRating?,
  1.1764 -             expectedProtectionEnabled: Bool?,
  1.1765 -             expHideSuggestionsCalled: XCTestExpectation?,
  1.1766 -             expShowSuggestionsCalled: XCTestExpectation?,
  1.1767 -             expSuggestionsScrollFocusChangedCalled: XCTestExpectation?,
  1.1768 -             expectedScrollFocus: Bool?,
  1.1769 -             expectedShowSuggestionsIndexPath: IndexPath?,
  1.1770 -             expShowMediaAttachmentPickerCalled: XCTestExpectation?,
  1.1771 -             expHideMediaAttachmentPickerCalled: XCTestExpectation?,
  1.1772 -             expShowDocumentAttachmentPickerCalled: XCTestExpectation?,
  1.1773 -             expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation?) {
  1.1774 -            self.expContentChangedCalled = expContentChangedCalled
  1.1775 -            self.expectedContentChangedIndexPath = expectedContentChangedIndexPath
  1.1776 -            self.expFocusSwitchedCalled = expFocusSwitchedCalled
  1.1777 -            self.expValidatedStateChangedCalled = expValidatedStateChangedCalled
  1.1778 -            self.expectedIsValidated = expectedIsValidated
  1.1779 -            self.expModelChangedCalled = expModelChangedCalled
  1.1780 -            self.expSectionChangedCalled = expSectionChangedCalled
  1.1781 -            self.expectedSection = expectedSection
  1.1782 -            self.expColorBatchNeedsUpdateCalled =  expColorBatchNeedsUpdateCalled
  1.1783 -            self.expectedRating = expectedRating
  1.1784 -            self.expectedProtectionEnabled = expectedProtectionEnabled
  1.1785 -            self.expHideSuggestionsCalled = expHideSuggestionsCalled
  1.1786 -            self.expShowSuggestionsCalled = expShowSuggestionsCalled
  1.1787 -            self.expSuggestionsScrollFocusChangedCalled = expSuggestionsScrollFocusChangedCalled
  1.1788 -            self.expectedScrollFocus = expectedScrollFocus
  1.1789 -            self.expectedShowSuggestionsIndexPath = expectedShowSuggestionsIndexPath
  1.1790 -            self.expShowMediaAttachmentPickerCalled = expShowMediaAttachmentPickerCalled
  1.1791 -            self.expHideMediaAttachmentPickerCalled = expHideMediaAttachmentPickerCalled
  1.1792 -            self.expShowDocumentAttachmentPickerCalled = expShowDocumentAttachmentPickerCalled
  1.1793 -            self.expDocumentAttachmentPickerDonePickerCalled =
  1.1794 -            expDocumentAttachmentPickerDonePickerCalled
  1.1795 -        }
  1.1796 -
  1.1797 -        func contentChanged(inRowAt indexPath: IndexPath) {
  1.1798 -            guard let exp = expContentChangedCalled else {
  1.1799 -                // We ignore called or not
  1.1800 -                return
  1.1801 -            }
  1.1802 -            exp.fulfill()
  1.1803 -            if let expected = expectedContentChangedIndexPath {
  1.1804 -                XCTAssertEqual(indexPath, expected)
  1.1805 -            }
  1.1806 -        }
  1.1807 -
  1.1808 -        func focusSwitched() {
  1.1809 -            guard let exp = expFocusSwitchedCalled else {
  1.1810 -                // We ignore called or not
  1.1811 -                return
  1.1812 -            }
  1.1813 -            exp.fulfill()
  1.1814 -        }
  1.1815 -
  1.1816 -        func validatedStateChanged(to isValidated: Bool) {
  1.1817 -            guard let exp = expValidatedStateChangedCalled else {
  1.1818 -                // We ignore called or not
  1.1819 -                return
  1.1820 -            }
  1.1821 -            exp.fulfill()
  1.1822 -            if let expected = expectedIsValidated {
  1.1823 -                XCTAssertEqual(isValidated, expected)
  1.1824 -            }
  1.1825 -        }
  1.1826 -
  1.1827 -        func modelChanged() {
  1.1828 -            guard let exp = expModelChangedCalled else {
  1.1829 -                // We ignore called or not
  1.1830 -                return
  1.1831 -            }
  1.1832 -            exp.fulfill()
  1.1833 -        }
  1.1834 -
  1.1835 -        func sectionChanged(section: Int) {
  1.1836 -            guard let exp = expSectionChangedCalled else {
  1.1837 -                // We ignore called or not
  1.1838 -                return
  1.1839 -            }
  1.1840 -            exp.fulfill()
  1.1841 -            if let expected = expectedSection {
  1.1842 -                XCTAssertEqual(section, expected)
  1.1843 -            }
  1.1844 -        }
  1.1845 -
  1.1846 -        func colorBatchNeedsUpdate(for rating: PEPRating, protectionEnabled: Bool) {
  1.1847 -            guard let exp = expColorBatchNeedsUpdateCalled else {
  1.1848 -                // We ignore called or not
  1.1849 -                return
  1.1850 -            }
  1.1851 -            exp.fulfill()
  1.1852 -            if let expected = expectedRating {
  1.1853 -                XCTAssertEqual(rating, expected)
  1.1854 -            }
  1.1855 -            if let expectedProtection = expectedProtectionEnabled {
  1.1856 -                XCTAssertEqual(protectionEnabled, expectedProtection)
  1.1857 -            }
  1.1858 -        }
  1.1859 -
  1.1860 -        func hideSuggestions() {
  1.1861 -            guard let exp = expHideSuggestionsCalled else {
  1.1862 -                // We ignore called or not
  1.1863 -                return
  1.1864 -            }
  1.1865 -            exp.fulfill()
  1.1866 -        }
  1.1867 -
  1.1868 -        func showSuggestions(forRowAt indexPath: IndexPath) {
  1.1869 -            guard let exp = expShowSuggestionsCalled else {
  1.1870 -                // We ignore called or not
  1.1871 -                return
  1.1872 -            }
  1.1873 -            exp.fulfill()
  1.1874 -            if let expected = expectedShowSuggestionsIndexPath {
  1.1875 -                XCTAssertEqual(indexPath, expected)
  1.1876 -            }
  1.1877 -        }
  1.1878 -
  1.1879 -        func suggestions(haveScrollFocus: Bool) {
  1.1880 -            guard let exp = expSuggestionsScrollFocusChangedCalled else {
  1.1881 -                // We ignore called or not
  1.1882 -                return
  1.1883 -            }
  1.1884 -            exp.fulfill()
  1.1885 -            if let expected = expectedScrollFocus {
  1.1886 -                XCTAssertEqual(haveScrollFocus, expected)
  1.1887 -            }
  1.1888 -        }
  1.1889 -
  1.1890 -        func showMediaAttachmentPicker() {
  1.1891 -            guard let exp = expShowMediaAttachmentPickerCalled else {
  1.1892 -                // We ignore called or not
  1.1893 -                return
  1.1894 -            }
  1.1895 -            exp.fulfill()
  1.1896 -        }
  1.1897 -
  1.1898 -        func hideMediaAttachmentPicker() {
  1.1899 -            guard let exp = expHideMediaAttachmentPickerCalled else {
  1.1900 -                // We ignore called or not
  1.1901 -                return
  1.1902 -            }
  1.1903 -            exp.fulfill()
  1.1904 -        }
  1.1905 -
  1.1906 -        func showDocumentAttachmentPicker() {
  1.1907 -            guard let exp = expShowDocumentAttachmentPickerCalled else {
  1.1908 -                // We ignore called or not
  1.1909 -                return
  1.1910 -            }
  1.1911 -            exp.fulfill()
  1.1912 -        }
  1.1913 -
  1.1914 -        func documentAttachmentPickerDone() {
  1.1915 -            guard let exp = expDocumentAttachmentPickerDonePickerCalled else {
  1.1916 -                // We ignore called or not
  1.1917 -                return
  1.1918 -            }
  1.1919 -            exp.fulfill()
  1.1920 -        }
  1.1921 -    }
  1.1922 -
  1.1923 -    // MARK: - DocumentAttachmentPickerViewModel
  1.1924 -    class TestDocumentAttachmentPickerViewModel: DocumentAttachmentPickerViewModel {} // Dummy to pass something
  1.1925 -
  1.1926 -    // MARK: - MediaAttachmentPickerProviderViewModel
  1.1927 -    class TestMediaAttachmentPickerProviderViewModel: MediaAttachmentPickerProviderViewModel {} // Dummy to pass something
  1.1928 -}
  1.1929 +//class ComposeViewModelTest: CoreDataDrivenTestBase {
  1.1930 +//    private var testDelegate: TestDelegate?
  1.1931 +//    private var testResultDelegate: TestResultDelegate?
  1.1932 +//    var vm: ComposeViewModel?
  1.1933 +//    var outbox: Folder? {
  1.1934 +//        return account.firstFolder(ofType: .outbox)
  1.1935 +//    }
  1.1936 +//    var drafts: Folder? {
  1.1937 +//        return account.firstFolder(ofType: .drafts)
  1.1938 +//    }
  1.1939 +//    var sent: Folder? {
  1.1940 +//        return account.firstFolder(ofType: .sent)
  1.1941 +//    }
  1.1942 +//
  1.1943 +//    override func setUp() {
  1.1944 +//        super.setUp()
  1.1945 +//        vm = ComposeViewModel(resultDelegate: nil,
  1.1946 +//                              composeMode: nil,
  1.1947 +//                              prefilledTo: nil,
  1.1948 +//                              originalMessage: nil)
  1.1949 +//        assureOutboxExists()
  1.1950 +//        assureDraftsExists()
  1.1951 +//        assureSentExists()
  1.1952 +//    }
  1.1953 +//
  1.1954 +//    // MARK: - Test the Test Helper
  1.1955 +//
  1.1956 +//    func testAssertHelperTest_doNothing_noCallback() {
  1.1957 +//        assert(contentChangedMustBeCalled: false,
  1.1958 +//               focusSwitchedMustBeCalled: false,
  1.1959 +//               validatedStateChangedMustBeCalled: false,
  1.1960 +//               modelChangedMustBeCalled: false,
  1.1961 +//               sectionChangedMustBeCalled: false,
  1.1962 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.1963 +//               hideSuggestionsMustBeCalled: false,
  1.1964 +//               showSuggestionsMustBeCalled: false,
  1.1965 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.1966 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.1967 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.1968 +//               documentAttachmentPickerDonePickerCalled: false,
  1.1969 +//               didComposeNewMailMustBeCalled: false,
  1.1970 +//               didModifyMessageMustBeCalled: false,
  1.1971 +//               didDeleteMessageMustBeCalled: false)
  1.1972 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.1973 +//    }
  1.1974 +//
  1.1975 +//    // MARK: - init
  1.1976 +//
  1.1977 +//    func testInit_resultDelegateSet() {
  1.1978 +//        let resultDelegate = TestResultDelegate()
  1.1979 +//        let vm = ComposeViewModel(resultDelegate: resultDelegate,
  1.1980 +//                                  composeMode: nil,
  1.1981 +//                                  prefilledTo: nil,
  1.1982 +//                                  originalMessage: nil)
  1.1983 +//        guard let testee = vm.resultDelegate else {
  1.1984 +//            XCTFail()
  1.1985 +//            return
  1.1986 +//        }
  1.1987 +//        XCTAssertTrue(testee === resultDelegate)
  1.1988 +//    }
  1.1989 +//
  1.1990 +//    func testInit_stateSetupCorrectly() {
  1.1991 +//        let mode = ComposeUtil.ComposeMode.replyAll
  1.1992 +//        let vm = ComposeViewModel(resultDelegate: nil,
  1.1993 +//                                  composeMode: mode,
  1.1994 +//                                  prefilledTo: nil,
  1.1995 +//                                  originalMessage: nil)
  1.1996 +//        guard
  1.1997 +//            let testee = vm.state.initData,
  1.1998 +//            let testeeMode = vm.state.initData?.composeMode,
  1.1999 +//            let stateDelegate = vm.state.delegate else {
  1.2000 +//            XCTFail()
  1.2001 +//            return
  1.2002 +//        }
  1.2003 +//        XCTAssertNotNil(testee)
  1.2004 +//        XCTAssertEqual(testeeMode, mode)
  1.2005 +//        XCTAssertTrue(vm === stateDelegate)
  1.2006 +//    }
  1.2007 +//
  1.2008 +//    // MARK: - Sections
  1.2009 +//
  1.2010 +//    func testSections_setupCorrectly() {
  1.2011 +//        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: false)
  1.2012 +//        assertSections(forVMIniitaliizedWith: testOriginalMessage,
  1.2013 +//                       expectBccWrapperSectionExists: true,
  1.2014 +//                       expectAccountSectionExists: false,
  1.2015 +//                       expectAttachmentSectionExists: false)
  1.2016 +//    }
  1.2017 +//
  1.2018 +//    func testSections_unwrappedbcc() {
  1.2019 +//        let testOriginalMessage = draftMessage(bccSet: true, attachmentsSet: false)
  1.2020 +//        assertSections(forVMIniitaliizedWith: testOriginalMessage,
  1.2021 +//                       expectBccWrapperSectionExists: false,
  1.2022 +//                       expectAccountSectionExists: false,
  1.2023 +//                       expectAttachmentSectionExists: false)
  1.2024 +//    }
  1.2025 +//
  1.2026 +//    func testSections_accountSelector() {
  1.2027 +//        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: false)
  1.2028 +//        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
  1.2029 +//        secondAccount.save()
  1.2030 +//        assertSections(forVMIniitaliizedWith: testOriginalMessage,
  1.2031 +//                       expectBccWrapperSectionExists: true,
  1.2032 +//                       expectAccountSectionExists: true,
  1.2033 +//                       expectAttachmentSectionExists: false)
  1.2034 +//    }
  1.2035 +//
  1.2036 +//    func testSections_attachments() {
  1.2037 +//        let testOriginalMessage = draftMessage(bccSet: false, attachmentsSet: true)
  1.2038 +//        assertSections(forVMIniitaliizedWith: testOriginalMessage,
  1.2039 +//                       expectBccWrapperSectionExists: true,
  1.2040 +//                       expectAccountSectionExists: false,
  1.2041 +//                       expectAttachmentSectionExists: true)
  1.2042 +//    }
  1.2043 +//
  1.2044 +//    // MARK: - DocumentAttachmentPickerResultDelegate Handling
  1.2045 +//
  1.2046 +//    func testDocumentAttachmentPickerViewModel() {
  1.2047 +//        let testee = vm?.documentAttachmentPickerViewModel()
  1.2048 +//        XCTAssertNotNil(testee)
  1.2049 +//    }
  1.2050 +//
  1.2051 +//    func testDidPickDocumentAttachment() {
  1.2052 +//        let attachmentSectionSection = 4
  1.2053 +//        assert(contentChangedMustBeCalled: false,
  1.2054 +//               focusSwitchedMustBeCalled: false,
  1.2055 +//               validatedStateChangedMustBeCalled: false,
  1.2056 +//               modelChangedMustBeCalled: false,
  1.2057 +//               sectionChangedMustBeCalled: true,
  1.2058 +//               expectedSection: attachmentSectionSection,
  1.2059 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2060 +//               hideSuggestionsMustBeCalled: false,
  1.2061 +//               showSuggestionsMustBeCalled: false,
  1.2062 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2063 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2064 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2065 +//               documentAttachmentPickerDonePickerCalled: true,
  1.2066 +//               didComposeNewMailMustBeCalled: false,
  1.2067 +//               didModifyMessageMustBeCalled: false,
  1.2068 +//               didDeleteMessageMustBeCalled: false)
  1.2069 +//        let countBefore = vm?.state.nonInlinedAttachments.count ?? -1
  1.2070 +//        let att = attachment()
  1.2071 +//        vm?.documentAttachmentPickerViewModel(TestDocumentAttachmentPickerViewModel(), didPick: att)
  1.2072 +//        let countAfter = vm?.state.nonInlinedAttachments.count ?? -1
  1.2073 +//        XCTAssertEqual(countAfter, countBefore + 1)
  1.2074 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2075 +//    }
  1.2076 +//
  1.2077 +//    func testDocumentAttachmentPickerDone() {
  1.2078 +//        assert(contentChangedMustBeCalled: false,
  1.2079 +//               focusSwitchedMustBeCalled: false,
  1.2080 +//               validatedStateChangedMustBeCalled: false,
  1.2081 +//               modelChangedMustBeCalled: false,
  1.2082 +//               sectionChangedMustBeCalled: false,
  1.2083 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2084 +//               hideSuggestionsMustBeCalled: false,
  1.2085 +//               showSuggestionsMustBeCalled: false,
  1.2086 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2087 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2088 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2089 +//               documentAttachmentPickerDonePickerCalled: true,
  1.2090 +//               didComposeNewMailMustBeCalled: false,
  1.2091 +//               didModifyMessageMustBeCalled: false,
  1.2092 +//               didDeleteMessageMustBeCalled: false)
  1.2093 +//        vm?.documentAttachmentPickerViewModelDidCancel(TestDocumentAttachmentPickerViewModel())
  1.2094 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2095 +//    }
  1.2096 +//
  1.2097 +//    // MARK: - MediaAttachmentPickerProviderViewModelResultDelegate Handling
  1.2098 +//
  1.2099 +//    func testMediaAttachmentPickerProviderViewModelFactory() {
  1.2100 +//        let testee = vm?.mediaAttachmentPickerProviderViewModel()
  1.2101 +//        XCTAssertNotNil(testee)
  1.2102 +//    }
  1.2103 +//
  1.2104 +//    func testDidSelectMediaAttachment_image() {
  1.2105 +//        let msg = draftMessage()
  1.2106 +//        let imageAttachment = attachment(ofType: .inline)
  1.2107 +//        msg.replaceAttachments(with: [imageAttachment])
  1.2108 +//        assert(originalMessage: msg,
  1.2109 +//               contentChangedMustBeCalled: false,
  1.2110 +//               focusSwitchedMustBeCalled: false,
  1.2111 +//               validatedStateChangedMustBeCalled: false,
  1.2112 +//               modelChangedMustBeCalled: false,
  1.2113 +//               sectionChangedMustBeCalled: false,
  1.2114 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2115 +//               hideSuggestionsMustBeCalled: false,
  1.2116 +//               showSuggestionsMustBeCalled: false,
  1.2117 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2118 +//               hideMediaAttachmentPickerMustBeCalled: true,
  1.2119 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2120 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2121 +//               didComposeNewMailMustBeCalled: false,
  1.2122 +//               didModifyMessageMustBeCalled: false,
  1.2123 +//               didDeleteMessageMustBeCalled: false)
  1.2124 +//        let mediaAtt =
  1.2125 +//            MediaAttachmentPickerProviderViewModel.MediaAttachment(type: .image,
  1.2126 +//                                                                   attachment: imageAttachment)
  1.2127 +//        let countBefore = vm?.state.inlinedAttachments.count ?? -1
  1.2128 +//        vm?.mediaAttachmentPickerProviderViewModel(
  1.2129 +//            TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil),
  1.2130 +//            didSelect: mediaAtt)
  1.2131 +//        let countAfter = vm?.state.inlinedAttachments.count ?? -1
  1.2132 +//        XCTAssertEqual(countAfter, countBefore + 1)
  1.2133 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2134 +//
  1.2135 +//    }
  1.2136 +//
  1.2137 +//    func testDidSelectMediaAttachment_video() {
  1.2138 +//        let msg = draftMessage()
  1.2139 +//        let imageAttachment = attachment(ofType: .inline)
  1.2140 +//        msg.replaceAttachments(with: [imageAttachment])
  1.2141 +//
  1.2142 +//        let attachmentSectionSection = 4
  1.2143 +//
  1.2144 +//        assert(originalMessage: msg,
  1.2145 +//               contentChangedMustBeCalled: false,
  1.2146 +//               focusSwitchedMustBeCalled: false,
  1.2147 +//               validatedStateChangedMustBeCalled: false,
  1.2148 +//               modelChangedMustBeCalled: false,
  1.2149 +//               sectionChangedMustBeCalled: true,
  1.2150 +//               expectedSection: attachmentSectionSection,
  1.2151 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2152 +//               hideSuggestionsMustBeCalled: false,
  1.2153 +//               showSuggestionsMustBeCalled: false,
  1.2154 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2155 +//               hideMediaAttachmentPickerMustBeCalled: true,
  1.2156 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2157 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2158 +//               didComposeNewMailMustBeCalled: false,
  1.2159 +//               didModifyMessageMustBeCalled: false,
  1.2160 +//               didDeleteMessageMustBeCalled: false)
  1.2161 +//        let mediaAtt =
  1.2162 +//            MediaAttachmentPickerProviderViewModel.MediaAttachment(type: .movie,
  1.2163 +//                                                                   attachment: imageAttachment)
  1.2164 +//        let countBefore = vm?.state.nonInlinedAttachments.count ?? -1
  1.2165 +//        vm?.mediaAttachmentPickerProviderViewModel(
  1.2166 +//            TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil),
  1.2167 +//            didSelect: mediaAtt)
  1.2168 +//        let countAfter = vm?.state.nonInlinedAttachments.count ?? -1
  1.2169 +//        XCTAssertEqual(countAfter, countBefore + 1)
  1.2170 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2171 +//    }
  1.2172 +//
  1.2173 +//    func testMediaPickerDidCancel() {
  1.2174 +//        assert(contentChangedMustBeCalled: false,
  1.2175 +//               focusSwitchedMustBeCalled: false,
  1.2176 +//               validatedStateChangedMustBeCalled: false,
  1.2177 +//               modelChangedMustBeCalled: false,
  1.2178 +//               sectionChangedMustBeCalled: false,
  1.2179 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2180 +//               hideSuggestionsMustBeCalled: false,
  1.2181 +//               showSuggestionsMustBeCalled: false,
  1.2182 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2183 +//               hideMediaAttachmentPickerMustBeCalled: true,
  1.2184 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2185 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2186 +//               didComposeNewMailMustBeCalled: false,
  1.2187 +//               didModifyMessageMustBeCalled: false,
  1.2188 +//               didDeleteMessageMustBeCalled: false)
  1.2189 +//      vm?.mediaAttachmentPickerProviderViewModelDidCancel(
  1.2190 +//        TestMediaAttachmentPickerProviderViewModel(resultDelegate: nil))
  1.2191 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2192 +//    }
  1.2193 +//
  1.2194 +//    // MARK: - BodyCellViewModelResultDelegate handling
  1.2195 +//
  1.2196 +//    private var bodyVm: BodyCellViewModel {
  1.2197 +//        return vm?.bodyVM ?? BodyCellViewModel(resultDelegate: nil)
  1.2198 +//    }
  1.2199 +//
  1.2200 +//    func testBodyVM() {
  1.2201 +//        let testee = vm?.bodyVM
  1.2202 +//        XCTAssertNotNil(testee)
  1.2203 +//    }
  1.2204 +//
  1.2205 +//    func testBodyCellViewModelUserWantsToAddMedia() {
  1.2206 +//        assert(contentChangedMustBeCalled: false,
  1.2207 +//               focusSwitchedMustBeCalled: false,
  1.2208 +//               validatedStateChangedMustBeCalled: false,
  1.2209 +//               modelChangedMustBeCalled: false,
  1.2210 +//               sectionChangedMustBeCalled: false,
  1.2211 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2212 +//               hideSuggestionsMustBeCalled: false,
  1.2213 +//               showSuggestionsMustBeCalled: false,
  1.2214 +//               showMediaAttachmentPickerMustBeCalled: true,
  1.2215 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2216 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2217 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2218 +//               didComposeNewMailMustBeCalled: false,
  1.2219 +//               didModifyMessageMustBeCalled: false,
  1.2220 +//               didDeleteMessageMustBeCalled: false)
  1.2221 +//        vm?.bodyCellViewModelUserWantsToAddMedia(bodyVm)
  1.2222 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2223 +//    }
  1.2224 +//
  1.2225 +//    func testBodyCellViewModelUserWantsToAddDocument() {
  1.2226 +//        assert(contentChangedMustBeCalled: false,
  1.2227 +//               focusSwitchedMustBeCalled: false,
  1.2228 +//               validatedStateChangedMustBeCalled: false,
  1.2229 +//               modelChangedMustBeCalled: false,
  1.2230 +//               sectionChangedMustBeCalled: false,
  1.2231 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2232 +//               hideSuggestionsMustBeCalled: false,
  1.2233 +//               showSuggestionsMustBeCalled: false,
  1.2234 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2235 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2236 +//               showDocumentAttachmentPickerMustBeCalled: true,
  1.2237 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2238 +//               didComposeNewMailMustBeCalled: false,
  1.2239 +//               didModifyMessageMustBeCalled: false,
  1.2240 +//               didDeleteMessageMustBeCalled: false)
  1.2241 +//        vm?.bodyCellViewModelUserWantsToAddDocument(bodyVm)
  1.2242 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2243 +//    }
  1.2244 +//
  1.2245 +//    func testBodyCellViewModelInlinedAttachmentsChanged_moreAttachments() {
  1.2246 +//        assert(contentChangedMustBeCalled: false,
  1.2247 +//               focusSwitchedMustBeCalled: false,
  1.2248 +//               validatedStateChangedMustBeCalled: false,
  1.2249 +//               modelChangedMustBeCalled: false,
  1.2250 +//               sectionChangedMustBeCalled: false,
  1.2251 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2252 +//               hideSuggestionsMustBeCalled: false,
  1.2253 +//               showSuggestionsMustBeCalled: false,
  1.2254 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2255 +//               hideMediaAttachmentPickerMustBeCalled: true,
  1.2256 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2257 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2258 +//               didComposeNewMailMustBeCalled: false,
  1.2259 +//               didModifyMessageMustBeCalled: false,
  1.2260 +//               didDeleteMessageMustBeCalled: false)
  1.2261 +//        let countBefore = vm?.state.inlinedAttachments.count ?? -1
  1.2262 +//        vm?.bodyCellViewModel(bodyVm,
  1.2263 +//                              inlinedAttachmentsChanged: [attachment()])
  1.2264 +//        let countAfter = vm?.state.inlinedAttachments.count ?? -1
  1.2265 +//        XCTAssertEqual(countAfter, countBefore + 1)
  1.2266 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2267 +//    }
  1.2268 +//
  1.2269 +//    func testBodyCellViewModelInlinedAttachmentsChanged_lessAttachments() {
  1.2270 +//        let msg = draftMessage()
  1.2271 +//        let imageAttachment = attachment(ofType: .inline)
  1.2272 +//        msg.replaceAttachments(with: [imageAttachment])
  1.2273 +//        assert(originalMessage: msg,
  1.2274 +//               contentChangedMustBeCalled: false,
  1.2275 +//               focusSwitchedMustBeCalled: false,
  1.2276 +//               validatedStateChangedMustBeCalled: false,
  1.2277 +//               modelChangedMustBeCalled: false,
  1.2278 +//               sectionChangedMustBeCalled: false,
  1.2279 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2280 +//               hideSuggestionsMustBeCalled: false,
  1.2281 +//               showSuggestionsMustBeCalled: false,
  1.2282 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2283 +//               hideMediaAttachmentPickerMustBeCalled: true,
  1.2284 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2285 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2286 +//               didComposeNewMailMustBeCalled: false,
  1.2287 +//               didModifyMessageMustBeCalled: false,
  1.2288 +//               didDeleteMessageMustBeCalled: false)
  1.2289 +//        let lessAttachments = [Attachment]()
  1.2290 +//        vm?.bodyCellViewModel(bodyVm,
  1.2291 +//                              inlinedAttachmentsChanged: lessAttachments)
  1.2292 +//        XCTAssertEqual(vm?.state.inlinedAttachments.count, lessAttachments.count)
  1.2293 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2294 +//    }
  1.2295 +//
  1.2296 +//    func testBodyChangedToPlaintextHtml() {
  1.2297 +//        assert(contentChangedMustBeCalled: true,
  1.2298 +//               focusSwitchedMustBeCalled: false,
  1.2299 +//               validatedStateChangedMustBeCalled: false,
  1.2300 +//               modelChangedMustBeCalled: false,
  1.2301 +//               sectionChangedMustBeCalled: false,
  1.2302 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2303 +//               hideSuggestionsMustBeCalled: false,
  1.2304 +//               showSuggestionsMustBeCalled: false,
  1.2305 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2306 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2307 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2308 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2309 +//               didComposeNewMailMustBeCalled: false,
  1.2310 +//               didModifyMessageMustBeCalled: false,
  1.2311 +//               didDeleteMessageMustBeCalled: false)
  1.2312 +//        let newPlaintext = "newPlaitext"
  1.2313 +//        let newHtml = "<p>fake</p>"
  1.2314 +//        vm?.bodyCellViewModel(bodyVm,
  1.2315 +//                              bodyChangedToPlaintext: newPlaintext,
  1.2316 +//                              html: newHtml)
  1.2317 +//        XCTAssertEqual(vm?.state.bodyHtml, newHtml)
  1.2318 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2319 +//    }
  1.2320 +//
  1.2321 +//    // MARK: - SubjectCellViewModelResultDelegate Handling
  1.2322 +//
  1.2323 +//    private var subjectCellViewModel: SubjectCellViewModel? {
  1.2324 +//        return viewmodel(ofType: SubjectCellViewModel.self) as? SubjectCellViewModel
  1.2325 +//    }
  1.2326 +//
  1.2327 +//    //!!!: crash
  1.2328 +////    func testSubjectCellViewModelDidChangeSubject() {
  1.2329 +////        assert(contentChangedMustBeCalled: true,
  1.2330 +////               focusSwitchedMustBeCalled: false,
  1.2331 +////               validatedStateChangedMustBeCalled: false,
  1.2332 +////               modelChangedMustBeCalled: false,
  1.2333 +////               sectionChangedMustBeCalled: false,
  1.2334 +////               colorBatchNeedsUpdateMustBeCalled: false,
  1.2335 +////               hideSuggestionsMustBeCalled: false,
  1.2336 +////               showSuggestionsMustBeCalled: false,
  1.2337 +////               showMediaAttachmentPickerMustBeCalled: false,
  1.2338 +////               hideMediaAttachmentPickerMustBeCalled: false,
  1.2339 +////               showDocumentAttachmentPickerMustBeCalled: false,
  1.2340 +////               documentAttachmentPickerDonePickerCalled: false,
  1.2341 +////               didComposeNewMailMustBeCalled: false,
  1.2342 +////               didModifyMessageMustBeCalled: false,
  1.2343 +////               didDeleteMessageMustBeCalled: false)
  1.2344 +////        guard let subjectVm = subjectCellViewModel  else {
  1.2345 +////            XCTFail()
  1.2346 +////            return
  1.2347 +////        }
  1.2348 +////        let newSubject = "testSubjectCellViewModelDidChangeSubject content"
  1.2349 +////        subjectVm.content = newSubject
  1.2350 +////        vm?.subjectCellViewModelDidChangeSubject(subjectVm)
  1.2351 +////        XCTAssertEqual(vm?.state.subject, newSubject)
  1.2352 +////        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2353 +////    }
  1.2354 +//
  1.2355 +//    // MARK: - AccountCellViewModelResultDelegate handling
  1.2356 +//
  1.2357 +//    private var accountCellViewModel: AccountCellViewModel? {
  1.2358 +//        return viewmodel(ofType: AccountCellViewModel.self) as? AccountCellViewModel
  1.2359 +//    }
  1.2360 +//
  1.2361 +//    func testAccountCellViewModelAccountChangedTo() {
  1.2362 +//        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
  1.2363 +//        secondAccount.save()
  1.2364 +//        assert(contentChangedMustBeCalled: true,
  1.2365 +//               focusSwitchedMustBeCalled: false,
  1.2366 +//               validatedStateChangedMustBeCalled: true,
  1.2367 +//               modelChangedMustBeCalled: false,
  1.2368 +//               sectionChangedMustBeCalled: false,
  1.2369 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2370 +//               hideSuggestionsMustBeCalled: false,
  1.2371 +//               showSuggestionsMustBeCalled: false,
  1.2372 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2373 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2374 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2375 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2376 +//               didComposeNewMailMustBeCalled: false,
  1.2377 +//               didModifyMessageMustBeCalled: false,
  1.2378 +//               didDeleteMessageMustBeCalled: false)
  1.2379 +//        guard let accountVm = accountCellViewModel else {
  1.2380 +//            XCTFail()
  1.2381 +//            return
  1.2382 +//        }
  1.2383 +//        vm?.accountCellViewModel(accountVm, accountChangedTo: secondAccount)
  1.2384 +//        XCTAssertEqual(vm?.state.from, secondAccount.user)
  1.2385 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2386 +//    }
  1.2387 +//
  1.2388 +//    // MARK: - RecipientCellViewModelResultDelegate Handling
  1.2389 +//
  1.2390 +//    private func recipientCellViewModel(type: RecipientCellViewModel.FieldType) -> RecipientCellViewModel? {
  1.2391 +//        guard let sections = vm?.sections else {
  1.2392 +//            XCTFail()
  1.2393 +//            return nil
  1.2394 +//        }
  1.2395 +//        for section in sections {
  1.2396 +//            for row in section.rows where row is RecipientCellViewModel {
  1.2397 +//                if let row = row as? RecipientCellViewModel, row.type == type {
  1.2398 +//                    return row
  1.2399 +//                }
  1.2400 +//            }
  1.2401 +//        }
  1.2402 +//        return nil
  1.2403 +//    }
  1.2404 +//
  1.2405 +//    func testRecipientCellViewModelDidChangeRecipients_to() {
  1.2406 +//        assertRecipientCellViewModelDidChangeRecipients(fieldType: .to)
  1.2407 +//    }
  1.2408 +//
  1.2409 +//    func testRecipientCellViewModelDidChangeRecipients_cc() {
  1.2410 +//        assertRecipientCellViewModelDidChangeRecipients(fieldType: .cc)
  1.2411 +//    }
  1.2412 +//
  1.2413 +//    func testRecipientCellViewModelDidChangeRecipients_bcc() {
  1.2414 +//        assertRecipientCellViewModelDidChangeRecipients(fieldType: .bcc)
  1.2415 +//    }
  1.2416 +//
  1.2417 +//    func testRecipientCellViewModelDidEndEditing() {
  1.2418 +//        assert(contentChangedMustBeCalled: false,
  1.2419 +//               focusSwitchedMustBeCalled: true,
  1.2420 +//               validatedStateChangedMustBeCalled: true,
  1.2421 +//               modelChangedMustBeCalled: false,
  1.2422 +//               sectionChangedMustBeCalled: false,
  1.2423 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2424 +//               hideSuggestionsMustBeCalled: true,
  1.2425 +//               showSuggestionsMustBeCalled: false,
  1.2426 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2427 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2428 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2429 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2430 +//               didComposeNewMailMustBeCalled: false,
  1.2431 +//               didModifyMessageMustBeCalled: false,
  1.2432 +//               didDeleteMessageMustBeCalled: false)
  1.2433 +//        guard let recipientVm = recipientCellViewModel(type: .to) else {
  1.2434 +//            XCTFail()
  1.2435 +//            return
  1.2436 +//        }
  1.2437 +//        vm?.recipientCellViewModelDidEndEditing(recipientVm)
  1.2438 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2439 +//    }
  1.2440 +//
  1.2441 +//    func testRecipientCellViewModelDidBeginEditing() {
  1.2442 +//        assert(contentChangedMustBeCalled: false,
  1.2443 +//               focusSwitchedMustBeCalled: false,
  1.2444 +//               validatedStateChangedMustBeCalled: false,
  1.2445 +//               modelChangedMustBeCalled: false,
  1.2446 +//               sectionChangedMustBeCalled: false,
  1.2447 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2448 +//               hideSuggestionsMustBeCalled: false,
  1.2449 +//               showSuggestionsMustBeCalled: true,
  1.2450 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2451 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2452 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2453 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2454 +//               didComposeNewMailMustBeCalled: false,
  1.2455 +//               didModifyMessageMustBeCalled: false,
  1.2456 +//               didDeleteMessageMustBeCalled: false)
  1.2457 +//        guard let recipientVm = recipientCellViewModel(type: .to) else {
  1.2458 +//            XCTFail()
  1.2459 +//            return
  1.2460 +//        }
  1.2461 +//        let text = "testRecipientCellViewModelDidBeginEditing text"
  1.2462 +//        vm?.recipientCellViewModel(recipientVm, didBeginEditing: text)
  1.2463 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2464 +//    }
  1.2465 +//
  1.2466 +//    func testRecipientCellViewModelTextChanged() {
  1.2467 +//        assert(contentChangedMustBeCalled: true,
  1.2468 +//               focusSwitchedMustBeCalled: false,
  1.2469 +//               validatedStateChangedMustBeCalled: true,
  1.2470 +//               modelChangedMustBeCalled: false,
  1.2471 +//               sectionChangedMustBeCalled: false,
  1.2472 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2473 +//               hideSuggestionsMustBeCalled: false,
  1.2474 +//               showSuggestionsMustBeCalled: true,
  1.2475 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2476 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2477 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2478 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2479 +//               didComposeNewMailMustBeCalled: false,
  1.2480 +//               didModifyMessageMustBeCalled: false,
  1.2481 +//               didDeleteMessageMustBeCalled: false)
  1.2482 +//        guard let recipientVm = recipientCellViewModel(type: .to) else {
  1.2483 +//            XCTFail()
  1.2484 +//            return
  1.2485 +//        }
  1.2486 +//        let text = "testRecipientCellViewModelDidBeginEditing text"
  1.2487 +//        vm?.recipientCellViewModel(recipientVm, textChanged: text)
  1.2488 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2489 +//    }
  1.2490 +//
  1.2491 +//    // MARK: - Cancel Actions
  1.2492 +//
  1.2493 +//    /*
  1.2494 +//    func testShowKeepInOutbox() {
  1.2495 +//        FolderType.allCases.forEach {
  1.2496 +//            assertShowKeepInOutbox(forMessageInfolderOfType: $0)
  1.2497 +//        }
  1.2498 +//    }
  1.2499 +// */
  1.2500 +//
  1.2501 +//    func testShowCancelActionsv() {
  1.2502 +//        let msg = message()
  1.2503 +//        assert(originalMessage: msg)
  1.2504 +//        guard let testee = vm?.showCancelActions else {
  1.2505 +//            XCTFail()
  1.2506 +//            return
  1.2507 +//        }
  1.2508 +//        XCTAssertFalse(testee)
  1.2509 +//    }
  1.2510 +//
  1.2511 +//    func testShowCancelActions_edited() {
  1.2512 +//        let msg = message()
  1.2513 +//        assert(originalMessage: msg)
  1.2514 +//        vm?.state.toRecipients = [Identity(address: "testShow@Cancel.Actions")]
  1.2515 +//        guard let testee = vm?.showCancelActions else {
  1.2516 +//            XCTFail()
  1.2517 +//            return
  1.2518 +//        }
  1.2519 +//        XCTAssertTrue(testee)
  1.2520 +//    }
  1.2521 +//
  1.2522 +//    func testHandleSaveActionTriggered() {
  1.2523 +//        assert(originalMessage: nil,
  1.2524 +//               contentChangedMustBeCalled: false,
  1.2525 +//               focusSwitchedMustBeCalled: false,
  1.2526 +//               validatedStateChangedMustBeCalled: false,
  1.2527 +//               modelChangedMustBeCalled: false,
  1.2528 +//               sectionChangedMustBeCalled: false,
  1.2529 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2530 +//               hideSuggestionsMustBeCalled: false,
  1.2531 +//               showSuggestionsMustBeCalled: false,
  1.2532 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2533 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2534 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2535 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2536 +//               didComposeNewMailMustBeCalled: false,
  1.2537 +//               didModifyMessageMustBeCalled: false,
  1.2538 +//               didDeleteMessageMustBeCalled: false)
  1.2539 +//
  1.2540 +//        let testSubject = UUID().uuidString + "testSubject"
  1.2541 +//        vm?.state.subject = testSubject
  1.2542 +//
  1.2543 +//        vm?.handleSaveActionTriggered()
  1.2544 +//
  1.2545 +//        guard
  1.2546 +//            let draftsFolder = drafts,
  1.2547 +//            let testeeDrafted = Message.by(uid: 0,
  1.2548 +//                                           folderName: draftsFolder.name,
  1.2549 +//                                           accountAddress: account.user.address)
  1.2550 +//            else {
  1.2551 +//                XCTFail("Message not saved to drafts")
  1.2552 +//                return
  1.2553 +//        }
  1.2554 +//        XCTAssertEqual(testeeDrafted.shortMessage, testSubject)
  1.2555 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2556 +//    }
  1.2557 +//
  1.2558 +//    //!!!: crash
  1.2559 +////    func testHandleSaveActionTriggered_origOutbox() {
  1.2560 +////        let testMessageId = UUID().uuidString + "testHandleSaveActionTriggered"
  1.2561 +////        let originalMessage = message(inFolderOfType: .outbox)
  1.2562 +////        originalMessage.messageID = testMessageId
  1.2563 +////        originalMessage.from = account.user
  1.2564 +////
  1.2565 +////        assert(originalMessage: originalMessage,
  1.2566 +////               contentChangedMustBeCalled: false,
  1.2567 +////               focusSwitchedMustBeCalled: false,
  1.2568 +////               validatedStateChangedMustBeCalled: false,
  1.2569 +////               modelChangedMustBeCalled: false,
  1.2570 +////               sectionChangedMustBeCalled: false,
  1.2571 +////               colorBatchNeedsUpdateMustBeCalled: false,
  1.2572 +////               hideSuggestionsMustBeCalled: false,
  1.2573 +////               showSuggestionsMustBeCalled: false,
  1.2574 +////               showMediaAttachmentPickerMustBeCalled: false,
  1.2575 +////               hideMediaAttachmentPickerMustBeCalled: false,
  1.2576 +////               showDocumentAttachmentPickerMustBeCalled: false,
  1.2577 +////               documentAttachmentPickerDonePickerCalled: false,
  1.2578 +////               didComposeNewMailMustBeCalled: false,
  1.2579 +////               didModifyMessageMustBeCalled: false,
  1.2580 +////               didDeleteMessageMustBeCalled: true)
  1.2581 +////        vm?.handleSaveActionTriggered()
  1.2582 +////        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
  1.2583 +////                                              uuid: originalMessage.uuid,
  1.2584 +////                                              folderName: originalMessage.parent.name,
  1.2585 +////                                              accountAddress: account.user.address)
  1.2586 +////        XCTAssertNil(msgWithTestMessageId,
  1.2587 +////                     "original message must be deleted, a copy is safed to drafts")
  1.2588 +////        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2589 +////    }
  1.2590 +//
  1.2591 +//    func testHandleSaveActionTriggered_origDrafts() {
  1.2592 +//        let testMessageId = UUID().uuidString + "testHandleSaveActionTriggered"
  1.2593 +//        let originalMessage = message(inFolderOfType: .drafts)
  1.2594 +//        originalMessage.messageID = testMessageId
  1.2595 +//        originalMessage.from = account.user
  1.2596 +//
  1.2597 +//        assert(originalMessage: originalMessage,
  1.2598 +//               contentChangedMustBeCalled: false,
  1.2599 +//               focusSwitchedMustBeCalled: false,
  1.2600 +//               validatedStateChangedMustBeCalled: false,
  1.2601 +//               modelChangedMustBeCalled: false,
  1.2602 +//               sectionChangedMustBeCalled: false,
  1.2603 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2604 +//               hideSuggestionsMustBeCalled: false,
  1.2605 +//               showSuggestionsMustBeCalled: false,
  1.2606 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2607 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2608 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2609 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2610 +//               didComposeNewMailMustBeCalled: false,
  1.2611 +//               didModifyMessageMustBeCalled: true,
  1.2612 +//               didDeleteMessageMustBeCalled: true)
  1.2613 +//        vm?.handleSaveActionTriggered()
  1.2614 +//        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
  1.2615 +//                                              uuid: originalMessage.uuid,
  1.2616 +//                                              folderName: originalMessage.parent.name,
  1.2617 +//                                              accountAddress: account.user.address,
  1.2618 +//                                              includingDeleted: true)
  1.2619 +//        XCTAssertTrue(msgWithTestMessageId?.imapFlags.deleted ?? false,
  1.2620 +//                     "The user edited draft. Technically we save a new message, thus the original" +
  1.2621 +//            " must be deleted.")
  1.2622 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2623 +//    }
  1.2624 +//
  1.2625 +//    func testHandleDeleteActionTriggered_normal() {
  1.2626 +//        assert(originalMessage: nil,
  1.2627 +//               contentChangedMustBeCalled: false,
  1.2628 +//               focusSwitchedMustBeCalled: false,
  1.2629 +//               validatedStateChangedMustBeCalled: false,
  1.2630 +//               modelChangedMustBeCalled: false,
  1.2631 +//               sectionChangedMustBeCalled: false,
  1.2632 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2633 +//               hideSuggestionsMustBeCalled: false,
  1.2634 +//               showSuggestionsMustBeCalled: false,
  1.2635 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2636 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2637 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2638 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2639 +//               didComposeNewMailMustBeCalled: false,
  1.2640 +//               didModifyMessageMustBeCalled: false,
  1.2641 +//               didDeleteMessageMustBeCalled: false)
  1.2642 +//        vm?.handleSaveActionTriggered()
  1.2643 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2644 +//    }
  1.2645 +//
  1.2646 +//    //!!!: crash
  1.2647 +////    func testHandleDeleteActionTriggered_origOutbox() {
  1.2648 +////        let testMessageId = UUID().uuidString + "testHandleDeleteActionTriggered_origOutbox"
  1.2649 +////        let originalMessage = message(inFolderOfType: .outbox)
  1.2650 +////        originalMessage.messageID = testMessageId
  1.2651 +////        originalMessage.from = account.user
  1.2652 +////
  1.2653 +////        assert(originalMessage: originalMessage,
  1.2654 +////               contentChangedMustBeCalled: false,
  1.2655 +////               focusSwitchedMustBeCalled: false,
  1.2656 +////               validatedStateChangedMustBeCalled: false,
  1.2657 +////               modelChangedMustBeCalled: false,
  1.2658 +////               sectionChangedMustBeCalled: false,
  1.2659 +////               colorBatchNeedsUpdateMustBeCalled: false,
  1.2660 +////               hideSuggestionsMustBeCalled: false,
  1.2661 +////               showSuggestionsMustBeCalled: false,
  1.2662 +////               showMediaAttachmentPickerMustBeCalled: false,
  1.2663 +////               hideMediaAttachmentPickerMustBeCalled: false,
  1.2664 +////               showDocumentAttachmentPickerMustBeCalled: false,
  1.2665 +////               documentAttachmentPickerDonePickerCalled: false,
  1.2666 +////               didComposeNewMailMustBeCalled: false,
  1.2667 +////               didModifyMessageMustBeCalled: false,
  1.2668 +////               didDeleteMessageMustBeCalled: true)
  1.2669 +////        vm?.handleSaveActionTriggered()
  1.2670 +////        let msgWithTestMessageId = Message.by(uid: originalMessage.uid,
  1.2671 +////                                              uuid: originalMessage.uuid,
  1.2672 +////                                              folderName: originalMessage.parent.name,
  1.2673 +////                                              accountAddress: account.user.address)
  1.2674 +////        XCTAssertNil(msgWithTestMessageId,
  1.2675 +////                     "original message must be deleted, a copy is safed to drafts")
  1.2676 +////        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2677 +////    }
  1.2678 +//
  1.2679 +//    // MARK: - Suggestions
  1.2680 +//
  1.2681 +//    func testSuggestViewModel() {
  1.2682 +//        let testee = vm?.suggestViewModel()
  1.2683 +//        XCTAssertNotNil(testee)
  1.2684 +//        XCTAssertTrue(testee?.resultDelegate === vm)
  1.2685 +//    }
  1.2686 +//
  1.2687 +//    // showSuggestions and hideSuggestions are tested altering recipients
  1.2688 +//
  1.2689 +//    //!!!: crash
  1.2690 +////    func testShowSuggestionsScrollFocus_nonEmpty() {
  1.2691 +////        let expectedSuggestionsVisibility = true
  1.2692 +////        assert(contentChangedMustBeCalled: false,
  1.2693 +////               focusSwitchedMustBeCalled: false,
  1.2694 +////               validatedStateChangedMustBeCalled: false,
  1.2695 +////               expectedIsValidated: nil,
  1.2696 +////               modelChangedMustBeCalled: false,
  1.2697 +////               sectionChangedMustBeCalled: false,
  1.2698 +////               colorBatchNeedsUpdateMustBeCalled: false,
  1.2699 +////               hideSuggestionsMustBeCalled: false,
  1.2700 +////               showSuggestionsMustBeCalled: false,
  1.2701 +////               suggestionsScrollFocusChangedMustBeCalled: true,
  1.2702 +////               expectedNewSuggestionsScrollFocusIsVisible: expectedSuggestionsVisibility,
  1.2703 +////               showMediaAttachmentPickerMustBeCalled: false,
  1.2704 +////               hideMediaAttachmentPickerMustBeCalled: false,
  1.2705 +////               showDocumentAttachmentPickerMustBeCalled: false,
  1.2706 +////               documentAttachmentPickerDonePickerCalled: false,
  1.2707 +////               didComposeNewMailMustBeCalled: false,
  1.2708 +////               didModifyMessageMustBeCalled: false,
  1.2709 +////               didDeleteMessageMustBeCalled: false)
  1.2710 +////        let _ = vm?.suggestViewModel(SuggestViewModel(),
  1.2711 +////                                     didToggleVisibilityTo: expectedSuggestionsVisibility)
  1.2712 +////        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2713 +////    }
  1.2714 +//
  1.2715 +//    func testShowSuggestionsScrollFocus_empty() {
  1.2716 +//        let expectedSuggestionsVisibility = false
  1.2717 +//        assert(contentChangedMustBeCalled: false,
  1.2718 +//               focusSwitchedMustBeCalled: false,
  1.2719 +//               validatedStateChangedMustBeCalled: false,
  1.2720 +//               expectedIsValidated: nil,
  1.2721 +//               modelChangedMustBeCalled: false,
  1.2722 +//               sectionChangedMustBeCalled: false,
  1.2723 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2724 +//               hideSuggestionsMustBeCalled: false,
  1.2725 +//               showSuggestionsMustBeCalled: false,
  1.2726 +//               suggestionsScrollFocusChangedMustBeCalled: true,
  1.2727 +//               expectedNewSuggestionsScrollFocusIsVisible: expectedSuggestionsVisibility,
  1.2728 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2729 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2730 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2731 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2732 +//               didComposeNewMailMustBeCalled: false,
  1.2733 +//               didModifyMessageMustBeCalled: false,
  1.2734 +//               didDeleteMessageMustBeCalled: false)
  1.2735 +//        let _ = vm?.suggestViewModel(SuggestViewModel(),
  1.2736 +//                                     didToggleVisibilityTo: expectedSuggestionsVisibility)
  1.2737 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2738 +//    }
  1.2739 +//
  1.2740 +//// MARK: - ComposeViewModelStateDelegate Handling
  1.2741 +//
  1.2742 +//    func testComposeViewModelStateDidChangeValidationStateTo() {
  1.2743 +//        let expectedIsValid = true
  1.2744 +//        assert(contentChangedMustBeCalled: false,
  1.2745 +//               focusSwitchedMustBeCalled: false,
  1.2746 +//               validatedStateChangedMustBeCalled: true,
  1.2747 +//               expectedIsValidated: expectedIsValid,
  1.2748 +//               modelChangedMustBeCalled: false,
  1.2749 +//               sectionChangedMustBeCalled: false,
  1.2750 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2751 +//               hideSuggestionsMustBeCalled: false,
  1.2752 +//               showSuggestionsMustBeCalled: false,
  1.2753 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2754 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2755 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2756 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2757 +//               didComposeNewMailMustBeCalled: false,
  1.2758 +//               didModifyMessageMustBeCalled: false,
  1.2759 +//               didDeleteMessageMustBeCalled: false)
  1.2760 +//        guard let state = vm?.state else {
  1.2761 +//            XCTFail()
  1.2762 +//            return
  1.2763 +//        }
  1.2764 +//        vm?.composeViewModelState(state, didChangeValidationStateTo: expectedIsValid)
  1.2765 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2766 +//    }
  1.2767 +//
  1.2768 +//    func testComposeViewModelDidChangePEPRatingTo() {
  1.2769 +//        let expectedRating = PEPRating.reliable
  1.2770 +//        vm?.state.pEpProtection = true
  1.2771 +//        let expectedProtection = vm?.state.pEpProtection ?? false
  1.2772 +//        assert(contentChangedMustBeCalled: false,
  1.2773 +//               focusSwitchedMustBeCalled: false,
  1.2774 +//               validatedStateChangedMustBeCalled: false,
  1.2775 +//               modelChangedMustBeCalled: false,
  1.2776 +//               sectionChangedMustBeCalled: false,
  1.2777 +//               colorBatchNeedsUpdateMustBeCalled: true,
  1.2778 +//               expectedRating: expectedRating,
  1.2779 +//               expectedProtectionEnabled: expectedProtection,
  1.2780 +//               hideSuggestionsMustBeCalled: false,
  1.2781 +//               showSuggestionsMustBeCalled: false,
  1.2782 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2783 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2784 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2785 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2786 +//               didComposeNewMailMustBeCalled: false,
  1.2787 +//               didModifyMessageMustBeCalled: false,
  1.2788 +//               didDeleteMessageMustBeCalled: false)
  1.2789 +//        guard let state = vm?.state else {
  1.2790 +//            XCTFail()
  1.2791 +//            return
  1.2792 +//        }
  1.2793 +//        vm?.composeViewModelState(state, didChangePEPRatingTo: expectedRating)
  1.2794 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2795 +//    }
  1.2796 +//
  1.2797 +//    // MARK: - Delegate Setter Side Effect
  1.2798 +//
  1.2799 +//    func testDelegateSetter() {
  1.2800 +//        let expectedRating = PEPRating.undefined
  1.2801 +//        let expectedProtection = true
  1.2802 +//        assert(contentChangedMustBeCalled: false,
  1.2803 +//               focusSwitchedMustBeCalled: false,
  1.2804 +//               validatedStateChangedMustBeCalled: false,
  1.2805 +//               modelChangedMustBeCalled: false,
  1.2806 +//               sectionChangedMustBeCalled: false,
  1.2807 +//               colorBatchNeedsUpdateMustBeCalled: true,
  1.2808 +//               expectedRating: expectedRating,
  1.2809 +//               expectedProtectionEnabled: expectedProtection,
  1.2810 +//               hideSuggestionsMustBeCalled: false,
  1.2811 +//               showSuggestionsMustBeCalled: false,
  1.2812 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2813 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2814 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2815 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2816 +//               didComposeNewMailMustBeCalled: false,
  1.2817 +//               didModifyMessageMustBeCalled: false,
  1.2818 +//               didDeleteMessageMustBeCalled: false)
  1.2819 +//        vm?.delegate = testDelegate
  1.2820 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2821 +//    }
  1.2822 +//
  1.2823 +//    // MARK: - isAttachmentSection
  1.2824 +//
  1.2825 +//    func testIsAttachmentSection() {
  1.2826 +//        let msgWithAttachment = draftMessage(attachmentsSet: true)
  1.2827 +//        assert(originalMessage: msgWithAttachment)
  1.2828 +//        guard
  1.2829 +//            let lastSection = vm?.sections.last,
  1.2830 +//            let numSections = vm?.sections.count else {
  1.2831 +//                XCTFail()
  1.2832 +//                return
  1.2833 +//        }
  1.2834 +//        let numRows = lastSection.rows.count
  1.2835 +//        let idxPath = IndexPath(row: numRows - 1, section: numSections - 1)
  1.2836 +//        XCTAssertTrue(vm?.isAttachmentSection(indexPath: idxPath) ?? false,
  1.2837 +//                      "Last row in last section must be attachment")
  1.2838 +//    }
  1.2839 +//
  1.2840 +//    // MARK: - handleRemovedRow
  1.2841 +//
  1.2842 +//    func testHandleRemovedRow_removeAttachment() {
  1.2843 +//        let msgWithAttachments = draftMessage(attachmentsSet: true)
  1.2844 +//        msgWithAttachments.appendToAttachments(attachment(ofType: .attachment))
  1.2845 +//        msgWithAttachments.save()
  1.2846 +//        assert(originalMessage: msgWithAttachments)
  1.2847 +//        vm?.state.nonInlinedAttachments = msgWithAttachments.attachments.array
  1.2848 +//        guard
  1.2849 +//            let lastSectionBefore = vm?.sections.last,
  1.2850 +//            let numSectionsBefore = vm?.sections.count,
  1.2851 +//            let numNonIlinedAttachmentsBefore = vm?.state.nonInlinedAttachments.count
  1.2852 +//            else {
  1.2853 +//                XCTFail()
  1.2854 +//                return
  1.2855 +//        }
  1.2856 +//        let numRowsBefore  = lastSectionBefore.rows.count
  1.2857 +//        let attachmentIdxPath = IndexPath(row: numRowsBefore - 1,
  1.2858 +//                                          section: numSectionsBefore - 1)
  1.2859 +//        // Test
  1.2860 +//        vm?.handleRemovedRow(at: attachmentIdxPath)
  1.2861 +//        guard
  1.2862 +//            let lastSectionAfter = vm?.sections.last,
  1.2863 +//            let numSectionsAfter = vm?.sections.count,
  1.2864 +//            let numNonIlinedAttachmentsAfter = vm?.state.nonInlinedAttachments.count
  1.2865 +//            else {
  1.2866 +//                XCTFail()
  1.2867 +//                return
  1.2868 +//        }
  1.2869 +//        let numRowsAfter = lastSectionAfter.rows.count
  1.2870 +//        XCTAssertEqual(numNonIlinedAttachmentsAfter, numNonIlinedAttachmentsBefore - 1)
  1.2871 +//        XCTAssertEqual(numSectionsAfter, numSectionsBefore)
  1.2872 +//        XCTAssertEqual(numRowsAfter, numRowsBefore - 1, "Attachment is removed")
  1.2873 +//    }
  1.2874 +//
  1.2875 +//    // MARK: - handleUserClickedSendButton
  1.2876 +//
  1.2877 +//    func testHandleUserClickedSendButton() {
  1.2878 +//        assert()
  1.2879 +//        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
  1.2880 +//        vm?.state.toRecipients = [toRecipient]
  1.2881 +//        vm?.state.from = account.user
  1.2882 +//        let outMsgsBefore = Folder.by(account: account, folderType: .outbox)?
  1.2883 +//            .allMessagesNonThreaded()
  1.2884 +//            .count ?? -1
  1.2885 +//        vm?.handleUserClickedSendButton()
  1.2886 +//        let outMsgsAfter = Folder.by(account: account, folderType: .outbox)?
  1.2887 +//            .allMessagesNonThreaded()
  1.2888 +//            .count ?? -1
  1.2889 +//        XCTAssertEqual(outMsgsAfter, outMsgsBefore + 1)
  1.2890 +//        XCTAssertGreaterThan(outMsgsAfter, 0)
  1.2891 +//    }
  1.2892 +//
  1.2893 +//    func testHandleUserClickedSendButton_origDraft() {
  1.2894 +//        let testMessageId = UUID().uuidString + #function
  1.2895 +//        let originalMessage = draftMessage()
  1.2896 +//        originalMessage.messageID = testMessageId
  1.2897 +//        originalMessage.from = account.user
  1.2898 +//        originalMessage.save()
  1.2899 +//        XCTAssertNotNil(Message.by(uid: originalMessage.uid,
  1.2900 +//                                   uuid: originalMessage.uuid,
  1.2901 +//                                   folderName: originalMessage.parent.name,
  1.2902 +//                                   accountAddress: account.user.address))
  1.2903 +//        assert(originalMessage: originalMessage)
  1.2904 +//        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
  1.2905 +//        vm?.state.toRecipients = [toRecipient]
  1.2906 +//        vm?.state.from = account.user
  1.2907 +//        vm?.handleUserClickedSendButton()
  1.2908 +//        guard
  1.2909 +//            let originalDraftedMessageDeleted =
  1.2910 +//            Message.by(uid: originalMessage.uid,
  1.2911 +//                       uuid: originalMessage.uuid,
  1.2912 +//                       folderName: originalMessage.parent.name,
  1.2913 +//                       accountAddress: account.user.address,
  1.2914 +//                       includingDeleted: true)?.imapFlags.deleted
  1.2915 +//            else {
  1.2916 +//                XCTFail()
  1.2917 +//                return
  1.2918 +//        }
  1.2919 +//        XCTAssertTrue(originalDraftedMessageDeleted,
  1.2920 +//                      "original drafted message must be flagged deleted")
  1.2921 +//    }
  1.2922 +//
  1.2923 +//    //!!!: crash
  1.2924 +////    func testHandleUserClickedSendButton_origOutbox() {
  1.2925 +////        let testMessageId = UUID().uuidString + #function
  1.2926 +////        let originalMessage = message(inFolderOfType: .outbox)
  1.2927 +////        originalMessage.messageID = testMessageId
  1.2928 +////        originalMessage.from = account.user
  1.2929 +////        originalMessage.save()
  1.2930 +////        XCTAssertNotNil(Message.by(uid: originalMessage.uid,
  1.2931 +////                                   uuid: originalMessage.uuid,
  1.2932 +////                                   folderName: originalMessage.parent.name,
  1.2933 +////                                   accountAddress: account.user.address))
  1.2934 +////        assert(originalMessage: originalMessage)
  1.2935 +////        let toRecipient = Identity(address: "testHandleUserClickedSend@Butt.on")
  1.2936 +////        vm?.state.toRecipients = [toRecipient]
  1.2937 +////        vm?.state.from = account.user
  1.2938 +////        vm?.handleUserClickedSendButton()
  1.2939 +////        if let _ = Message.by(uid: originalMessage.uid,
  1.2940 +////                              uuid: originalMessage.uuid,
  1.2941 +////                              folderName: originalMessage.parent.name,
  1.2942 +////                              accountAddress: account.user.address) {
  1.2943 +////            XCTFail("original message must not exist (must be deleted)")
  1.2944 +////            return
  1.2945 +////        }
  1.2946 +////    }
  1.2947 +//
  1.2948 +//    // MARK: - handleUserChangedProtectionStatus
  1.2949 +//
  1.2950 +//    func testHandleUserChangedProtectionStatus_change() {
  1.2951 +//        let expectedRating = PEPRating.undefined
  1.2952 +//        let expectedProtection = false
  1.2953 +//        assert(contentChangedMustBeCalled: false,
  1.2954 +//               focusSwitchedMustBeCalled: false,
  1.2955 +//               validatedStateChangedMustBeCalled: false,
  1.2956 +//               modelChangedMustBeCalled: false,
  1.2957 +//               sectionChangedMustBeCalled: false,
  1.2958 +//               colorBatchNeedsUpdateMustBeCalled: true,
  1.2959 +//               expectedRating: expectedRating,
  1.2960 +//               expectedProtectionEnabled: expectedProtection,
  1.2961 +//               hideSuggestionsMustBeCalled: false,
  1.2962 +//               showSuggestionsMustBeCalled: false,
  1.2963 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2964 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2965 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2966 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2967 +//               didComposeNewMailMustBeCalled: false,
  1.2968 +//               didModifyMessageMustBeCalled: false,
  1.2969 +//               didDeleteMessageMustBeCalled: false)
  1.2970 +//        vm?.handleUserChangedProtectionStatus(to: false)
  1.2971 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2972 +//    }
  1.2973 +//
  1.2974 +//    func testHandleUserChangedProtectionStatus_noChange() {
  1.2975 +//        assert(contentChangedMustBeCalled: false,
  1.2976 +//               focusSwitchedMustBeCalled: false,
  1.2977 +//               validatedStateChangedMustBeCalled: false,
  1.2978 +//               modelChangedMustBeCalled: false,
  1.2979 +//               sectionChangedMustBeCalled: false,
  1.2980 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.2981 +//               hideSuggestionsMustBeCalled: false,
  1.2982 +//               showSuggestionsMustBeCalled: false,
  1.2983 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.2984 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.2985 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.2986 +//               documentAttachmentPickerDonePickerCalled: false,
  1.2987 +//               didComposeNewMailMustBeCalled: false,
  1.2988 +//               didModifyMessageMustBeCalled: false,
  1.2989 +//               didDeleteMessageMustBeCalled: false)
  1.2990 +//        vm?.handleUserChangedProtectionStatus(to: true)
  1.2991 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.2992 +//    }
  1.2993 +//
  1.2994 +//    // MARK: - handleUserSelectedRow
  1.2995 +//
  1.2996 +//    func testHandleUserSelectedRow_ccWrapped_wrapperCellSelected() {
  1.2997 +//        assert(contentChangedMustBeCalled: false,
  1.2998 +//               focusSwitchedMustBeCalled: false,
  1.2999 +//               validatedStateChangedMustBeCalled: false,
  1.3000 +//               modelChangedMustBeCalled: false,
  1.3001 +//               sectionChangedMustBeCalled: true,
  1.3002 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3003 +//               hideSuggestionsMustBeCalled: false,
  1.3004 +//               showSuggestionsMustBeCalled: false,
  1.3005 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3006 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3007 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3008 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3009 +//               didComposeNewMailMustBeCalled: false,
  1.3010 +//               didModifyMessageMustBeCalled: false,
  1.3011 +//               didDeleteMessageMustBeCalled: false)
  1.3012 +//        guard
  1.3013 +//            let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self),
  1.3014 +//            let idxPath = indexPath(for: wrapperVM) else {
  1.3015 +//                XCTFail("No VM")
  1.3016 +//                return
  1.3017 +//        }
  1.3018 +//        vm?.handleUserSelectedRow(at: idxPath)
  1.3019 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3020 +//    }
  1.3021 +//
  1.3022 +//    func testHandleUserSelectedRow_ccWrapped_recipientCellSelected() {
  1.3023 +//        assert(contentChangedMustBeCalled: false,
  1.3024 +//               focusSwitchedMustBeCalled: false,
  1.3025 +//               validatedStateChangedMustBeCalled: false,
  1.3026 +//               modelChangedMustBeCalled: false,
  1.3027 +//               sectionChangedMustBeCalled: false,
  1.3028 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3029 +//               hideSuggestionsMustBeCalled: false,
  1.3030 +//               showSuggestionsMustBeCalled: false,
  1.3031 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3032 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3033 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3034 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3035 +//               didComposeNewMailMustBeCalled: false,
  1.3036 +//               didModifyMessageMustBeCalled: false,
  1.3037 +//               didDeleteMessageMustBeCalled: false)
  1.3038 +//        let idxPathToRecipients = IndexPath(row: 0, section: 0)
  1.3039 +//        vm?.handleUserSelectedRow(at: idxPathToRecipients)
  1.3040 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3041 +//    }
  1.3042 +//
  1.3043 +//    func testHandleUserSelectedRow_ccUnwrapped_recipientCellSelected() {
  1.3044 +//        let originalMessage = draftMessage()
  1.3045 +//        assert(originalMessage: originalMessage,
  1.3046 +//               contentChangedMustBeCalled: false,
  1.3047 +//               focusSwitchedMustBeCalled: false,
  1.3048 +//               validatedStateChangedMustBeCalled: false,
  1.3049 +//               modelChangedMustBeCalled: false,
  1.3050 +//               sectionChangedMustBeCalled: false,
  1.3051 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3052 +//               hideSuggestionsMustBeCalled: false,
  1.3053 +//               showSuggestionsMustBeCalled: false,
  1.3054 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3055 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3056 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3057 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3058 +//               didComposeNewMailMustBeCalled: false,
  1.3059 +//               didModifyMessageMustBeCalled: false,
  1.3060 +//               didDeleteMessageMustBeCalled: false)
  1.3061 +//        let idxPathToRecipients = IndexPath(row: 0, section: 0)
  1.3062 +//        vm?.handleUserSelectedRow(at: idxPathToRecipients)
  1.3063 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3064 +//    }
  1.3065 +//
  1.3066 +//    // MARK: - viewModel(for:)
  1.3067 +//
  1.3068 +//    //!!!: crash
  1.3069 +////    func testViewModelForIndexPath() {
  1.3070 +////        assert(contentChangedMustBeCalled: false,
  1.3071 +////               focusSwitchedMustBeCalled: false,
  1.3072 +////               validatedStateChangedMustBeCalled: false,
  1.3073 +////               modelChangedMustBeCalled: false,
  1.3074 +////               sectionChangedMustBeCalled: false,
  1.3075 +////               colorBatchNeedsUpdateMustBeCalled: false,
  1.3076 +////               hideSuggestionsMustBeCalled: false,
  1.3077 +////               showSuggestionsMustBeCalled: false,
  1.3078 +////               showMediaAttachmentPickerMustBeCalled: false,
  1.3079 +////               hideMediaAttachmentPickerMustBeCalled: false,
  1.3080 +////               showDocumentAttachmentPickerMustBeCalled: false,
  1.3081 +////               documentAttachmentPickerDonePickerCalled: false,
  1.3082 +////               didComposeNewMailMustBeCalled: false,
  1.3083 +////               didModifyMessageMustBeCalled: false,
  1.3084 +////               didDeleteMessageMustBeCalled: false)
  1.3085 +////        guard
  1.3086 +////            let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self),
  1.3087 +////            let idxPath = indexPath(for: wrapperVM) else {
  1.3088 +////                XCTFail("No VM")
  1.3089 +////                return
  1.3090 +////        }
  1.3091 +////        guard let testee = vm?.viewModel(for: idxPath) else {
  1.3092 +////            XCTFail()
  1.3093 +////            return
  1.3094 +////        }
  1.3095 +////        XCTAssertTrue(testee === wrapperVM)
  1.3096 +////        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3097 +////    }
  1.3098 +//
  1.3099 +//    func testViewModelForIndexPath_notAlwaysWrapper() {
  1.3100 +//        assert()
  1.3101 +//        guard let wrapperVM = viewmodel(ofType: WrappedBccViewModel.self) else {
  1.3102 +//                XCTFail("No VM")
  1.3103 +//                return
  1.3104 +//        }
  1.3105 +//        let toRecipientsIdxPath = IndexPath(row: 0, section: 0)
  1.3106 +//        guard let testee = vm?.viewModel(for: toRecipientsIdxPath) else {
  1.3107 +//            XCTFail()
  1.3108 +//            return
  1.3109 +//        }
  1.3110 +//        XCTAssertFalse(testee === wrapperVM)
  1.3111 +//    }
  1.3112 +//
  1.3113 +//    // MARK: - beforePickerFocus
  1.3114 +//
  1.3115 +//    func testBeforePickerFocus() {
  1.3116 +//        assert()
  1.3117 +//        guard let bodyVm = vm?.bodyVM else {
  1.3118 +//            XCTFail()
  1.3119 +//            return
  1.3120 +//        }
  1.3121 +//        let beforeFocus = indexPath(for: bodyVm)
  1.3122 +//        let testee = vm?.beforePickerFocus()
  1.3123 +//        XCTAssertEqual(testee, beforeFocus)
  1.3124 +//        let toRecipientsIndPath = IndexPath(row: 0, section: 0)
  1.3125 +//        XCTAssertNotEqual(testee, toRecipientsIndPath)
  1.3126 +//    }
  1.3127 +//
  1.3128 +//    // MARK: - initialFocus
  1.3129 +//
  1.3130 +//    func testInitialFocus_emptyTo() {
  1.3131 +//        let originalMessage = draftMessage()
  1.3132 +//        originalMessage.replaceTo(with: [])
  1.3133 +//        originalMessage.save()
  1.3134 +//        assert(originalMessage: originalMessage,
  1.3135 +//               contentChangedMustBeCalled: false,
  1.3136 +//               focusSwitchedMustBeCalled: false,
  1.3137 +//               validatedStateChangedMustBeCalled: false,
  1.3138 +//               modelChangedMustBeCalled: false,
  1.3139 +//               sectionChangedMustBeCalled: false,
  1.3140 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3141 +//               hideSuggestionsMustBeCalled: false,
  1.3142 +//               showSuggestionsMustBeCalled: false,
  1.3143 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3144 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3145 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3146 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3147 +//               didComposeNewMailMustBeCalled: false,
  1.3148 +//               didModifyMessageMustBeCalled: false,
  1.3149 +//               didDeleteMessageMustBeCalled: false)
  1.3150 +//        guard let testee = vm?.initialFocus() else {
  1.3151 +//            XCTFail()
  1.3152 +//            return
  1.3153 +//        }
  1.3154 +//        let toRecipientsIndPath = IndexPath(row: 0, section: 0)
  1.3155 +//        XCTAssertEqual(testee, toRecipientsIndPath)
  1.3156 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3157 +//    }
  1.3158 +//
  1.3159 +//    func testInitialFocus_toSet() {
  1.3160 +//        let originalMessage = draftMessage()
  1.3161 +//        originalMessage.replaceTo(with: [account.user])
  1.3162 +//        originalMessage.save()
  1.3163 +//        assert(originalMessage: originalMessage,
  1.3164 +//               contentChangedMustBeCalled: false,
  1.3165 +//               focusSwitchedMustBeCalled: false,
  1.3166 +//               validatedStateChangedMustBeCalled: false,
  1.3167 +//               modelChangedMustBeCalled: false,
  1.3168 +//               sectionChangedMustBeCalled: false,
  1.3169 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3170 +//               hideSuggestionsMustBeCalled: false,
  1.3171 +//               showSuggestionsMustBeCalled: false,
  1.3172 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3173 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3174 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3175 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3176 +//               didComposeNewMailMustBeCalled: false,
  1.3177 +//               didModifyMessageMustBeCalled: false,
  1.3178 +//               didDeleteMessageMustBeCalled: false)
  1.3179 +//        guard
  1.3180 +//            let testee = vm?.initialFocus(),
  1.3181 +//            let bodyVM = vm?.bodyVM,
  1.3182 +//            let bodyIndexPath = indexPath(for: bodyVM)
  1.3183 +//            else {
  1.3184 +//                XCTFail()
  1.3185 +//                return
  1.3186 +//        }
  1.3187 +//        let toRecipientsIndexPath = IndexPath(row: 0, section: 0)
  1.3188 +//        XCTAssertEqual(testee, bodyIndexPath)
  1.3189 +//        XCTAssertNotEqual(testee, toRecipientsIndexPath)
  1.3190 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3191 +//    }
  1.3192 +//
  1.3193 +//    // MARK: - Helper
  1.3194 +//
  1.3195 +//    private func indexPath(for cellViewModel: CellViewModel) -> IndexPath? {
  1.3196 +//        guard let vm = vm else {
  1.3197 +//            XCTFail("No VM")
  1.3198 +//            return nil
  1.3199 +//        }
  1.3200 +//        for s in 0..<vm.sections.count {
  1.3201 +//            let section = vm.sections[s]
  1.3202 +//            for r in 0..<section.rows.count {
  1.3203 +//                let row = section.rows[r]
  1.3204 +//                if row === cellViewModel {
  1.3205 +//                    return IndexPath(row: r, section: s)
  1.3206 +//                }
  1.3207 +//            }
  1.3208 +//        }
  1.3209 +//        return nil
  1.3210 +//    }
  1.3211 +//
  1.3212 +//    private func assureOutboxExists() {
  1.3213 +//        if outbox == nil {
  1.3214 +//            let createe = Folder(name: "outbox", parent: nil, account: account, folderType: .outbox)
  1.3215 +//            createe.save()
  1.3216 +//        }
  1.3217 +//        XCTAssertNotNil(outbox)
  1.3218 +//    }
  1.3219 +//
  1.3220 +//    private func assureDraftsExists() {
  1.3221 +//        if drafts == nil {
  1.3222 +//            let createe = Folder(name: "drafts",
  1.3223 +//                                 parent: nil,
  1.3224 +//                                 account: account,
  1.3225 +//                                 folderType: .drafts)
  1.3226 +//            createe.save()
  1.3227 +//        }
  1.3228 +//        XCTAssertNotNil(drafts)
  1.3229 +//    }
  1.3230 +//
  1.3231 +//    private func assureSentExists() {
  1.3232 +//        if sent == nil {
  1.3233 +//            let createe = Folder(name: "sent",
  1.3234 +//                                 parent: nil,
  1.3235 +//                                 account: account,
  1.3236 +//                                 folderType: .sent)
  1.3237 +//            createe.save()
  1.3238 +//        }
  1.3239 +//        XCTAssertNotNil(sent)
  1.3240 +//    }
  1.3241 +//
  1.3242 +//    private func assertShowKeepInOutbox(forMessageInfolderOfType type: FolderType) {
  1.3243 +//        let msg = message(inFolderOfType: type)
  1.3244 +//        assert(originalMessage: msg,
  1.3245 +//               contentChangedMustBeCalled: false,
  1.3246 +//               focusSwitchedMustBeCalled: false,
  1.3247 +//               validatedStateChangedMustBeCalled: false,
  1.3248 +//               modelChangedMustBeCalled: false,
  1.3249 +//               sectionChangedMustBeCalled: false,
  1.3250 +//               colorBatchNeedsUpdateMustBeCalled: false,
  1.3251 +//               hideSuggestionsMustBeCalled: false,
  1.3252 +//               showSuggestionsMustBeCalled: false,
  1.3253 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3254 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3255 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3256 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3257 +//               didComposeNewMailMustBeCalled: false,
  1.3258 +//               didModifyMessageMustBeCalled: false,
  1.3259 +//               didDeleteMessageMustBeCalled: false)
  1.3260 +//        let testee = vm?.showKeepInOutbox
  1.3261 +//        XCTAssertEqual(testee, type == .outbox)
  1.3262 +//        waitForExpectations(timeout: UnitTestUtils.waitTime)
  1.3263 +//    }
  1.3264 +//
  1.3265 +//    private func assertRecipientCellViewModelDidChangeRecipients(
  1.3266 +//        fieldType type: RecipientCellViewModel.FieldType) {
  1.3267 +//        let secondAccount = SecretTestData().createWorkingAccount(number: 1)
  1.3268 +//        secondAccount.save()
  1.3269 +//        let om = draftMessage(bccSet: true, attachmentsSet: false)
  1.3270 +//        assert(originalMessage: om,
  1.3271 +//               contentChangedMustBeCalled: false,
  1.3272 +//               focusSwitchedMustBeCalled: false,
  1.3273 +//               validatedStateChangedMustBeCalled: true,
  1.3274 +//               modelChangedMustBeCalled: false,
  1.3275 +//               sectionChangedMustBeCalled: false,
  1.3276 +//               colorBatchNeedsUpdateMustBeCalled: true,
  1.3277 +//               hideSuggestionsMustBeCalled: false,
  1.3278 +//               showSuggestionsMustBeCalled: false,
  1.3279 +//               showMediaAttachmentPickerMustBeCalled: false,
  1.3280 +//               hideMediaAttachmentPickerMustBeCalled: false,
  1.3281 +//               showDocumentAttachmentPickerMustBeCalled: false,
  1.3282 +//               documentAttachmentPickerDonePickerCalled: false,
  1.3283 +//               didComposeNewMailMustBeCalled: false,
  1.3284 +//               didModifyMessageMustBeCalled: false,
  1.3285 +//               didDeleteMessageMustBeCalled: false)
  1.3286 +//        guard let recipientVm = recipientCellViewModel(type: type) else {
  1.3287 +//            XCTFail()
  1.3288 +//            return
  1.3289 +//        }
  1.3290 +//
  1.3291 +//        let beforeCount: Int
  1.3292 +//        switch type {
  1.3293 +//        case .to:
  1.3294 +//            beforeCount = vm?.state.toRecipients.count ?? -2
  1.3295 +//        case .cc:
  1.3296 +//            beforeCount = vm?.state.ccRecipients.count ?? -2
  1.3297 +//        case .bcc:
  1.3298 +//            beforeCount = vm?.state.bccRecipients.count ?? -2
  1.3299 +//        }
  1.3300 +//
  1.3301 +//        let newRecipients = [account.user, secondAccount.user]
  1.3302 +//        vm?.recipientCellViewModel(recipientVm, didChangeRecipients: newRecipients)
  1.3303 +//
  1.3304 +//        let afterCount: Int
  1.3305 +//        switch type {
  1.3306 +//        case .to:
  1.3307 +//            afterCount = vm?.state.toRecipients.count ?? -2
  1.3308 +//        case .cc:
  1.3309 +//            afterCount = vm?.state.ccRecipients.count ?? -2
  1.3310 +//        case .bcc:
  1.3311 +//            afterCount = vm?.state.bccRecipients.count ?? -2
  1.3312 +//        }
  1.3313 +//        XCTAssertNotEqual(afterCount, beforeCount)
  1.3314 +//        XCTAssertEqual(afterCount, newRecipients.count)
  1.3315 +//        waitForExpectations(timeout: UnitTestUtils.asyncWaitTime) // Async calls involved (get pEp color)
  1.3316 +//    }
  1.3317 +//
  1.3318 +//    private func viewmodel(ofType vmType: AnyClass) -> CellViewModel? {
  1.3319 +//        guard let sections = vm?.sections else {
  1.3320 +//            XCTFail()
  1.3321 +//            return nil
  1.3322 +//        }
  1.3323 +//        for section in sections {
  1.3324 +//            guard let vm = section.rows.first else {
  1.3325 +//                continue
  1.3326 +//            }
  1.3327 +//            if type(of: vm) == vmType {
  1.3328 +//                return  section.rows.first
  1.3329 +//            }
  1.3330 +//        }
  1.3331 +//        return nil
  1.3332 +//    }
  1.3333 +//
  1.3334 +//    private func draftMessage(bccSet: Bool = false, attachmentsSet: Bool = false) -> Message {
  1.3335 +//        return message(inFolderOfType: .drafts, bccSet: bccSet, attachmentsSet: attachmentsSet)
  1.3336 +//    }
  1.3337 +//
  1.3338 +//    private func message(inFolderOfType parentType: FolderType = .inbox,
  1.3339 +//                         bccSet: Bool = false,
  1.3340 +//                         attachmentsSet: Bool = false) -> Message {
  1.3341 +//        let folder = Folder(name: "\(parentType)",
  1.3342 +//            parent: parentType == .inbox ? nil : account.firstFolder(ofType: .inbox),
  1.3343 +//            account: account,
  1.3344 +//            folderType: parentType)
  1.3345 +//        folder.save()
  1.3346 +//        let createe = Message(uuid: UUID().uuidString, parentFolder: folder)
  1.3347 +//        if bccSet {
  1.3348 +//            createe.replaceBcc(with: [account.user])
  1.3349 +//        }
  1.3350 +//        if attachmentsSet {
  1.3351 +//            let att = attachment()
  1.3352 +//            createe.replaceAttachments(with: [att])
  1.3353 +//        }
  1.3354 +//        createe.save()
  1.3355 +//        return createe
  1.3356 +//    }
  1.3357 +//
  1.3358 +//    private func attachment(
  1.3359 +//        ofType type: Attachment.ContentDispositionType = .attachment ) -> Attachment {
  1.3360 +//        let imageFileName = "PorpoiseGalaxy_HubbleFraile_960.jpg"
  1.3361 +//        guard
  1.3362 +//            let imageData = TestUtil.loadData(fileName: imageFileName),
  1.3363 +//            let image = UIImage(data: imageData) else {
  1.3364 +//            XCTFail()
  1.3365 +//            return Attachment(data: nil, mimeType: "meh", contentDisposition: .attachment)
  1.3366 +//        }
  1.3367 +//        let createe: Attachment
  1.3368 +//        if type == .inline {
  1.3369 +//            createe = Attachment(data: image.jpegData(compressionQuality: 1.0), mimeType: "image/jpg", contentDisposition: type)
  1.3370 +//            createe.image = image
  1.3371 +//        } else {
  1.3372 +//            createe = Attachment(data: imageData,
  1.3373 +//                                 mimeType: "video/quicktime",
  1.3374 +//                                 contentDisposition: type)
  1.3375 +//        }
  1.3376 +//        createe.fileName = UUID().uuidString
  1.3377 +//        return createe
  1.3378 +//    }
  1.3379 +//
  1.3380 +//    private func assertSections(forVMIniitaliizedWith originalMessage: Message,
  1.3381 +//                                expectBccWrapperSectionExists: Bool = true,
  1.3382 +//                                expectAccountSectionExists: Bool = false,
  1.3383 +//                                expectAttachmentSectionExists: Bool = false) {
  1.3384 +//        let vm = ComposeViewModel(resultDelegate: nil,
  1.3385 +//                                  composeMode: .normal,
  1.3386 +//                                  prefilledTo: nil,
  1.3387 +//                                  originalMessage: originalMessage)
  1.3388 +//        let testee = vm.sections
  1.3389 +//        let recipientSection = 1
  1.3390 +//        let bccWrapperSection = expectBccWrapperSectionExists ? 1 : 0
  1.3391 +//        let accountSelectorSection = expectAccountSectionExists ? 1 : 0
  1.3392 +//        let subjectSection = 1
  1.3393 +//        let bodySection = 1
  1.3394 +//        let attachmentSection = expectAttachmentSectionExists ? 1 : 0
  1.3395 +//        XCTAssertEqual(testee.count,  recipientSection +
  1.3396 +//            bccWrapperSection +
  1.3397 +//            accountSelectorSection +
  1.3398 +//            subjectSection +
  1.3399 +//            bodySection +
  1.3400 +//            attachmentSection)
  1.3401 +//    }
  1.3402 +//
  1.3403 +//    private func assert(composeMode: ComposeUtil.ComposeMode? = nil,
  1.3404 +//                        prefilledTo: Identity? = nil,
  1.3405 +//                        originalMessage: Message? = nil,
  1.3406 +//                        contentChangedMustBeCalled: Bool? = nil,/*TestDelegate realted params*/
  1.3407 +//                        expectedContentChangedIndexPath: IndexPath? = nil,
  1.3408 +//                        focusSwitchedMustBeCalled: Bool? = nil,
  1.3409 +//                        validatedStateChangedMustBeCalled: Bool? = nil,
  1.3410 +//                        expectedIsValidated: Bool? = nil,
  1.3411 +//                        modelChangedMustBeCalled: Bool? = nil,
  1.3412 +//                        sectionChangedMustBeCalled: Bool? = nil,
  1.3413 +//                        expectedSection: Int? = nil,
  1.3414 +//                        colorBatchNeedsUpdateMustBeCalled: Bool? = nil,
  1.3415 +//                        expectedRating: PEPRating? = nil,
  1.3416 +//                        expectedProtectionEnabled: Bool? = nil,
  1.3417 +//                        hideSuggestionsMustBeCalled: Bool? = nil,
  1.3418 +//                        showSuggestionsMustBeCalled: Bool? = nil,
  1.3419 +//                        expectedShowSuggestionsIndexPath: IndexPath? = nil,
  1.3420 +//                        suggestionsScrollFocusChangedMustBeCalled: Bool? = nil,
  1.3421 +//                        expectedNewSuggestionsScrollFocusIsVisible: Bool? = nil,
  1.3422 +//                        showMediaAttachmentPickerMustBeCalled: Bool? = nil,
  1.3423 +//                        hideMediaAttachmentPickerMustBeCalled: Bool? = nil,
  1.3424 +//                        showDocumentAttachmentPickerMustBeCalled: Bool? = nil,
  1.3425 +//                        documentAttachmentPickerDonePickerCalled: Bool? = nil,
  1.3426 +//                        didComposeNewMailMustBeCalled: Bool? = nil,/*TestResultDelegate realted params*/
  1.3427 +//                        didModifyMessageMustBeCalled: Bool? = nil,
  1.3428 +//                        didDeleteMessageMustBeCalled: Bool? = nil) {
  1.3429 +//        // TestDelegate
  1.3430 +//        var expContentChangedCalled: XCTestExpectation? = nil
  1.3431 +//        if let exp = contentChangedMustBeCalled {
  1.3432 +//            expContentChangedCalled =
  1.3433 +//                expectation(description: "expContentChangedCalled")
  1.3434 +//            expContentChangedCalled?.isInverted = !exp
  1.3435 +//        }
  1.3436 +//
  1.3437 +//        var expFocusSwitchedCalled: XCTestExpectation? = nil
  1.3438 +//        if let exp = focusSwitchedMustBeCalled {
  1.3439 +//            expFocusSwitchedCalled =
  1.3440 +//                expectation(description: "expFocusSwitchedCalled")
  1.3441 +//            expFocusSwitchedCalled?.isInverted = !exp
  1.3442 +//        }
  1.3443 +//
  1.3444 +//        var expValidatedStateChangedCalled: XCTestExpectation? = nil
  1.3445 +//        if let exp = validatedStateChangedMustBeCalled {
  1.3446 +//            expValidatedStateChangedCalled =
  1.3447 +//                expectation(description: "expValidatedStateChangedCalled")
  1.3448 +//            expValidatedStateChangedCalled?.isInverted = !exp
  1.3449 +//        }
  1.3450 +//
  1.3451 +//        var expModelChangedCalled: XCTestExpectation? = nil
  1.3452 +//        if let exp = modelChangedMustBeCalled {
  1.3453 +//            expModelChangedCalled =
  1.3454 +//                expectation(description: "expModelChangedCalled")
  1.3455 +//            expModelChangedCalled?.isInverted = !exp
  1.3456 +//        }
  1.3457 +//
  1.3458 +//        var expSectionChangedCalled: XCTestExpectation? = nil
  1.3459 +//        if let exp = sectionChangedMustBeCalled {
  1.3460 +//            expSectionChangedCalled =
  1.3461 +//                expectation(description: "expSectionChangedCalled")
  1.3462 +//            expSectionChangedCalled?.isInverted = !exp
  1.3463 +//            // Overfulfill is espected. When unwrapping CcBcc fields, wrapper section AND
  1.3464 +//            // recipinets section changes.
  1.3465 +//            expSectionChangedCalled?.assertForOverFulfill = false
  1.3466 +//        }
  1.3467 +//
  1.3468 +//        var expColorBatchNeedsUpdateCalled: XCTestExpectation? = nil
  1.3469 +//        if let exp = colorBatchNeedsUpdateMustBeCalled {
  1.3470 +//            expColorBatchNeedsUpdateCalled =
  1.3471 +//                expectation(description: "expColorBatchNeedsUpdateCalled")
  1.3472 +//            expColorBatchNeedsUpdateCalled?.isInverted = !exp
  1.3473 +//        }
  1.3474 +//
  1.3475 +//        var expHideSuggestionsCalled: XCTestExpectation? = nil
  1.3476 +//        if let exp = hideSuggestionsMustBeCalled {
  1.3477 +//            expHideSuggestionsCalled =
  1.3478 +//                expectation(description: "expHideSuggestionsCalled")
  1.3479 +//            expHideSuggestionsCalled?.isInverted = !exp
  1.3480 +//        }
  1.3481 +//
  1.3482 +//        var expSuggestionsScrollFocusChangedCalled: XCTestExpectation? = nil
  1.3483 +//        if let exp = suggestionsScrollFocusChangedMustBeCalled {
  1.3484 +//            expSuggestionsScrollFocusChangedCalled =
  1.3485 +//                expectation(description: "expSuggestionsScrollFocusChangedCalled")
  1.3486 +//            expSuggestionsScrollFocusChangedCalled?.isInverted = !exp
  1.3487 +//        }
  1.3488 +//
  1.3489 +//        var expShowSuggestionsCalled: XCTestExpectation? = nil
  1.3490 +//        if let exp = showSuggestionsMustBeCalled {
  1.3491 +//            expShowSuggestionsCalled =
  1.3492 +//                expectation(description: "expShowSuggestionsCalled")
  1.3493 +//            expShowSuggestionsCalled?.isInverted = !exp
  1.3494 +//        }
  1.3495 +//
  1.3496 +//        var expShowMediaAttachmentPickerCalled: XCTestExpectation? = nil
  1.3497 +//        if let exp = showMediaAttachmentPickerMustBeCalled {
  1.3498 +//            expShowMediaAttachmentPickerCalled =
  1.3499 +//                expectation(description: "expShowMediaAttachmentPickerCalled")
  1.3500 +//            expShowMediaAttachmentPickerCalled?.isInverted = !exp
  1.3501 +//        }
  1.3502 +//
  1.3503 +//        var expHideMediaAttachmentPickerCalled: XCTestExpectation? = nil
  1.3504 +//        if let exp = hideMediaAttachmentPickerMustBeCalled {
  1.3505 +//            expHideMediaAttachmentPickerCalled =
  1.3506 +//                expectation(description: "expHideMediaAttachmentPickerCalled")
  1.3507 +//            expHideMediaAttachmentPickerCalled?.isInverted = !exp
  1.3508 +//        }
  1.3509 +//
  1.3510 +//        var expShowDocumentAttachmentPickerCalled: XCTestExpectation? = nil
  1.3511 +//        if let exp = showDocumentAttachmentPickerMustBeCalled {
  1.3512 +//            expShowDocumentAttachmentPickerCalled =
  1.3513 +//                expectation(description: "expShowDocumentAttachmentPickerCalled")
  1.3514 +//            expShowDocumentAttachmentPickerCalled?.isInverted = !exp
  1.3515 +//        }
  1.3516 +//
  1.3517 +//        var expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation? = nil
  1.3518 +//        if let exp = documentAttachmentPickerDonePickerCalled {
  1.3519 +//            expDocumentAttachmentPickerDonePickerCalled =
  1.3520 +//                expectation(description: "expDocumentAttachmentPickerDonePickerCalled")
  1.3521 +//            expDocumentAttachmentPickerDonePickerCalled?.isInverted = !exp
  1.3522 +//        }
  1.3523 +//
  1.3524 +//        testDelegate =
  1.3525 +//            TestDelegate(expContentChangedCalled: expContentChangedCalled,
  1.3526 +//                         expectedContentChangedIndexPath: expectedContentChangedIndexPath,
  1.3527 +//                         expFocusSwitchedCalled: expFocusSwitchedCalled,
  1.3528 +//                         expValidatedStateChangedCalled: expValidatedStateChangedCalled,
  1.3529 +//                         expectedIsValidated: expectedIsValidated,
  1.3530 +//                         expModelChangedCalled: expModelChangedCalled,
  1.3531 +//                         expSectionChangedCalled: expSectionChangedCalled,
  1.3532 +//                         expectedSection: expectedSection,
  1.3533 +//                         expColorBatchNeedsUpdateCalled: nil,
  1.3534 +//                         expectedRating: expectedRating,
  1.3535 +//                         expectedProtectionEnabled: expectedProtectionEnabled,
  1.3536 +//                         expHideSuggestionsCalled: expHideSuggestionsCalled,
  1.3537 +//                         expShowSuggestionsCalled: expShowSuggestionsCalled,
  1.3538 +//                         expSuggestionsScrollFocusChangedCalled: expSuggestionsScrollFocusChangedCalled,
  1.3539 +//                         expectedScrollFocus: expectedNewSuggestionsScrollFocusIsVisible,
  1.3540 +//                         expectedShowSuggestionsIndexPath: expectedShowSuggestionsIndexPath,
  1.3541 +//                         expShowMediaAttachmentPickerCalled: expShowMediaAttachmentPickerCalled,
  1.3542 +//                         expHideMediaAttachmentPickerCalled: expHideMediaAttachmentPickerCalled,
  1.3543 +//                         expShowDocumentAttachmentPickerCalled: expShowDocumentAttachmentPickerCalled,
  1.3544 +//                         expDocumentAttachmentPickerDonePickerCalled:
  1.3545 +//                expDocumentAttachmentPickerDonePickerCalled)
  1.3546 +//
  1.3547 +//        // TestResultDelegate
  1.3548 +//
  1.3549 +//        var expDidComposeNewMailCalled: XCTestExpectation? = nil
  1.3550 +//        if let exp = didComposeNewMailMustBeCalled {
  1.3551 +//            expDidComposeNewMailCalled =
  1.3552 +//                expectation(description: "expDidComposeNewMailCalled")
  1.3553 +//            expDidComposeNewMailCalled?.isInverted = !exp
  1.3554 +//        }
  1.3555 +//
  1.3556 +//        var expDidModifyMessageCalled: XCTestExpectation? = nil
  1.3557 +//        if let exp = didModifyMessageMustBeCalled {
  1.3558 +//            expDidModifyMessageCalled =
  1.3559 +//                expectation(description: "expDidModifyMessageCalled")
  1.3560 +//            expDidModifyMessageCalled?.isInverted = !exp
  1.3561 +//        }
  1.3562 +//
  1.3563 +//        var expDidDeleteMessageCalled: XCTestExpectation? = nil
  1.3564 +//        if let exp = didDeleteMessageMustBeCalled {
  1.3565 +//            expDidDeleteMessageCalled =
  1.3566 +//                expectation(description: "expDidDeleteMessageCalled")
  1.3567 +//            expDidDeleteMessageCalled?.isInverted = !exp
  1.3568 +//            expDidDeleteMessageCalled?.assertForOverFulfill = false
  1.3569 +//        }
  1.3570 +//
  1.3571 +//        testResultDelegate =
  1.3572 +//            TestResultDelegate(expDidComposeNewMailCalled: expDidComposeNewMailCalled,
  1.3573 +//                               expDidModifyMessageCalled: expDidModifyMessageCalled,
  1.3574 +//                               expDidDeleteMessageCalled: expDidDeleteMessageCalled)
  1.3575 +//        vm = ComposeViewModel(resultDelegate: testResultDelegate,
  1.3576 +//                              composeMode: composeMode,
  1.3577 +//                              prefilledTo: prefilledTo,
  1.3578 +//                              originalMessage: originalMessage)
  1.3579 +//        vm?.delegate = testDelegate
  1.3580 +//        // Set _after_ the delegate is set because at this point we are not interested in callbacks
  1.3581 +//        // triggered by setting the delegate.
  1.3582 +//        testDelegate?.expColorBatchNeedsUpdateCalled = expColorBatchNeedsUpdateCalled
  1.3583 +//    }
  1.3584 +//
  1.3585 +//    private class TestResultDelegate: ComposeViewModelResultDelegate {
  1.3586 +//        let expDidComposeNewMailCalled: XCTestExpectation?
  1.3587 +//        let expDidModifyMessageCalled: XCTestExpectation?
  1.3588 +//        let expDidDeleteMessageCalled: XCTestExpectation?
  1.3589 +//
  1.3590 +//        init(expDidComposeNewMailCalled: XCTestExpectation? = nil,
  1.3591 +//             expDidModifyMessageCalled: XCTestExpectation? = nil,
  1.3592 +//             expDidDeleteMessageCalled: XCTestExpectation? = nil) {
  1.3593 +//            self.expDidComposeNewMailCalled = expDidComposeNewMailCalled
  1.3594 +//            self.expDidModifyMessageCalled = expDidModifyMessageCalled
  1.3595 +//            self.expDidDeleteMessageCalled = expDidDeleteMessageCalled
  1.3596 +//
  1.3597 +//        }
  1.3598 +//
  1.3599 +//        func composeViewModelDidComposeNewMail(message: Message) {
  1.3600 +//            guard let exp = expDidComposeNewMailCalled else {
  1.3601 +//                // We ignore called or not
  1.3602 +//                return
  1.3603 +//            }
  1.3604 +//            exp.fulfill()
  1.3605 +//        }
  1.3606 +//
  1.3607 +//        func composeViewModelDidModifyMessage(message: Message) {
  1.3608 +//            guard let exp = expDidModifyMessageCalled else {
  1.3609 +//                // We ignore called or not
  1.3610 +//                return
  1.3611 +//            }
  1.3612 +//            exp.fulfill()
  1.3613 +//        }
  1.3614 +//
  1.3615 +//        func composeViewModelDidDeleteMessage(message: Message) {
  1.3616 +//            guard let exp = expDidDeleteMessageCalled else {
  1.3617 +//                // We ignore called or not
  1.3618 +//                return
  1.3619 +//            }
  1.3620 +//            exp.fulfill()
  1.3621 +//        }
  1.3622 +//    }
  1.3623 +//
  1.3624 +//    private class TestDelegate:  ComposeViewModelDelegate {
  1.3625 +//        let expContentChangedCalled: XCTestExpectation?
  1.3626 +//        let expectedContentChangedIndexPath: IndexPath?
  1.3627 +//
  1.3628 +//        let expFocusSwitchedCalled: XCTestExpectation?
  1.3629 +//
  1.3630 +//        let expValidatedStateChangedCalled: XCTestExpectation?
  1.3631 +//        let expectedIsValidated: Bool?
  1.3632 +//
  1.3633 +//        let expModelChangedCalled: XCTestExpectation?
  1.3634 +//
  1.3635 +//        let expSectionChangedCalled: XCTestExpectation?
  1.3636 +//        let expectedSection: Int?
  1.3637 +//
  1.3638 +//        var expColorBatchNeedsUpdateCalled: XCTestExpectation?
  1.3639 +//        let expectedRating: PEPRating?
  1.3640 +//        let expectedProtectionEnabled: Bool?
  1.3641 +//
  1.3642 +//        let expHideSuggestionsCalled: XCTestExpectation?
  1.3643 +//
  1.3644 +//        let expShowSuggestionsCalled: XCTestExpectation?
  1.3645 +//        let expectedShowSuggestionsIndexPath: IndexPath?
  1.3646 +//
  1.3647 +//        let expSuggestionsScrollFocusChangedCalled: XCTestExpectation?
  1.3648 +//        let expectedScrollFocus: Bool?
  1.3649 +//
  1.3650 +//        let expShowMediaAttachmentPickerCalled: XCTestExpectation?
  1.3651 +//
  1.3652 +//        let expHideMediaAttachmentPickerCalled: XCTestExpectation?
  1.3653 +//
  1.3654 +//        let expShowDocumentAttachmentPickerCalled: XCTestExpectation?
  1.3655 +//
  1.3656 +//        let expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation?
  1.3657 +//
  1.3658 +//        init(expContentChangedCalled: XCTestExpectation?,
  1.3659 +//             expectedContentChangedIndexPath: IndexPath?,
  1.3660 +//             expFocusSwitchedCalled: XCTestExpectation?,
  1.3661 +//             expValidatedStateChangedCalled: XCTestExpectation?,
  1.3662 +//             expectedIsValidated: Bool?,
  1.3663 +//             expModelChangedCalled: XCTestExpectation?,
  1.3664 +//             expSectionChangedCalled: XCTestExpectation?,
  1.3665 +//             expectedSection: Int?,
  1.3666 +//             expColorBatchNeedsUpdateCalled: XCTestExpectation?,
  1.3667 +//             expectedRating: PEPRating?,
  1.3668 +//             expectedProtectionEnabled: Bool?,
  1.3669 +//             expHideSuggestionsCalled: XCTestExpectation?,
  1.3670 +//             expShowSuggestionsCalled: XCTestExpectation?,
  1.3671 +//             expSuggestionsScrollFocusChangedCalled: XCTestExpectation?,
  1.3672 +//             expectedScrollFocus: Bool?,
  1.3673 +//             expectedShowSuggestionsIndexPath: IndexPath?,
  1.3674 +//             expShowMediaAttachmentPickerCalled: XCTestExpectation?,
  1.3675 +//             expHideMediaAttachmentPickerCalled: XCTestExpectation?,
  1.3676 +//             expShowDocumentAttachmentPickerCalled: XCTestExpectation?,
  1.3677 +//             expDocumentAttachmentPickerDonePickerCalled: XCTestExpectation?) {
  1.3678 +//            self.expContentChangedCalled = expContentChangedCalled
  1.3679 +//            self.expectedContentChangedIndexPath = expectedContentChangedIndexPath
  1.3680 +//            self.expFocusSwitchedCalled = expFocusSwitchedCalled
  1.3681 +//            self.expValidatedStateChangedCalled = expValidatedStateChangedCalled
  1.3682 +//            self.expectedIsValidated = expectedIsValidated
  1.3683 +//            self.expModelChangedCalled = expModelChangedCalled
  1.3684 +//            self.expSectionChangedCalled = expSectionChangedCalled
  1.3685 +//            self.expectedSection = expectedSection
  1.3686 +//            self.expColorBatchNeedsUpdateCalled =  expColorBatchNeedsUpdateCalled
  1.3687 +//            self.expectedRating = expectedRating
  1.3688 +//            self.expectedProtectionEnabled = expectedProtectionEnabled
  1.3689 +//            self.expHideSuggestionsCalled = expHideSuggestionsCalled
  1.3690 +//            self.expShowSuggestionsCalled = expShowSuggestionsCalled
  1.3691 +//            self.expSuggestionsScrollFocusChangedCalled = expSuggestionsScrollFocusChangedCalled
  1.3692 +//            self.expectedScrollFocus = expectedScrollFocus
  1.3693 +//            self.expectedShowSuggestionsIndexPath = expectedShowSuggestionsIndexPath
  1.3694 +//            self.expShowMediaAttachmentPickerCalled = expShowMediaAttachmentPickerCalled
  1.3695 +//            self.expHideMediaAttachmentPickerCalled = expHideMediaAttachmentPickerCalled
  1.3696 +//            self.expShowDocumentAttachmentPickerCalled = expShowDocumentAttachmentPickerCalled
  1.3697 +//            self.expDocumentAttachmentPickerDonePickerCalled =
  1.3698 +//            expDocumentAttachmentPickerDonePickerCalled
  1.3699 +//        }
  1.3700 +//
  1.3701 +//        func contentChanged(inRowAt indexPath: IndexPath) {
  1.3702 +//            guard let exp = expContentChangedCalled else {
  1.3703 +//                // We ignore called or not
  1.3704 +//                return
  1.3705 +//            }
  1.3706 +//            exp.fulfill()
  1.3707 +//            if let expected = expectedContentChangedIndexPath {
  1.3708 +//                XCTAssertEqual(indexPath, expected)
  1.3709 +//            }
  1.3710 +//        }
  1.3711 +//
  1.3712 +//        func focusSwitched() {
  1.3713 +//            guard let exp = expFocusSwitchedCalled else {
  1.3714 +//                // We ignore called or not
  1.3715 +//                return
  1.3716 +//            }
  1.3717 +//            exp.fulfill()
  1.3718 +//        }
  1.3719 +//
  1.3720 +//        func validatedStateChanged(to isValidated: Bool) {
  1.3721 +//            guard let exp = expValidatedStateChangedCalled else {
  1.3722 +//                // We ignore called or not
  1.3723 +//                return
  1.3724 +//            }
  1.3725 +//            exp.fulfill()
  1.3726 +//            if let expected = expectedIsValidated {
  1.3727 +//                XCTAssertEqual(isValidated, expected)
  1.3728 +//            }
  1.3729 +//        }
  1.3730 +//
  1.3731 +//        func modelChanged() {
  1.3732 +//            guard let exp = expModelChangedCalled else {
  1.3733 +//                // We ignore called or not
  1.3734 +//                return
  1.3735 +//            }
  1.3736 +//            exp.fulfill()
  1.3737 +//        }
  1.3738 +//
  1.3739 +//        func sectionChanged(section: Int) {
  1.3740 +//            guard let exp = expSectionChangedCalled else {
  1.3741 +//                // We ignore called or not
  1.3742 +//                return
  1.3743 +//            }
  1.3744 +//            exp.fulfill()
  1.3745 +//            if let expected = expectedSection {
  1.3746 +//                XCTAssertEqual(section, expected)
  1.3747 +//            }
  1.3748 +//        }
  1.3749 +//
  1.3750 +//        func colorBatchNeedsUpdate(for rating: PEPRating, protectionEnabled: Bool) {
  1.3751 +//            guard let exp = expColorBatchNeedsUpdateCalled else {
  1.3752 +//                // We ignore called or not
  1.3753 +//                return
  1.3754 +//            }
  1.3755 +//            exp.fulfill()
  1.3756 +//            if let expected = expectedRating {
  1.3757 +//                XCTAssertEqual(rating, expected)
  1.3758 +//            }
  1.3759 +//            if let expectedProtection = expectedProtectionEnabled {
  1.3760 +//                XCTAssertEqual(protectionEnabled, expectedProtection)
  1.3761 +//            }
  1.3762 +//        }
  1.3763 +//
  1.3764 +//        func hideSuggestions() {
  1.3765 +//            guard let exp = expHideSuggestionsCalled else {
  1.3766 +//                // We ignore called or not
  1.3767 +//                return
  1.3768 +//            }
  1.3769 +//            exp.fulfill()
  1.3770 +//        }
  1.3771 +//
  1.3772 +//        func showSuggestions(forRowAt indexPath: IndexPath) {
  1.3773 +//            guard let exp = expShowSuggestionsCalled else {
  1.3774 +//                // We ignore called or not
  1.3775 +//                return
  1.3776 +//            }
  1.3777 +//            exp.fulfill()
  1.3778 +//            if let expected = expectedShowSuggestionsIndexPath {
  1.3779 +//                XCTAssertEqual(indexPath, expected)
  1.3780 +//            }
  1.3781 +//        }
  1.3782 +//
  1.3783 +//        func suggestions(haveScrollFocus: Bool) {
  1.3784 +//            guard let exp = expSuggestionsScrollFocusChangedCalled else {
  1.3785 +//                // We ignore called or not
  1.3786 +//                return
  1.3787 +//            }
  1.3788 +//            exp.fulfill()
  1.3789 +//            if let expected = expectedScrollFocus {
  1.3790 +//                XCTAssertEqual(haveScrollFocus, expected)
  1.3791 +//            }
  1.3792 +//        }
  1.3793 +//
  1.3794 +//        func showMediaAttachmentPicker() {
  1.3795 +//            guard let exp = expShowMediaAttachmentPickerCalled else {
  1.3796 +//                // We ignore called or not
  1.3797 +//                return
  1.3798 +//            }
  1.3799 +//            exp.fulfill()
  1.3800 +//        }
  1.3801 +//
  1.3802 +//        func hideMediaAttachmentPicker() {
  1.3803 +//            guard let exp = expHideMediaAttachmentPickerCalled else {
  1.3804 +//                // We ignore called or not
  1.3805 +//                return
  1.3806 +//            }
  1.3807 +//            exp.fulfill()
  1.3808 +//        }
  1.3809 +//
  1.3810 +//        func showDocumentAttachmentPicker() {
  1.3811 +//            guard let exp = expShowDocumentAttachmentPickerCalled else {
  1.3812 +//                // We ignore called or not
  1.3813 +//                return
  1.3814 +//            }
  1.3815 +//            exp.fulfill()
  1.3816 +//        }
  1.3817 +//
  1.3818 +//        func documentAttachmentPickerDone() {
  1.3819 +//            guard let exp = expDocumentAttachmentPickerDonePickerCalled else {
  1.3820 +//                // We ignore called or not
  1.3821 +//                return
  1.3822 +//            }
  1.3823 +//            exp.fulfill()
  1.3824 +//        }
  1.3825 +//    }
  1.3826 +//
  1.3827 +//    // MARK: - DocumentAttachmentPickerViewModel
  1.3828 +//    class TestDocumentAttachmentPickerViewModel: DocumentAttachmentPickerViewModel {} // Dummy to pass something
  1.3829 +//
  1.3830 +//    // MARK: - MediaAttachmentPickerProviderViewModel
  1.3831 +//    class TestMediaAttachmentPickerProviderViewModel: MediaAttachmentPickerProviderViewModel {} // Dummy to pass something
  1.3832 +//}