Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for CoversationViewModel #5225

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
90 changes: 44 additions & 46 deletions src/api/entities/tutanota/TypeRefs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {create} from "../../common/utils/EntityUtils.js"
import {TypeRef} from "@tutao/tutanota-utils"
import {typeModels} from "./TypeModels.js"
import {Blob} from '../sys/TypeRefs.js'
import {BucketKey} from '../sys/TypeRefs.js'
import {BlobReferenceTokenWrapper} from '../sys/TypeRefs.js'
import {Blob, BlobReferenceTokenWrapper, BucketKey} from '../sys/TypeRefs.js'

export const AttachmentKeyDataTypeRef: TypeRef<AttachmentKeyData> = new TypeRef("tutanota", "AttachmentKeyData")

Expand Down Expand Up @@ -87,8 +85,8 @@ export type CalendarEvent = {

alarmInfos: IdTuple[];
attendees: CalendarEventAttendee[];
organizer: null | EncryptedMailAddress;
repeatRule: null | CalendarRepeatRule;
organizer: null | EncryptedMailAddress;
repeatRule: null | CalendarRepeatRule;
}
export const CalendarEventAttendeeTypeRef: TypeRef<CalendarEventAttendee> = new TypeRef("tutanota", "CalendarEventAttendee")

Expand Down Expand Up @@ -181,7 +179,7 @@ export type CalendarGroupRoot = {
_ownerGroup: null | Id;
_permissions: Id;

index: null | CalendarEventIndexRef;
index: null | CalendarEventIndexRef;
longEvents: Id;
shortEvents: Id;
}
Expand Down Expand Up @@ -232,9 +230,9 @@ export type Contact = {

addresses: ContactAddress[];
mailAddresses: ContactMailAddress[];
oldBirthdayAggregate: null | Birthday;
oldBirthdayAggregate: null | Birthday;
phoneNumbers: ContactPhoneNumber[];
photo: null | IdTuple;
photo: null | IdTuple;
socialIds: ContactSocialId[];
}
export const ContactAddressTypeRef: TypeRef<ContactAddress> = new TypeRef("tutanota", "ContactAddress")
Expand Down Expand Up @@ -270,7 +268,7 @@ export type ContactForm = {
languages: ContactFormLanguage[];
participantGroupInfos: IdTuple[];
targetGroup: Id;
targetGroupInfo: null | IdTuple;
targetGroupInfo: null | IdTuple;
}
export const ContactFormAccountDataTypeRef: TypeRef<ContactFormAccountData> = new TypeRef("tutanota", "ContactFormAccountData")

Expand Down Expand Up @@ -353,7 +351,7 @@ export type ContactList = {
_permissions: Id;

contacts: Id;
photos: null | PhotosRef;
photos: null | PhotosRef;
}
export const ContactMailAddressTypeRef: TypeRef<ContactMailAddress> = new TypeRef("tutanota", "ContactMailAddress")

Expand Down Expand Up @@ -413,8 +411,8 @@ export type ConversationEntry = {
conversationType: NumberString;
messageId: string;

mail: null | IdTuple;
previous: null | IdTuple;
mail: null | IdTuple;
previous: null | IdTuple;
}
export const CreateExternalUserGroupDataTypeRef: TypeRef<CreateExternalUserGroupData> = new TypeRef("tutanota", "CreateExternalUserGroupData")

Expand Down Expand Up @@ -447,7 +445,7 @@ export type CreateFileData = {
ownerEncSessionKey: Uint8Array;

fileData: Id;
parentFolder: null | IdTuple;
parentFolder: null | IdTuple;
}
export const CreateGroupPostReturnTypeRef: TypeRef<CreateGroupPostReturn> = new TypeRef("tutanota", "CreateGroupPostReturn")

Expand Down Expand Up @@ -492,7 +490,7 @@ export type CreateMailFolderData = {
ownerEncSessionKey: Uint8Array;
ownerGroup: null | Id;

parentFolder: null | IdTuple;
parentFolder: null | IdTuple;
}
export const CreateMailFolderReturnTypeRef: TypeRef<CreateMailFolderReturn> = new TypeRef("tutanota", "CreateMailFolderReturn")

Expand Down Expand Up @@ -563,7 +561,7 @@ export type CustomerContactFormGroupRoot = {
_ownerGroup: null | Id;
_permissions: Id;

contactFormConversations: null | DeleteContactFormConversationIndex;
contactFormConversations: null | DeleteContactFormConversationIndex;
contactForms: Id;
}
export const DataBlockTypeRef: TypeRef<DataBlock> = new TypeRef("tutanota", "DataBlock")
Expand Down Expand Up @@ -631,7 +629,7 @@ export type DeleteMailData = {

_format: NumberString;

folder: null | IdTuple;
folder: null | IdTuple;
mails: IdTuple[];
}
export const DeleteMailFolderDataTypeRef: TypeRef<DeleteMailFolderData> = new TypeRef("tutanota", "DeleteMailFolderData")
Expand Down Expand Up @@ -660,8 +658,8 @@ export type DraftAttachment = {
_id: Id;
ownerEncFileSessionKey: Uint8Array;

existingFile: null | IdTuple;
newFile: null | NewDraftAttachment;
existingFile: null | IdTuple;
newFile: null | NewDraftAttachment;
}
export const DraftCreateDataTypeRef: TypeRef<DraftCreateData> = new TypeRef("tutanota", "DraftCreateData")

