2023-06-29 18:26:45 +02:00
|
|
|
import o from "@tutao/otest"
|
2022-01-07 15:58:30 +01:00
|
|
|
// @ts-ignore[untyped-import]
|
2022-05-12 16:51:15 +02:00
|
|
|
import en from "../../../src/translations/en.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import type { UserController } from "../../../src/api/main/UserController.js"
|
|
|
|
import type { LoginController } from "../../../src/api/main/LoginController.js"
|
|
|
|
import { MailboxDetail, MailModel } from "../../../src/mail/model/MailModel.js"
|
2022-04-28 17:32:27 +02:00
|
|
|
import {
|
|
|
|
Contact,
|
|
|
|
ContactListTypeRef,
|
|
|
|
ContactTypeRef,
|
|
|
|
ConversationEntryTypeRef,
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
createBody,
|
2022-04-28 17:32:27 +02:00
|
|
|
createContact,
|
|
|
|
createConversationEntry,
|
|
|
|
createMail,
|
|
|
|
createMailAddress,
|
|
|
|
createMailBox,
|
2022-12-27 15:37:40 +01:00
|
|
|
createMailboxGroupRoot,
|
|
|
|
createMailboxProperties,
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
createMailDetails,
|
2022-04-28 17:32:27 +02:00
|
|
|
createTutanotaProperties,
|
|
|
|
CustomerAccountCreateDataTypeRef,
|
|
|
|
MailTypeRef,
|
2022-12-27 15:37:40 +01:00
|
|
|
NotificationMailTypeRef,
|
2022-04-28 17:32:27 +02:00
|
|
|
} from "../../../src/api/entities/tutanota/TypeRefs.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { ContactModel } from "../../../src/contacts/model/ContactModel.js"
|
|
|
|
import { assertThrows, verify } from "@tutao/tutanota-test-utils"
|
|
|
|
import { downcast, isSameTypeRef } from "@tutao/tutanota-utils"
|
|
|
|
import { SendMailModel, TOO_MANY_VISIBLE_RECIPIENTS } from "../../../src/mail/editor/SendMailModel.js"
|
2022-04-28 17:32:27 +02:00
|
|
|
import {
|
|
|
|
ChallengeTypeRef,
|
|
|
|
createCustomer,
|
|
|
|
createGroup,
|
|
|
|
createGroupInfo,
|
|
|
|
createGroupMembership,
|
|
|
|
createUser,
|
|
|
|
CustomerTypeRef,
|
2022-12-27 15:37:40 +01:00
|
|
|
UserTypeRef,
|
2022-04-28 17:32:27 +02:00
|
|
|
} from "../../../src/api/entities/sys/TypeRefs.js"
|
2023-08-24 16:04:13 +02:00
|
|
|
import { ConversationType, GroupType, KdfType, MailMethod, OperationType } from "../../../src/api/common/TutanotaConstants.js"
|
2023-02-16 12:25:40 +01:00
|
|
|
import { lang, TranslationKey } from "../../../src/misc/LanguageViewModel.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { EventController } from "../../../src/api/main/EventController.js"
|
|
|
|
import { UserError } from "../../../src/api/main/UserError.js"
|
|
|
|
import { EntityClient } from "../../../src/api/common/EntityClient.js"
|
|
|
|
import { getContactDisplayName } from "../../../src/contacts/model/ContactUtils.js"
|
|
|
|
import { isSameId } from "../../../src/api/common/utils/EntityUtils.js"
|
2023-02-10 16:27:53 +01:00
|
|
|
import { MailFacade } from "../../../src/api/worker/facades/lazy/MailFacade.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
import { RecipientField } from "../../../src/mail/model/MailUtils.js"
|
|
|
|
import { func, instance, matchers, object, replace, when } from "testdouble"
|
|
|
|
import { RecipientsModel, ResolveMode } from "../../../src/api/main/RecipientsModel"
|
|
|
|
import { ResolvableRecipientMock } from "./ResolvableRecipientMock.js"
|
|
|
|
import { NoZoneDateProvider } from "../../../src/api/common/utils/NoZoneDateProvider.js"
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
import { MailWrapper } from "../../../src/api/common/MailWrapper.js"
|
2023-01-12 14:54:42 +01:00
|
|
|
import { FolderSystem } from "../../../src/api/common/mail/FolderSystem.js"
|
2023-08-24 16:04:13 +02:00
|
|
|
import { KdfPicker } from "../../../src/misc/KdfPicker.js"
|
2022-12-27 15:37:40 +01:00
|
|
|
|
|
|
|
const { anything, argThat } = matchers
|
2020-09-18 14:41:31 +02:00
|
|
|
|
|
|
|
type TestIdGenerator = {
|
2022-12-27 15:37:40 +01:00
|
|
|
currentIdValue: number
|
|
|
|
currentListIdValue: number
|
2022-01-07 15:58:30 +01:00
|
|
|
newId: () => Id
|
|
|
|
newListId: () => Id
|
2020-09-18 14:41:31 +02:00
|
|
|
newIdTuple: () => IdTuple
|
|
|
|
}
|
2023-06-19 17:44:21 +02:00
|
|
|
let testIdGenerator: TestIdGenerator = {
|
|
|
|
currentIdValue: 0,
|
|
|
|
currentListIdValue: 0,
|
|
|
|
|
|
|
|
newId(): Id {
|
|
|
|
return (this.currentIdValue++).toString()
|
|
|
|
},
|
|
|
|
|
|
|
|
newListId(): Id {
|
|
|
|
return (this.currentListIdValue++).toString()
|
|
|
|
},
|
|
|
|
|
|
|
|
newIdTuple(): IdTuple {
|
|
|
|
return [this.newListId(), this.newId()]
|
|
|
|
},
|
|
|
|
}
|
2020-09-18 14:41:31 +02:00
|
|
|
|
|
|
|
const EXTERNAL_ADDRESS_1 = "address1@test.com"
|
|
|
|
const EXTERNAL_ADDRESS_2 = "address2@test.com"
|
|
|
|
const DEFAULT_SENDER_FOR_TESTING = "test@tutanota.de"
|
|
|
|
const INTERNAL_RECIPIENT_1 = {
|
|
|
|
name: "test1",
|
|
|
|
address: "test1@tutanota.de",
|
2022-01-07 15:58:30 +01:00
|
|
|
contact: null,
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
|
|
|
const BODY_TEXT_1 = "lorem ipsum dolor yaddah yaddah"
|
|
|
|
const SUBJECT_LINE_1 = "Did you get that thing I sent ya"
|
|
|
|
const STRONG_PASSWORD = "@()IE!)(@FME)0-123jfDSA32SDACmmnvnvddEW"
|
|
|
|
const WEAK_PASSWORD = "123"
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2020-11-03 08:42:25 +01:00
|
|
|
o.spec("SendMailModel", function () {
|
|
|
|
o.before(function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
// we need lang initialized because the SendMailModel constructor requires some translation
|
|
|
|
lang.init(en)
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-08-24 16:04:13 +02:00
|
|
|
let mailModel: MailModel, entity: EntityClient, mailFacade: MailFacade, recipientsModel: RecipientsModel, kdfPicker: KdfPicker
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
let model: SendMailModel
|
|
|
|
|
2020-11-03 08:42:25 +01:00
|
|
|
o.beforeEach(function () {
|
2022-02-03 14:55:40 +01:00
|
|
|
entity = instance(EntityClient)
|
2022-12-27 15:37:40 +01:00
|
|
|
when(
|
|
|
|
entity.loadRoot(
|
|
|
|
argThat((typeRef) => isSameTypeRef(typeRef, ContactListTypeRef)),
|
|
|
|
anything(),
|
|
|
|
),
|
|
|
|
).thenDo(() => ({ contacts: testIdGenerator.newId() }))
|
|
|
|
when(entity.load(anything(), anything(), anything())).thenDo((typeRef, id, params) => ({ _type: typeRef, _id: id }))
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
mailModel = instance(MailModel)
|
2023-08-24 16:04:13 +02:00
|
|
|
kdfPicker = instance(KdfPicker)
|
|
|
|
when(kdfPicker.pickKdfType()).thenResolve(KdfType.Argon2id)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const contactModel = object<ContactModel>()
|
2023-08-04 13:58:36 +02:00
|
|
|
when(contactModel.getContactListId()).thenResolve("contactListId")
|
2022-02-03 14:55:40 +01:00
|
|
|
when(contactModel.searchForContact(anything())).thenResolve(null)
|
|
|
|
|
|
|
|
mailFacade = instance(MailFacade)
|
|
|
|
when(mailFacade.createDraft(anything())).thenDo(() => createMail())
|
|
|
|
when(mailFacade.updateDraft(anything())).thenDo(() => createMail())
|
|
|
|
when(mailFacade.getRecipientKeyData(anything())).thenResolve(null)
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
when(mailFacade.getAttachmentIds(anything())).thenResolve([])
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
const tutanotaProperties = createTutanotaProperties({
|
|
|
|
defaultSender: DEFAULT_SENDER_FOR_TESTING,
|
|
|
|
defaultUnconfidential: true,
|
|
|
|
notificationMailLanguage: "en",
|
|
|
|
noAutomaticContacts: false,
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
const user = createUser({
|
2022-01-07 15:58:30 +01:00
|
|
|
userGroup: createGroupMembership({
|
|
|
|
_id: testIdGenerator.newId(),
|
|
|
|
group: testIdGenerator.newId(),
|
|
|
|
}),
|
2020-09-18 14:41:31 +02:00
|
|
|
memberships: [
|
2022-01-07 15:58:30 +01:00
|
|
|
createGroupMembership({
|
|
|
|
_id: testIdGenerator.newId(),
|
|
|
|
groupType: GroupType.Contact,
|
|
|
|
}),
|
|
|
|
],
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-05-30 09:11:41 +02:00
|
|
|
const userController = object<UserController>()
|
2022-02-03 14:55:40 +01:00
|
|
|
replace(userController, "user", user)
|
|
|
|
replace(userController, "props", tutanotaProperties)
|
|
|
|
when(userController.loadCustomer()).thenResolve(createCustomer())
|
|
|
|
|
|
|
|
const loginController = object<LoginController>()
|
|
|
|
when(loginController.isInternalUserLoggedIn()).thenReturn(true)
|
|
|
|
when(loginController.getUserController()).thenReturn(userController)
|
|
|
|
|
|
|
|
const eventController = instance(EventController)
|
|
|
|
|
2022-12-16 17:18:37 +01:00
|
|
|
const mailboxDetails: MailboxDetail = {
|
2020-09-18 14:41:31 +02:00
|
|
|
mailbox: createMailBox(),
|
2022-12-16 17:18:37 +01:00
|
|
|
folders: new FolderSystem([]),
|
2023-08-01 09:57:03 +02:00
|
|
|
mailGroupInfo: createGroupInfo({
|
|
|
|
mailAddress: "mailgroup@addre.ss",
|
|
|
|
}),
|
2020-09-18 14:41:31 +02:00
|
|
|
mailGroup: createGroup(),
|
2022-01-07 15:58:30 +01:00
|
|
|
mailboxGroupRoot: createMailboxGroupRoot(),
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-04-28 17:32:27 +02:00
|
|
|
recipientsModel = instance(RecipientsModel)
|
|
|
|
when(recipientsModel.resolve(anything(), anything())).thenDo((recipient, resolveMode) => {
|
|
|
|
return new ResolvableRecipientMock(
|
|
|
|
recipient.address,
|
|
|
|
recipient.name,
|
|
|
|
recipient.contact,
|
|
|
|
recipient.type,
|
|
|
|
[INTERNAL_RECIPIENT_1.address],
|
|
|
|
[],
|
|
|
|
resolveMode,
|
2022-12-27 15:37:40 +01:00
|
|
|
user,
|
2022-04-28 17:32:27 +02:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2022-11-08 17:06:42 +01:00
|
|
|
const mailboxProperties = createMailboxProperties()
|
|
|
|
|
2022-01-07 15:58:30 +01:00
|
|
|
model = new SendMailModel(
|
|
|
|
mailFacade,
|
2022-04-28 17:32:27 +02:00
|
|
|
entity,
|
2022-02-03 14:55:40 +01:00
|
|
|
loginController,
|
2022-01-07 15:58:30 +01:00
|
|
|
mailModel,
|
|
|
|
contactModel,
|
2022-02-03 14:55:40 +01:00
|
|
|
eventController,
|
2022-01-07 15:58:30 +01:00
|
|
|
mailboxDetails,
|
2022-07-22 14:06:05 +02:00
|
|
|
recipientsModel,
|
2022-11-08 17:06:42 +01:00
|
|
|
new NoZoneDateProvider(),
|
|
|
|
mailboxProperties,
|
2023-08-24 16:04:13 +02:00
|
|
|
kdfPicker,
|
2022-01-07 15:58:30 +01:00
|
|
|
)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-04-28 17:32:27 +02:00
|
|
|
replace(model, "getDefaultSender", () => DEFAULT_SENDER_FOR_TESTING)
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2020-11-03 08:42:25 +01:00
|
|
|
o.spec("initialization", function () {
|
|
|
|
o("initWithTemplate empty", async function () {
|
2020-10-22 14:55:01 +02:00
|
|
|
await model.initWithTemplate({}, "", "", [], false)
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.getConversationType()).equals(ConversationType.NEW)
|
|
|
|
o(model.getSubject()).equals("")
|
|
|
|
o(model.getBody()).equals("")
|
|
|
|
o(model.getDraft()).equals(null)
|
|
|
|
o(model.allRecipients().length).equals(0)
|
|
|
|
o(model.getSender()).equals(DEFAULT_SENDER_FOR_TESTING)
|
|
|
|
o(model.isConfidential()).equals(true)
|
|
|
|
o(model.containsExternalRecipients()).equals(false)
|
|
|
|
o(model.getAttachments().length).equals(0)
|
|
|
|
o(model.hasMailChanged()).equals(false)("initialization should not flag mail changed")
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o("initWithTemplate data", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const initializedModel = await model.initWithTemplate(
|
2022-01-07 15:58:30 +01:00
|
|
|
{
|
|
|
|
to: [INTERNAL_RECIPIENT_1],
|
|
|
|
},
|
2020-09-18 14:41:31 +02:00
|
|
|
SUBJECT_LINE_1,
|
|
|
|
BODY_TEXT_1,
|
|
|
|
[],
|
|
|
|
false,
|
2022-01-07 15:58:30 +01:00
|
|
|
DEFAULT_SENDER_FOR_TESTING,
|
2020-09-18 14:41:31 +02:00
|
|
|
)
|
|
|
|
o(initializedModel.getConversationType()).equals(ConversationType.NEW)
|
|
|
|
o(initializedModel.getSubject()).equals(SUBJECT_LINE_1)
|
|
|
|
o(initializedModel.getBody()).equals(BODY_TEXT_1)
|
|
|
|
o(initializedModel.getDraft()).equals(null)
|
|
|
|
o(initializedModel.allRecipients().length).equals(1)
|
|
|
|
o(initializedModel.getSender()).equals(DEFAULT_SENDER_FOR_TESTING)
|
|
|
|
o(model.isConfidential()).equals(true)
|
|
|
|
o(model.containsExternalRecipients()).equals(false)
|
|
|
|
o(initializedModel.getAttachments().length).equals(0)
|
|
|
|
o(initializedModel.hasMailChanged()).equals(false)("initialization should not flag mail changed")
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o("initWithTemplate duplicated recipients", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const duplicate = {
|
|
|
|
name: INTERNAL_RECIPIENT_1.name,
|
|
|
|
address: INTERNAL_RECIPIENT_1.address,
|
2022-01-07 15:58:30 +01:00
|
|
|
contact: INTERNAL_RECIPIENT_1.contact,
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
|
|
|
const initializedModel = await model.initWithTemplate(
|
2022-01-07 15:58:30 +01:00
|
|
|
{
|
|
|
|
to: [INTERNAL_RECIPIENT_1, duplicate],
|
|
|
|
},
|
2020-09-18 14:41:31 +02:00
|
|
|
SUBJECT_LINE_1,
|
|
|
|
BODY_TEXT_1,
|
|
|
|
[],
|
|
|
|
false,
|
2022-01-07 15:58:30 +01:00
|
|
|
DEFAULT_SENDER_FOR_TESTING,
|
2020-09-18 14:41:31 +02:00
|
|
|
)
|
|
|
|
o(initializedModel.getConversationType()).equals(ConversationType.NEW)
|
|
|
|
o(initializedModel.getSubject()).equals(SUBJECT_LINE_1)
|
|
|
|
o(initializedModel.getBody()).equals(BODY_TEXT_1)
|
|
|
|
o(initializedModel.getDraft()).equals(null)
|
|
|
|
o(initializedModel.allRecipients().length).equals(1)
|
|
|
|
o(initializedModel.getSender()).equals(DEFAULT_SENDER_FOR_TESTING)
|
|
|
|
o(model.isConfidential()).equals(true)
|
|
|
|
o(model.containsExternalRecipients()).equals(false)
|
|
|
|
o(initializedModel.getAttachments().length).equals(0)
|
|
|
|
o(initializedModel.hasMailChanged()).equals(false)("initialization should not flag mail changed")
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o("initWithDraft with blank data", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const draftMail = createMail({
|
|
|
|
confidential: false,
|
|
|
|
sender: createMailAddress(),
|
|
|
|
toRecipients: [],
|
|
|
|
ccRecipients: [],
|
|
|
|
bccRecipients: [],
|
|
|
|
subject: "",
|
2022-01-07 15:58:30 +01:00
|
|
|
replyTos: [],
|
2022-12-27 15:37:40 +01:00
|
|
|
conversationEntry: testIdGenerator.newIdTuple(),
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const mailWrapper = MailWrapper.details(
|
|
|
|
draftMail,
|
|
|
|
createMailDetails({
|
|
|
|
body: createBody({
|
|
|
|
text: BODY_TEXT_1,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
)
|
2022-12-27 15:37:40 +01:00
|
|
|
when(entity.load(ConversationEntryTypeRef, draftMail.conversationEntry)).thenResolve(
|
|
|
|
createConversationEntry({ conversationType: ConversationType.REPLY }),
|
|
|
|
)
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const initializedModel = await model.initWithDraft([], mailWrapper, new Map())
|
2020-11-03 08:42:25 +01:00
|
|
|
o(initializedModel.getConversationType()).equals(ConversationType.REPLY)
|
2020-09-18 14:41:31 +02:00
|
|
|
o(initializedModel.getSubject()).equals(draftMail.subject)
|
|
|
|
o(initializedModel.getBody()).equals(BODY_TEXT_1)
|
|
|
|
o(initializedModel.getDraft()).equals(draftMail)
|
|
|
|
o(initializedModel.allRecipients().length).equals(0)
|
|
|
|
o(initializedModel.getSender()).equals(DEFAULT_SENDER_FOR_TESTING)
|
|
|
|
o(model.isConfidential()).equals(true)
|
|
|
|
o(model.containsExternalRecipients()).equals(false)
|
|
|
|
o(initializedModel.getAttachments().length).equals(0)
|
|
|
|
o(initializedModel.hasMailChanged()).equals(false)("initialization should not flag mail changed")
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o("initWithDraft with some data", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const draftMail = createMail({
|
|
|
|
confidential: true,
|
|
|
|
sender: createMailAddress(),
|
2022-01-07 15:58:30 +01:00
|
|
|
toRecipients: [
|
|
|
|
createMailAddress({
|
|
|
|
address: "",
|
|
|
|
}),
|
|
|
|
createMailAddress({
|
|
|
|
address: EXTERNAL_ADDRESS_1,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
ccRecipients: [
|
|
|
|
createMailAddress({
|
|
|
|
address: EXTERNAL_ADDRESS_2,
|
|
|
|
}),
|
|
|
|
],
|
2020-09-18 14:41:31 +02:00
|
|
|
bccRecipients: [],
|
|
|
|
subject: SUBJECT_LINE_1,
|
2022-01-07 15:58:30 +01:00
|
|
|
replyTos: [],
|
2022-12-27 15:37:40 +01:00
|
|
|
conversationEntry: testIdGenerator.newIdTuple(),
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const mailWrapper = MailWrapper.details(draftMail, createMailDetails({ body: createBody({ text: BODY_TEXT_1 }) }))
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
when(entity.load(ConversationEntryTypeRef, draftMail.conversationEntry)).thenResolve(
|
|
|
|
createConversationEntry({ conversationType: ConversationType.FORWARD }),
|
|
|
|
)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
add MailDetails feature, #4719
server issues: 1276, 1271, 1279, 1272, 1270, 1258, 1254, 1253, 1242, 1241
2022-11-03 19:03:54 +01:00
|
|
|
const initializedModel = await model.initWithDraft([], mailWrapper, new Map())
|
2020-11-03 08:42:25 +01:00
|
|
|
o(initializedModel.getConversationType()).equals(ConversationType.FORWARD)
|
2020-09-18 14:41:31 +02:00
|
|
|
o(initializedModel.getSubject()).equals(draftMail.subject)
|
|
|
|
o(initializedModel.getBody()).equals(BODY_TEXT_1)
|
|
|
|
o(initializedModel.getDraft()).equals(draftMail)
|
2022-12-27 15:37:40 +01:00
|
|
|
o(initializedModel.allRecipients().length).equals(2)("Only MailAddresses with a valid address will be accepted as recipients")
|
2020-09-18 14:41:31 +02:00
|
|
|
o(initializedModel.toRecipients().length).equals(1)
|
|
|
|
o(initializedModel.ccRecipients().length).equals(1)
|
|
|
|
o(initializedModel.bccRecipients().length).equals(0)
|
|
|
|
o(initializedModel.getSender()).equals(DEFAULT_SENDER_FOR_TESTING)
|
|
|
|
o(model.isConfidential()).equals(true)
|
|
|
|
o(model.containsExternalRecipients()).equals(true)
|
|
|
|
o(initializedModel.getAttachments().length).equals(0)
|
|
|
|
})
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o.spec("Adding and removing recipients", function () {
|
|
|
|
o.beforeEach(async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
await model.initWithTemplate({}, "", "", [], false, "")
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
o("adding duplicate to-recipient", async function () {
|
|
|
|
const recipient = {
|
|
|
|
name: "sanchez",
|
|
|
|
address: "123@test.com",
|
|
|
|
contact: null,
|
2022-04-28 17:32:27 +02:00
|
|
|
type: null,
|
2022-02-03 14:55:40 +01:00
|
|
|
}
|
2022-04-28 17:32:27 +02:00
|
|
|
model.addRecipient(RecipientField.TO, recipient, ResolveMode.Eager)
|
|
|
|
const r1 = model.getRecipient(RecipientField.TO, recipient.address)!
|
|
|
|
|
|
|
|
model.addRecipient(RecipientField.TO, recipient, ResolveMode.Eager)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(recipientsModel.resolve(recipient, ResolveMode.Eager), { times: 1 })
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.toRecipients().length).equals(1)
|
|
|
|
o(model.ccRecipients().length).equals(0)
|
|
|
|
o(model.bccRecipients().length).equals(0)
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
o("add different to-recipients", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const pablo = {
|
|
|
|
name: "pablo",
|
|
|
|
address: "pablo94@test.co.uk",
|
2022-01-07 15:58:30 +01:00
|
|
|
contact: null,
|
2022-12-27 15:37:40 +01:00
|
|
|
type: null,
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
|
|
|
const cortez = {
|
|
|
|
name: "cortez",
|
|
|
|
address: "c.asd@test.net",
|
2022-01-07 15:58:30 +01:00
|
|
|
contact: null,
|
2022-12-27 15:37:40 +01:00
|
|
|
type: null,
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
2022-04-28 17:32:27 +02:00
|
|
|
model.addRecipient(RecipientField.TO, pablo, ResolveMode.Eager)
|
|
|
|
model.addRecipient(RecipientField.TO, cortez, ResolveMode.Eager)
|
|
|
|
|
|
|
|
verify(recipientsModel.resolve(pablo, ResolveMode.Eager))
|
|
|
|
verify(recipientsModel.resolve(cortez, ResolveMode.Eager))
|
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.toRecipients().length).equals(2)
|
|
|
|
o(model.ccRecipients().length).equals(0)
|
|
|
|
o(model.bccRecipients().length).equals(0)
|
|
|
|
})
|
2020-11-03 08:42:25 +01:00
|
|
|
o("add duplicate recipients to different fields", async function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
const recipient = {
|
|
|
|
name: "sanchez",
|
|
|
|
address: "123@test.com",
|
2022-01-07 15:58:30 +01:00
|
|
|
contact: null,
|
2022-12-27 15:37:40 +01:00
|
|
|
type: null,
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
2022-04-28 17:32:27 +02:00
|
|
|
model.addRecipient(RecipientField.TO, recipient, ResolveMode.Eager)
|
|
|
|
model.addRecipient(RecipientField.CC, recipient, ResolveMode.Eager)
|
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(recipientsModel.resolve(recipient, ResolveMode.Eager), { times: 2 })
|
2022-04-28 17:32:27 +02:00
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.toRecipients().length).equals(1)
|
|
|
|
o(model.ccRecipients().length).equals(1)
|
|
|
|
o(model.bccRecipients().length).equals(0)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
o.spec("Sending", function () {
|
|
|
|
o("completely blank email", async function () {
|
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
const getConfirmation = func<() => Promise<boolean>>()
|
2021-06-21 17:47:54 +02:00
|
|
|
const e = await assertThrows(UserError, () => model.send(method, getConfirmation))
|
2021-07-20 12:31:30 +02:00
|
|
|
o(e?.message).equals(lang.get("noRecipients_msg"))
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(getConfirmation(), { times: 0 })
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 0 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 0 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
o("blank subject no confirm", async function () {
|
2022-04-28 17:32:27 +02:00
|
|
|
model.addRecipient(RecipientField.TO, {
|
2022-01-07 15:58:30 +01:00
|
|
|
name: "test",
|
|
|
|
address: "test@address.com",
|
|
|
|
contact: null,
|
2022-04-28 17:32:27 +02:00
|
|
|
})
|
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
const getConfirmation = func<() => Promise<boolean>>()
|
2020-09-18 14:41:31 +02:00
|
|
|
const r = await model.send(method, getConfirmation)
|
|
|
|
o(r).equals(false)
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(getConfirmation(), { times: 0 })
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 0 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 0 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
o("confidential missing password", async function () {
|
2022-04-28 17:32:27 +02:00
|
|
|
await model.addRecipient(RecipientField.TO, {
|
2022-01-07 15:58:30 +01:00
|
|
|
name: "test",
|
|
|
|
address: "test@address.com",
|
|
|
|
contact: null,
|
2022-04-28 17:32:27 +02:00
|
|
|
})
|
2020-09-18 14:41:31 +02:00
|
|
|
model.setConfidential(true)
|
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const getConfirmation = func<(TranslationKey) => Promise<boolean>>()
|
|
|
|
when(getConfirmation(anything())).thenResolve(true)
|
|
|
|
|
2021-06-21 17:47:54 +02:00
|
|
|
const e = await assertThrows(UserError, () => model.send(method, getConfirmation))
|
2021-07-20 12:31:30 +02:00
|
|
|
o(e?.message).equals(lang.get("noPreSharedPassword_msg"))
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 0 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 0 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
o("confidential weak password no confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipient = {
|
|
|
|
name: "test",
|
|
|
|
address: "test@address.com",
|
|
|
|
contact: null,
|
|
|
|
}
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: [recipient] }, "subject", "", [], true, "me@tutanota.com", false)
|
2020-09-18 14:41:31 +02:00
|
|
|
model.setPassword("test@address.com", "abc")
|
|
|
|
o(model.getPassword(recipient.address)).equals("abc")
|
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const getConfirmation = func<(TranslationKey) => Promise<boolean>>()
|
|
|
|
when(getConfirmation(anything())).thenResolve(false)
|
2020-09-18 14:41:31 +02:00
|
|
|
const r = await model.send(method, getConfirmation)
|
|
|
|
o(r).equals(false)
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 0 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 0 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
o("confidential weak password confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipient = {
|
|
|
|
name: "test",
|
|
|
|
address: "test@address.com",
|
|
|
|
contact: null,
|
|
|
|
}
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: [recipient] }, "did you get that thing i sent ya?", "", [], true, "me@tutanota.de", false)
|
2020-09-18 14:41:31 +02:00
|
|
|
const password = WEAK_PASSWORD
|
|
|
|
model.setPassword("test@address.com", password)
|
|
|
|
o(model.getPassword(recipient.address)).equals(password)
|
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
const getConfirmation = func<(TranslationKey) => Promise<boolean>>()
|
|
|
|
when(getConfirmation(anything())).thenResolve(true)
|
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
const r = await model.send(method, getConfirmation)
|
|
|
|
o(r).equals(true)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(kdfPicker.pickKdfType(), { times: 1 })
|
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 1 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 1 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const contact = model.getRecipientList(RecipientField.TO)[0].contact!
|
|
|
|
o(contact.presharedPassword).equals(password)
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
o("correct password will be returned from getPassword after calling setPassword", function () {
|
|
|
|
model.setPassword("address1", "password1")
|
|
|
|
model.setPassword("address2", "password2")
|
|
|
|
|
|
|
|
o(model.getPassword("address2")).equals("password2")
|
|
|
|
o(model.getPassword("address1")).equals("password1")
|
|
|
|
})
|
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o("confidential strong password", async function () {
|
|
|
|
const address = "test@address.com"
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipient = {
|
|
|
|
name: "test",
|
|
|
|
address: address,
|
|
|
|
contact: null,
|
|
|
|
}
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: [recipient] }, "subjecttttt", "", [], true, "me@tutanota.de", false)
|
2020-09-18 14:41:31 +02:00
|
|
|
const password = STRONG_PASSWORD
|
|
|
|
model.setPassword(address, password)
|
|
|
|
const method = MailMethod.NONE
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const getConfirmation = func<(TranslationKey) => Promise<boolean>>()
|
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
const r = await model.send(method, getConfirmation)
|
|
|
|
o(r).equals(true)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(getConfirmation(anything), { times: 0 })
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-08-24 16:04:13 +02:00
|
|
|
verify(kdfPicker.pickKdfType(), { times: 1 })
|
|
|
|
verify(mailFacade.sendDraft(anything(), anything(), anything(), anything()), { times: 1 })
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(mailFacade.createDraft(anything()), { times: 1 })
|
|
|
|
verify(mailFacade.updateDraft(anything()), { times: 0 })
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
const contact = model.getRecipientList(RecipientField.TO)[0].contact!
|
|
|
|
o(contact.presharedPassword).equals(password)
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
o("when a recipient has an existing contact, and the saved password changes, then the contact will be updated", async function () {
|
|
|
|
const getConfirmation = func<(TranslationKey) => Promise<boolean>>()
|
|
|
|
|
|
|
|
const contact = createContact({
|
|
|
|
_id: testIdGenerator.newIdTuple(),
|
|
|
|
firstName: "my",
|
|
|
|
lastName: "chippie",
|
|
|
|
presharedPassword: "weak password",
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: [] }, "did you get that thing i sent ya?", "no?", [], true, "me@tutanota.de", false)
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.addRecipient(RecipientField.TO, {
|
2022-12-27 15:37:40 +01:00
|
|
|
name: "chippie",
|
|
|
|
address: "chippie@cinco.net",
|
|
|
|
contact,
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
|
|
|
model.setPassword("chippie@cinco.net", STRONG_PASSWORD)
|
|
|
|
await model.send(MailMethod.NONE, getConfirmation)
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(entity.update(contact), { times: 1 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
})
|
2022-04-28 17:32:27 +02:00
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o.spec("Entity Event Updates", function () {
|
|
|
|
let existingContact
|
2023-06-19 17:44:21 +02:00
|
|
|
let recipients
|
|
|
|
o.before(function () {
|
2020-09-18 14:41:31 +02:00
|
|
|
existingContact = createContact({
|
|
|
|
_id: testIdGenerator.newIdTuple(),
|
|
|
|
firstName: "james",
|
|
|
|
lastName: "hetfield",
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-06-19 17:44:21 +02:00
|
|
|
recipients = [
|
2020-09-18 14:41:31 +02:00
|
|
|
{
|
2022-01-07 15:58:30 +01:00
|
|
|
name: "paul gilbert",
|
|
|
|
address: "paul@gmail.com",
|
|
|
|
contact: null,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "james hetfield",
|
|
|
|
address: "james@tutanota.com",
|
|
|
|
contact: existingContact,
|
|
|
|
},
|
2020-09-18 14:41:31 +02:00
|
|
|
]
|
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o("nonmatching event", async function () {
|
2022-03-17 16:18:17 +01:00
|
|
|
await model.handleEntityEvent(downcast(CustomerAccountCreateDataTypeRef))
|
|
|
|
await model.handleEntityEvent(downcast(UserTypeRef))
|
|
|
|
await model.handleEntityEvent(downcast(CustomerTypeRef))
|
|
|
|
await model.handleEntityEvent(downcast(NotificationMailTypeRef))
|
|
|
|
await model.handleEntityEvent(downcast(ChallengeTypeRef))
|
|
|
|
await model.handleEntityEvent(downcast(MailTypeRef))
|
2022-12-27 15:37:40 +01:00
|
|
|
verify(entity.load(anything(), anything(), anything(), anything()), { times: 0 })
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2020-09-18 14:41:31 +02:00
|
|
|
o("contact updated email kept", async function () {
|
2022-12-27 15:37:40 +01:00
|
|
|
const { app, type } = ContactTypeRef
|
2020-09-18 14:41:31 +02:00
|
|
|
const [instanceListId, instanceId] = existingContact._id
|
|
|
|
const contactForUpdate = {
|
|
|
|
firstName: "newfirstname",
|
|
|
|
lastName: "newlastname",
|
2021-12-07 15:30:53 +01:00
|
|
|
mailAddresses: [
|
2022-01-07 15:58:30 +01:00
|
|
|
createMailAddress({
|
|
|
|
address: "james@tutanota.com",
|
|
|
|
}),
|
|
|
|
createMailAddress({
|
|
|
|
address: "address2@hotmail.com",
|
|
|
|
}),
|
|
|
|
],
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
2022-12-27 15:37:40 +01:00
|
|
|
when(
|
|
|
|
entity.load(
|
|
|
|
ContactTypeRef,
|
|
|
|
argThat((id) => isSameId(id, existingContact._id)),
|
|
|
|
),
|
|
|
|
).thenResolve(createContact(Object.assign({ _id: existingContact._id } as Contact, contactForUpdate)))
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: recipients }, "somb", "", [], true, "a@b.c", false)
|
2022-12-27 15:37:40 +01:00
|
|
|
await model.handleEntityEvent({
|
|
|
|
application: app,
|
|
|
|
type,
|
|
|
|
operation: OperationType.UPDATE,
|
|
|
|
instanceListId,
|
|
|
|
instanceId,
|
|
|
|
})
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.allRecipients().length).equals(2)
|
2022-12-27 15:37:40 +01:00
|
|
|
const updatedRecipient = model.allRecipients().find((r) => r.contact && isSameId(r.contact._id, existingContact._id))
|
2020-09-18 14:41:31 +02:00
|
|
|
o(updatedRecipient && updatedRecipient.name).equals(getContactDisplayName(downcast(contactForUpdate)))
|
|
|
|
})
|
|
|
|
o("contact updated email removed or changed", async function () {
|
2022-12-27 15:37:40 +01:00
|
|
|
const { app, type } = ContactTypeRef
|
2020-09-18 14:41:31 +02:00
|
|
|
const [instanceListId, instanceId] = existingContact._id
|
|
|
|
const contactForUpdate = {
|
|
|
|
firstName: "james",
|
|
|
|
lastName: "hetfield",
|
2022-01-07 15:58:30 +01:00
|
|
|
mailAddresses: [
|
|
|
|
createMailAddress({
|
|
|
|
address: "nolongerjames@hotmail.com",
|
|
|
|
}),
|
|
|
|
],
|
2020-09-18 14:41:31 +02:00
|
|
|
}
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2022-12-27 15:37:40 +01:00
|
|
|
when(entity.load(ContactTypeRef, existingContact._id)).thenResolve(
|
|
|
|
createContact(
|
|
|
|
Object.assign(
|
|
|
|
{
|
|
|
|
_id: existingContact._id,
|
|
|
|
} as Contact,
|
|
|
|
contactForUpdate,
|
|
|
|
),
|
|
|
|
),
|
2022-01-07 15:58:30 +01:00
|
|
|
)
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: recipients }, "b", "c", [], true, "", false)
|
2022-12-27 15:37:40 +01:00
|
|
|
await model.handleEntityEvent({
|
|
|
|
application: app,
|
|
|
|
type,
|
|
|
|
operation: OperationType.UPDATE,
|
|
|
|
instanceListId,
|
|
|
|
instanceId,
|
|
|
|
})
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.allRecipients().length).equals(1)
|
2022-12-27 15:37:40 +01:00
|
|
|
const updatedContact = model.allRecipients().find((r) => r.contact && isSameId(r.contact._id, existingContact._id))
|
2022-02-03 14:55:40 +01:00
|
|
|
o(updatedContact ?? null).equals(null)
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
|
|
|
o("contact removed", async function () {
|
2022-12-27 15:37:40 +01:00
|
|
|
const { app, type } = ContactTypeRef
|
2020-09-18 14:41:31 +02:00
|
|
|
const [instanceListId, instanceId] = existingContact._id
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate({ to: recipients }, "subj", "", [], true, "a@b.c", false)
|
2022-12-27 15:37:40 +01:00
|
|
|
await model.handleEntityEvent({
|
|
|
|
application: app,
|
|
|
|
type,
|
|
|
|
operation: OperationType.DELETE,
|
|
|
|
instanceListId,
|
|
|
|
instanceId,
|
|
|
|
})
|
2020-09-18 14:41:31 +02:00
|
|
|
o(model.allRecipients().length).equals(1)
|
2022-12-27 15:37:40 +01:00
|
|
|
const updatedContact = model.allRecipients().find((r) => r.contact && isSameId(r.contact._id, existingContact._id))
|
2020-09-18 14:41:31 +02:00
|
|
|
o(updatedContact == null).equals(true)
|
|
|
|
})
|
2021-02-04 10:46:11 +01:00
|
|
|
o("too many to recipients dont confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipients = {
|
2022-12-27 15:37:40 +01:00
|
|
|
to: [] as { name: string; address: string }[],
|
2022-01-07 15:58:30 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
for (let i = 0; i < TOO_MANY_VISIBLE_RECIPIENTS; ++i) {
|
|
|
|
recipients.to.push({
|
|
|
|
name: `person ${i}`,
|
2022-01-07 15:58:30 +01:00
|
|
|
address: `person${i}@tutanota.de`,
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
}
|
2022-01-07 15:58:30 +01:00
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
const subject = "subyekt"
|
|
|
|
const body = "bodie"
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-02-16 12:25:40 +01:00
|
|
|
const getConfirmation = func<(key: TranslationKey) => Promise<boolean>>()
|
2022-02-03 14:55:40 +01:00
|
|
|
when(getConfirmation("manyRecipients_msg")).thenResolve(false)
|
|
|
|
|
2023-06-19 17:44:21 +02:00
|
|
|
await model.initWithTemplate(recipients, subject, body, [], false, "eggs@tutanota.de", false)
|
|
|
|
const hasBeenSent = await model.send(MailMethod.NONE, getConfirmation)
|
|
|
|
o(hasBeenSent).equals(false)("nothing was sent")
|
2023-02-16 12:25:40 +01:00
|
|
|
verify(getConfirmation("manyRecipients_msg"), { times: 1 })
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
o("too many to recipients confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipients = {
|
2022-12-27 15:37:40 +01:00
|
|
|
to: [] as { name: string; address: string }[],
|
2022-01-07 15:58:30 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
for (let i = 0; i < TOO_MANY_VISIBLE_RECIPIENTS; ++i) {
|
|
|
|
recipients.to.push({
|
|
|
|
name: `person ${i}`,
|
2022-01-07 15:58:30 +01:00
|
|
|
address: `person${i}@tutanota.de`,
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
}
|
2022-01-07 15:58:30 +01:00
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
const subject = "subyekt"
|
|
|
|
const body = "bodie"
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-02-16 12:25:40 +01:00
|
|
|
const getConfirmation = func<(key: TranslationKey) => Promise<boolean>>()
|
2022-02-03 14:55:40 +01:00
|
|
|
when(getConfirmation("manyRecipients_msg")).thenResolve(true)
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
await model.initWithTemplate(recipients, subject, body, [], false, "eggs@tutanota.de")
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
o(await model.send(MailMethod.NONE, getConfirmation)).equals(true)
|
2023-02-16 12:25:40 +01:00
|
|
|
verify(getConfirmation("manyRecipients_msg"), { times: 1 })
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
o("too many cc recipients dont confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipients = {
|
2022-12-27 15:37:40 +01:00
|
|
|
cc: [] as { name: string; address: string }[],
|
2022-01-07 15:58:30 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
for (let i = 0; i < TOO_MANY_VISIBLE_RECIPIENTS; ++i) {
|
|
|
|
recipients.cc.push({
|
|
|
|
name: `person ${i}`,
|
2022-01-07 15:58:30 +01:00
|
|
|
address: `person${i}@tutanota.de`,
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
}
|
2022-01-07 15:58:30 +01:00
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
const subject = "subyekt"
|
|
|
|
const body = "bodie"
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-02-16 12:25:40 +01:00
|
|
|
const getConfirmation = func<(key: TranslationKey) => Promise<boolean>>()
|
2022-02-03 14:55:40 +01:00
|
|
|
when(getConfirmation("manyRecipients_msg")).thenResolve(false)
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
await model.initWithTemplate(recipients, subject, body, [], false, "eggs@tutanota.de")
|
|
|
|
o(await model.send(MailMethod.NONE, getConfirmation)).equals(false)
|
2023-02-16 12:25:40 +01:00
|
|
|
verify(getConfirmation("manyRecipients_msg"), { times: 1 })
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
o("too many cc recipients confirm", async function () {
|
2022-01-07 15:58:30 +01:00
|
|
|
const recipients = {
|
2022-12-27 15:37:40 +01:00
|
|
|
cc: [] as { name: string; address: string }[],
|
2022-01-07 15:58:30 +01:00
|
|
|
}
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
for (let i = 0; i < TOO_MANY_VISIBLE_RECIPIENTS; ++i) {
|
|
|
|
recipients.cc.push({
|
|
|
|
name: `person ${i}`,
|
2022-01-07 15:58:30 +01:00
|
|
|
address: `person${i}@tutanota.de`,
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
|
|
|
}
|
2022-01-07 15:58:30 +01:00
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
const subject = "subyekt"
|
|
|
|
const body = "bodie"
|
2022-02-03 14:55:40 +01:00
|
|
|
|
2023-02-16 12:25:40 +01:00
|
|
|
const getConfirmation = func<(key: TranslationKey) => Promise<boolean>>()
|
2022-02-03 14:55:40 +01:00
|
|
|
when(getConfirmation("manyRecipients_msg")).thenResolve(true)
|
|
|
|
|
2021-02-04 10:46:11 +01:00
|
|
|
await model.initWithTemplate(recipients, subject, body, [], false, "eggs@tutanota.de")
|
|
|
|
o(await model.send(MailMethod.NONE, getConfirmation)).equals(true)
|
2023-02-16 12:25:40 +01:00
|
|
|
verify(getConfirmation("manyRecipients_msg"), { times: 1 })
|
2021-02-04 10:46:11 +01:00
|
|
|
})
|
2020-09-18 14:41:31 +02:00
|
|
|
})
|
2022-12-27 15:37:40 +01:00
|
|
|
})
|