Expand Down Expand Up @@ -879,9 +877,9 @@ export type File = {
size: NumberString;

blobs: Blob[];
data: null | Id;
parent: null | IdTuple;
subFiles: null | Subfiles;
data: null | Id;
parent: null | IdTuple;
subFiles: null | Subfiles;
}
export const FileDataTypeRef: TypeRef<FileData> = new TypeRef("tutanota", "FileData")

Expand Down Expand Up @@ -1091,7 +1089,7 @@ export type ImapSyncConfiguration = {
port: NumberString;
user: string;

imapSyncState: null | Id;
imapSyncState: null | Id;
}
export const ImapSyncStateTypeRef: TypeRef<ImapSyncState> = new TypeRef("tutanota", "ImapSyncState")

Expand Down Expand Up @@ -1139,7 +1137,7 @@ export type InternalGroupData = {
ownerEncGroupInfoSessionKey: Uint8Array;
publicKey: Uint8Array;

adminGroup: null | Id;
adminGroup: null | Id;
}
export const InternalRecipientKeyDataTypeRef: TypeRef<InternalRecipientKeyData> = new TypeRef("tutanota", "InternalRecipientKeyData")

Expand Down Expand Up @@ -1234,16 +1232,16 @@ export type Mail = {

attachments: IdTuple[];
bccRecipients: MailAddress[];
body: null | Id;
bucketKey: null | BucketKey;
body: null | Id;
bucketKey: null | BucketKey;
ccRecipients: MailAddress[];
conversationEntry: IdTuple;
firstRecipient: null | MailAddress;
headers: null | Id;
mailDetails: null | IdTuple;
mailDetailsDraft: null | IdTuple;
firstRecipient: null | MailAddress;
headers: null | Id;
mailDetails: null | IdTuple;
mailDetailsDraft: null | IdTuple;
replyTos: EncryptedMailAddress[];
restrictions: null | MailRestriction;
restrictions: null | MailRestriction;
sender: MailAddress;
toRecipients: MailAddress[];
}
Expand All @@ -1260,7 +1258,7 @@ export type MailAddress = {
address: string;
name: string;

contact: null | IdTuple;
contact: null | IdTuple;
}
export const MailAddressPropertiesTypeRef: TypeRef<MailAddressProperties> = new TypeRef("tutanota", "MailAddressProperties")

Expand Down Expand Up @@ -1313,12 +1311,12 @@ export type MailBox = {
lastInfoDate: Date;
symEncShareBucketKey: null | Uint8Array;

folders: null | MailFolderRef;
mailDetailsDrafts: null | MailDetailsDraftsRef;
folders: null | MailFolderRef;
mailDetailsDrafts: null | MailDetailsDraftsRef;
mails: Id;
receivedAttachments: Id;
sentAttachments: Id;
spamResults: null | SpamResults;
spamResults: null | SpamResults;
}
export const MailDetailsTypeRef: TypeRef<MailDetails> = new TypeRef("tutanota", "MailDetails")

Expand All @@ -1334,7 +1332,7 @@ export type MailDetails = {
sentDate: Date;

body: Body;
headers: null | Header;
headers: null | Header;
recipients: Recipients;
replyTos: EncryptedMailAddress[];
}
Expand Down Expand Up @@ -1406,7 +1404,7 @@ export type MailFolder = {
name: string;

mails: Id;
parentFolder: null | IdTuple;
parentFolder: null | IdTuple;
subFolders: Id;
}
export const MailFolderRefTypeRef: TypeRef<MailFolderRef> = new TypeRef("tutanota", "MailFolderRef")
Expand Down Expand Up @@ -1468,15 +1466,15 @@ export type MailboxGroupRoot = {
_ownerGroup: null | Id;
_permissions: Id;

calendarEventUpdates: null | CalendarEventUpdateList;
contactFormUserContactForm: null | IdTuple;
calendarEventUpdates: null | CalendarEventUpdateList;
contactFormUserContactForm: null | IdTuple;
mailbox: Id;
mailboxProperties: null | Id;
outOfOfficeNotification: null | Id;
outOfOfficeNotificationRecipientList: null | OutOfOfficeNotificationRecipientList;
mailboxProperties: null | Id;
outOfOfficeNotification: null | Id;
outOfOfficeNotificationRecipientList: null | OutOfOfficeNotificationRecipientList;
participatingContactForms: IdTuple[];
serverProperties: Id;
targetMailGroupContactForm: null | IdTuple;
targetMailGroupContactForm: null | IdTuple;
whitelistRequests: Id;
}
export const MailboxPropertiesTypeRef: TypeRef<MailboxProperties> = new TypeRef("tutanota", "MailboxProperties")
Expand Down Expand Up @@ -1541,7 +1539,7 @@ export type NewDraftAttachment = {
encFileName: Uint8Array;
encMimeType: Uint8Array;

fileData: null | Id;
fileData: null | Id;
referenceTokens: BlobReferenceTokenWrapper[];
}
export const NewsIdTypeRef: TypeRef<NewsId> = new TypeRef("tutanota", "NewsId")
Expand Down Expand Up @@ -1979,7 +1977,7 @@ export type TutanotaProperties = {

imapSyncConfig: ImapSyncConfiguration[];
inboxRules: InboxRule[];
lastPushedMail: null | IdTuple;
lastPushedMail: null | IdTuple;
}
export const UpdateMailFolderDataTypeRef: TypeRef<UpdateMailFolderData> = new TypeRef("tutanota", "UpdateMailFolderData")

Expand All @@ -1993,7 +1991,7 @@ export type UpdateMailFolderData = {
_format: NumberString;

folder: IdTuple;
newParent: null | IdTuple;
newParent: null | IdTuple;
}
export const UserAccountCreateDataTypeRef: TypeRef<UserAccountCreateData> = new TypeRef("tutanota", "UserAccountCreateData")

Expand Down Expand Up @@ -2058,7 +2056,7 @@ export type UserAreaGroupData = {
groupInfoEncName: Uint8Array;
userEncGroupKey: Uint8Array;

adminGroup: null | Id;
adminGroup: null | Id;
}
export const UserAreaGroupDeleteDataTypeRef: TypeRef<UserAreaGroupDeleteData> = new TypeRef("tutanota", "UserAreaGroupDeleteData")

Expand Down
1 change: 1 addition & 0 deletions src/api/main/MainLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class MainLocator {
this.entityClient,
this.eventController,
deviceConfig,
this.mailModel,
m.redraw,
)
}
Expand Down
8 changes: 5 additions & 3 deletions src/mail/view/ConversationViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ConversationType, MailFolderType, MailState, OperationType } from "../.
import { NotFoundError } from "../../api/common/error/RestError.js"
import { normalizeSubject } from "../model/MailUtils.js"
import { isOfTypeOrSubfolderOf } from "../../api/common/mail/CommonMailUtils.js"
import { MailModel } from "../model/MailModel.js"

export type MailViewerViewModelFactory = (options: CreateMailViewerOptions) => MailViewerViewModel

Expand All @@ -18,7 +19,7 @@ export type SubjectItem = { type: "subject"; subject: string; id: string; entryI
export type DeletedItem = { type: "deleted"; entryId: IdTuple }
export type ConversationItem = MailItem | SubjectItem | DeletedItem

interface ConversationPrefProvider {
export interface ConversationPrefProvider {
getConversationViewShowOnlySelectedMail(): boolean
}

Expand All @@ -36,6 +37,7 @@ export class ConversationViewModel {
private readonly entityClient: EntityClient,
private readonly eventController: EventController,
private readonly conversationPrefProvider: ConversationPrefProvider,
private readonly mailModel: MailModel,
private readonly onUiUpdate: () => unknown,
) {
this._primaryViewModel = viewModelFactory(options)
Expand Down Expand Up @@ -240,8 +242,8 @@ export class ConversationViewModel {
}

private async isInTrash(mail: Mail) {
const mailboxDetail = await this._primaryViewModel.mailModel.getMailboxDetailsForMail(mail)
const mailFolder = this._primaryViewModel.mailModel.getMailFolder(getListId(mail))
const mailboxDetail = await this.mailModel.getMailboxDetailsForMail(mail)
const mailFolder = this.mailModel.getMailFolder(getListId(mail))
return mailFolder && mailboxDetail && isOfTypeOrSubfolderOf(mailboxDetail.folders, mailFolder, MailFolderType.TRASH)
}

Expand Down
1 change: 1 addition & 0 deletions test/tests/Suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async function setupSuite() {
await import("./api/worker/offline/OfflineStorageMigratorTest.js")
await import("./api/worker/offline/OfflineStorageMigrationsTest.js")
await import("./api/worker/offline/OfflineStorageTest.js")
await import("./mail/view/CoversationViewModelTest.js")
}

// testdouble complains about certain mocking related code smells, and also prints a warning whenever you replace a property on an object.
Expand Down