diff --git a/FlowCrypt.xcodeproj/project.pbxproj b/FlowCrypt.xcodeproj/project.pbxproj index acbee989f..0963b11c0 100644 --- a/FlowCrypt.xcodeproj/project.pbxproj +++ b/FlowCrypt.xcodeproj/project.pbxproj @@ -127,6 +127,7 @@ 9F7E903926A1AD7A0021C07F /* KeyDetailsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F7E903826A1AD7A0021C07F /* KeyDetailsTests.swift */; }; 9F82779823737E0900E19C07 /* MessageViewDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F82779723737E0900E19C07 /* MessageViewDecorator.swift */; }; 9F82D352256D74FA0069A702 /* InboxViewContainerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F82D351256D74FA0069A702 /* InboxViewContainerController.swift */; }; + 9F8C160826C1379A000A460F /* SignInImapTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FDF364C235A1CCD00614596 /* SignInImapTest.swift */; }; 9F92EE72236F165E009BE0D7 /* EncryptedStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F92EE71236F165E009BE0D7 /* EncryptedStorage.swift */; }; 9F9361A52573CE260009912F /* MessageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F9361A42573CE260009912F /* MessageProvider.swift */; }; 9F9362062573D0C80009912F /* Gmail+MessagesList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F9362052573D0C80009912F /* Gmail+MessagesList.swift */; }; @@ -548,6 +549,8 @@ 9F82779B23737E2A00E19C07 /* MessageSubjectNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageSubjectNode.swift; sourceTree = ""; }; 9F82779D23737E3800E19C07 /* MessageTextSubjectNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTextSubjectNode.swift; sourceTree = ""; }; 9F82D351256D74FA0069A702 /* InboxViewContainerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxViewContainerController.swift; sourceTree = ""; }; + 9F8C160E26C137B9000A460F /* Gmail.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Gmail.xctestplan; sourceTree = ""; }; + 9F8C161426C1382E000A460F /* Imap.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = Imap.xctestplan; sourceTree = ""; }; 9F8D5E61236B04E300186E43 /* CellNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CellNode.swift; sourceTree = ""; }; 9F92EE6F236F144C009BE0D7 /* TextFieldCellNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldCellNode.swift; sourceTree = ""; }; 9F92EE71236F165E009BE0D7 /* EncryptedStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptedStorage.swift; sourceTree = ""; }; @@ -592,7 +595,7 @@ 9FDF3639235A0B3B00614596 /* HeaderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderNode.swift; sourceTree = ""; }; 9FDF3641235A1B0100614596 /* FlowCryptUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FlowCryptUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 9FDF3645235A1B0100614596 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 9FDF364C235A1CCD00614596 /* SignInTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInTest.swift; sourceTree = ""; }; + 9FDF364C235A1CCD00614596 /* SignInImapTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInImapTest.swift; sourceTree = ""; }; 9FDF364F235A1D3F00614596 /* UITestHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITestHelper.swift; sourceTree = ""; }; 9FDF3651235A1EDE00614596 /* XCUIApplicationBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCUIApplicationBuilder.swift; sourceTree = ""; }; 9FDF3653235A218E00614596 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; @@ -706,7 +709,7 @@ D2F6D12E24324ACC00DB4065 /* SwitchCellNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchCellNode.swift; sourceTree = ""; }; D2F6D1322433753100DB4065 /* IMAPSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IMAPSession.swift; sourceTree = ""; }; D2F6D1342433753B00DB4065 /* SMTPSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SMTPSession.swift; sourceTree = ""; }; - D2F6D13D2434FF1400DB4065 /* providers.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = providers.json; sourceTree = ""; }; + D2F6D13D2434FF1400DB4065 /* providers.json */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = text.json; path = providers.json; sourceTree = ""; }; D2F6D13F2435008500DB4065 /* SessionCredentialsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionCredentialsProvider.swift; sourceTree = ""; }; D2F6D146243506DA00DB4065 /* MailSettingsCredentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailSettingsCredentials.swift; sourceTree = ""; }; D2FC1C0524D82C9F003B949D /* ContactsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsService.swift; sourceTree = ""; }; @@ -1404,7 +1407,9 @@ 9FDF3642235A1B0100614596 /* FlowCryptUITests */ = { isa = PBXGroup; children = ( - 9FDF364C235A1CCD00614596 /* SignInTest.swift */, + 9F8C160E26C137B9000A460F /* Gmail.xctestplan */, + 9F8C161426C1382E000A460F /* Imap.xctestplan */, + 9FDF364C235A1CCD00614596 /* SignInImapTest.swift */, D2F18463244B0C63000CC5D1 /* SignInGoogleTest.swift */, D216D05D242D32EA0083EDD6 /* TestCredentials.swift */, 9FDF3645235A1B0100614596 /* Info.plist */, @@ -2481,6 +2486,7 @@ 9F228BA923C67587005D2CB6 /* UserCredentials.swift in Sources */, D2F18464244B0C63000CC5D1 /* SignInGoogleTest.swift in Sources */, 9F228BA623C673AD005D2CB6 /* Springboard.swift in Sources */, + 9F8C160826C1379A000A460F /* SignInImapTest.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/FlowCrypt.xcodeproj/xcshareddata/xcschemes/FlowCryptUITests.xcscheme b/FlowCrypt.xcodeproj/xcshareddata/xcschemes/FlowCryptUITests.xcscheme index 6748a9e02..b1302a697 100644 --- a/FlowCrypt.xcodeproj/xcshareddata/xcschemes/FlowCryptUITests.xcscheme +++ b/FlowCrypt.xcodeproj/xcshareddata/xcschemes/FlowCryptUITests.xcscheme @@ -39,6 +39,12 @@ isEnabled = "YES"> + + + + diff --git a/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift b/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift index a083b7bf5..eaf7a8351 100644 --- a/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift +++ b/FlowCrypt/Controllers/SetupImap/SetupImapViewController.swift @@ -212,16 +212,22 @@ extension SetupImapViewController: ASTableDelegate, ASTableDataSource { } func tableNode(_ tableNode: ASTableNode, nodeBlockForRowAt indexPath: IndexPath) -> ASCellNodeBlock { { [weak self] in - guard let self = self, let section = Section(indexPath: indexPath) else { return ASCellNode() } - - switch section { - case .account(.title): return self.titleNode(for: indexPath) - case .imap(.title): return self.titleNode(for: indexPath) - case .smtp(.title): return self.titleNode(for: indexPath) - case .other(.title): return self.switchNode() - case .connect: return self.buttonNode() - default: return self.textFieldNode(for: indexPath) - } + guard let self = self, let section = Section(indexPath: indexPath) else { return ASCellNode() } + + switch section { + case .account(.title): + return self.titleNode(for: indexPath) + case .imap(.title): + return self.titleNode(for: indexPath) + case .smtp(.title): + return self.titleNode(for: indexPath) + case .other(.title): + return self.switchNode() + case .connect: + return self.buttonNode() + default: + return self.textFieldNode(for: indexPath) + } } } } @@ -286,6 +292,20 @@ extension SetupImapViewController { IndexPath(row: AccountPart.username.rawValue, section: Section.account(.username).section) } + private func reloadImapSection() { + node.reloadSections( + IndexSet(integer: Section.imap(.port).section), + with: .none + ) + } + + private func reloadSmtpSection() { + node.reloadSections( + IndexSet(integer: Section.smtp(.port).section), + with: .none + ) + } + private func reloadSessionCredentials() { node.reloadSections( IndexSet(integersIn: Section.imap(.port).section...Section.smtp(.port).section), @@ -325,12 +345,12 @@ extension SetupImapViewController { user.imap?.connectionType = connections[0].rawValue case (.imap(.security), .didEndEditing): updateUserImapCredentials() - reloadSessionCredentials() + reloadImapSection() case (.smtp(.security), .didBeginEditing): user.smtp?.connectionType = connections[0].rawValue case (.smtp(.security), .didEndEditing): updateUserSmtpCredentials() - reloadSessionCredentials() + reloadSmtpSection() case (.other(.name), .didEndEditing(let name)): user.smtp?.username = name ?? user.name case (.other(.password), .didEndEditing(let password)): @@ -393,7 +413,7 @@ extension SetupImapViewController { switch settings { case let .failure(.notFound(defaultPort)): - user.imap?.port = defaultPort + user.imap?.port = user.imap?.port ?? defaultPort case let .success(imapSetting): updateUser(imap: imapSetting) } @@ -408,7 +428,7 @@ extension SetupImapViewController { switch settings { case let .failure(.notFound(defaultPort)): - user.smtp?.port = defaultPort + user.smtp?.port = user.smtp?.port ?? defaultPort case let .success(imapSetting): updateUser(smtp: imapSetting) } @@ -463,6 +483,8 @@ extension SetupImapViewController { // MARK: - Connect extension SetupImapViewController { private func connect() { + view.endEditing(true) + let result = checkCurrentUser() switch result { case .failure(.empty): diff --git a/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift b/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift index 846055879..fe7c2d4ac 100644 --- a/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift +++ b/FlowCrypt/Controllers/SetupImap/SetupImapViewDecorator.swift @@ -68,6 +68,7 @@ struct SetupImapViewDecorator { let placeholder: String? var isSecure = false var keyboardType: UIKeyboardType = .default + var accessibilityIdentifier: String? switch section { case let .account(part): @@ -75,38 +76,50 @@ struct SetupImapViewDecorator { case .email: placeholder = "Email" keyboardType = .emailAddress + accessibilityIdentifier = "Email" case .password: placeholder = "Password" isSecure = true + accessibilityIdentifier = "Password" case .username: placeholder = "Username" case .title: placeholder = nil } + + // IMAP case let .imap(part): switch part { case .port: placeholder = "IMAP port" keyboardType = .numberPad + accessibilityIdentifier = "IMAP port" case .security: placeholder = "Security type" + accessibilityIdentifier = "IMAP type" case .server: placeholder = "IMAP server" case .title: placeholder = nil } + + // SMTP case let .smtp(part): switch part { case .port: placeholder = "SMTP port" keyboardType = .numberPad + accessibilityIdentifier = "SMTP port" case .security: placeholder = "Security type" + accessibilityIdentifier = "SMTP type" case .server: placeholder = "SMTP server" case .title: placeholder = nil } + + // OTHER case let .other(part): switch part { case .name: @@ -131,7 +144,8 @@ struct SetupImapViewDecorator { darkStyle: .darkGray, lightStyle: UIColor(white: 1, alpha: 1) ), - keyboardType: keyboardType + keyboardType: keyboardType, + accessibilityIdentifier: accessibilityIdentifier ) } diff --git a/FlowCrypt/Core/Models/PassPhraseObject.swift b/FlowCrypt/Core/Models/PassPhraseObject.swift index 563c232a7..197a54521 100644 --- a/FlowCrypt/Core/Models/PassPhraseObject.swift +++ b/FlowCrypt/Core/Models/PassPhraseObject.swift @@ -22,7 +22,7 @@ final class PassPhraseObject: Object { self.value = value self.allFingerprints.append(objectsIn: fingerprints) } - + override class func primaryKey() -> String? { "value" } diff --git a/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift b/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift index e2227599a..8f75d74cb 100644 --- a/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift +++ b/FlowCrypt/Functionality/Mail Provider/Imap/Imap+session.swift @@ -29,34 +29,21 @@ extension Imap { logger.logInfo("Creating a new IMAP session") let newImapSession = MCOIMAPSession(session: imap) imapSess = newImapSession - logIMAPConnection(for: imapSess!) + .log() } if let smtp = smtpSession { logger.logInfo("Creating a new SMTP session") let newSmtpSession = MCOSMTPSession(session: smtp) smtpSess = newSmtpSession - logSMTPConnection(for: smtpSess!) - } - } - - private func logIMAPConnection(for session: MCOIMAPSession) { - session.connectionLogger = { [weak self] connectionID, type, data in - guard let data = data, let string = String(data: data, encoding: .utf8) else { return } - self?.logger.logInfo("connection IMAP :\(type):\(string)") - } - } - - private func logSMTPConnection(for smtpSession: MCOSMTPSession) { - smtpSession.connectionLogger = { [weak self] connectionID, type, data in - guard let data = data, let string = String(data: data, encoding: .utf8) else { return } - self?.logger.logInfo("connection SMTP:\(type):\(string)") + .log() } } func connectSmtp(session: SMTPSession) -> Promise { Promise { resolve, reject in MCOSMTPSession(session: session) + .log() .loginOperation()? .start { error in guard let error = error else { resolve(()); return } @@ -68,6 +55,7 @@ extension Imap { func connectImap(session: IMAPSession) -> Promise { Promise { resolve, reject in MCOIMAPSession(session: session) + .log() .connectOperation()? .start { [weak self] error in guard let error = error else { resolve(()); return } @@ -91,3 +79,23 @@ extension Imap { smtpSess = nil // smtp session has no disconnect method } } + +extension MCOIMAPSession { + func log() -> Self { + connectionLogger = { connectionID, type, data in + guard let data = data, let string = String(data: data, encoding: .utf8) else { return } + Logger.nested("IMAP").logInfo("\(type):\(string)") + } + return self + } +} + +extension MCOSMTPSession { + func log() -> Self { + connectionLogger = { connectionID, type, data in + guard let data = data, let string = String(data: data, encoding: .utf8) else { return } + Logger.nested("SMTP").logInfo("\(type):\(string)") + } + return self + } +} diff --git a/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/providers.json b/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/providers.json index 4fa9e1326..ec67294a8 100644 --- a/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/providers.json +++ b/FlowCrypt/Functionality/Mail Provider/Mail Sessions Providers/providers.json @@ -1,777 +1,798 @@ { - "mobileme":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"mail.me.com", - "ssl":true - }, - { - "port":143, - "hostname":"mail.me.com", - "starttls":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"smtp.me.com", - "starttls":true - } - ] - }, - "domain-match":[ - "me\\.com", - "mac\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "flowcrypt.test":{ + "servers":{ + "imap":[ + { + "port":10143, + "hostname":"217.163.30.119", + "ssl":false, + "starttls":false } + ], + "smtp":[ + { + "port":10025, + "hostname":"217.163.30.119" + } + ] }, - "dreamhost":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"mail.{domain}", - "ssl":true - }, - { - "port":143, - "hostname":"mail.{domain}", - "starttls":true - } - ], - "smtp":[ - { - "port":465, - "hostname":"mail.{domain}", - "ssl":true - }, - { - "port":587, - "hostname":"mail.{domain}", - "starttls":true - }, - { - "port":25, - "hostname":"mail.{domain}", - "starttls":true - } - ] - }, - "mx":[ - "mx1.sub4.homie.mail.dreamhost.com", - "mx2.sub4.homie.mail.dreamhost.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "flowcrypt.test" + ] + }, + "mobileme":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"mail.me.com", + "ssl":true + }, + { + "port":143, + "hostname":"mail.me.com", + "starttls":true + } + ], + "smtp":[ + { + "port":587, + "hostname":"smtp.me.com", + "starttls":true } + ] }, - "insecure-default":{ - "servers":{ - "imap":[ - { - "port":143, - "starttls":true - }, - { - "port":143 - } - ], - "smtp":[ - { - "port":587, - "starttls":true - }, - { - "port":25, - "starttls":true - }, - { - "port":587 - }, - { - "port":25 - } - ] - }, - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "me\\.com", + "mac\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "dreamhost":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"mail.{domain}", + "ssl":true + }, + { + "port":143, + "hostname":"mail.{domain}", + "starttls":true } + ], + "smtp":[ + { + "port":465, + "hostname":"mail.{domain}", + "ssl":true + }, + { + "port":587, + "hostname":"mail.{domain}", + "starttls":true + }, + { + "port":25, + "hostname":"mail.{domain}", + "starttls":true + } + ] }, - "euro-apple":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"phonehome.euro.apple.com", - "ssl":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"phonehome.apple.com", - "starttls":true - } - ] - }, - "domain-match":[ - "euro\\.apple\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "mx":[ + "mx1.sub4.homie.mail.dreamhost.com", + "mx2.sub4.homie.mail.dreamhost.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "insecure-default":{ + "servers":{ + "imap":[ + { + "port":143, + "starttls":true + }, + { + "port":143 } + ], + "smtp":[ + { + "port":587, + "starttls":true + }, + { + "port":25, + "starttls":true + }, + { + "port":587 + }, + { + "port":25 + } + ] }, - "default":{ - "servers":{ - "imap":[ - { - "port":993, - "ssl":true - }, - { - "port":143, - "starttls":true - } - ], - "smtp":[ - { - "port":465, - "ssl":true - }, - { - "port":587, - "starttls":true - }, - { - "port":25, - "starttls":true - } - ] - }, - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "euro-apple":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"phonehome.euro.apple.com", + "ssl":true + } + ], + "smtp":[ + { + "port":587, + "hostname":"phonehome.apple.com", + "starttls":true } + ] }, - "insecure-fixed-port":{ - "servers":{ - "imap":[ - { - "starttls":true - }, - { - - } - ], - "smtp":[ - { - "starttls":true - }, - { - - } - ] - }, - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "euro\\.apple\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "default":{ + "servers":{ + "imap":[ + { + "port":993, + "ssl":true + }, + { + "port":143, + "starttls":true + } + ], + "smtp":[ + { + "port":465, + "ssl":true + }, + { + "port":587, + "starttls":true + }, + { + "port":25, + "starttls":true } + ] }, - "aol":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"imap.aol.com", - "ssl":true - }, - { - "port":143, - "hostname":"imap.aol.com", - "starttls":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"smtp.aol.com", - "starttls":true - }, - { - "port":465, - "hostname":"smtp.aol.com", - "ssl":true - }, - { - "port":25, - "hostname":"smtp.aol.com", - "starttls":true - } - ] - }, - "domain-match":[ - "aim\\.com", - "aol\\..*", - "jp\\.aol\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Saved", - "spam":"Spam", - "sentmail":"Sent", - "trash":"Trash" + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "insecure-fixed-port":{ + "servers":{ + "imap":[ + { + "starttls":true + }, + { + + } + ], + "smtp":[ + { + "starttls":true + }, + { + + } + ] + }, + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "aol":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"imap.aol.com", + "ssl":true + }, + { + "port":143, + "hostname":"imap.aol.com", + "starttls":true + } + ], + "smtp":[ + { + "port":587, + "hostname":"smtp.aol.com", + "starttls":true + }, + { + "port":465, + "hostname":"smtp.aol.com", + "ssl":true + }, + { + "port":25, + "hostname":"smtp.aol.com", + "starttls":true } + ] }, - "yahoo":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"imap.mail.yahoo.com", - "ssl":true - }, - { - "port":143, - "hostname":"imap.mail.yahoo.com", - "starttls":true - } - ], - "smtp":[ - { - "port":465, - "hostname":"smtp.mail.yahoo.com", - "ssl":true - } - ] - }, - "domain-match":[ - "yahoo\\..*", - "ymail\\.com", - "rocketmail\\.com", - "xtra\\.co\\.nz" - ], - "mailboxes":{ - "drafts":"Draft", - "allmail":"Archive", - "spam":"Bulk Mail", - "sentmail":"Sent", - "trash":"Trash" + "domain-match":[ + "aim\\.com", + "aol\\..*", + "jp\\.aol\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Saved", + "spam":"Spam", + "sentmail":"Sent", + "trash":"Trash" + } + }, + "yahoo":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"imap.mail.yahoo.com", + "ssl":true + }, + { + "port":143, + "hostname":"imap.mail.yahoo.com", + "starttls":true } + ], + "smtp":[ + { + "port":465, + "hostname":"smtp.mail.yahoo.com", + "ssl":true + } + ] }, - "ukr": { - "servers":{ - "imap":[ - { - "port":993, - "hostname":"imap.ukr.net", - "ssl":true - } - ], - "smtp":[ - { - "port":465, - "hostname":"smtp.ukr.net", - "ssl":true - } - ] - }, - "domain-match":["ukr.net"] + "domain-match":[ + "yahoo\\..*", + "ymail\\.com", + "rocketmail\\.com", + "xtra\\.co\\.nz" + ], + "mailboxes":{ + "drafts":"Draft", + "allmail":"Archive", + "spam":"Bulk Mail", + "sentmail":"Sent", + "trash":"Trash" + } + }, + "ukr": { + "servers":{ + "imap":[ + { + "port":993, + "hostname":"imap.ukr.net", + "ssl":true + } + ], + "smtp":[ + { + "port":465, + "hostname":"smtp.ukr.net", + "ssl":true + } + ] }, - "outlook": { - "servers":{ - "imap":[ - { - "port":993, - "hostname":"outlook.office365.com", - "tls":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"smtp.office365.com", - "starttls":true - } - ] - }, - "domain-match":["outlook.com"] + "domain-match":["ukr.net"] + }, + "outlook": { + "servers":{ + "imap":[ + { + "port":993, + "hostname":"outlook.office365.com", + "tls":true + } + ], + "smtp":[ + { + "port":587, + "hostname":"smtp.office365.com", + "starttls":true + } + ] }, - "gmail":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"imap.gmail.com", - "ssl":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"smtp.gmail.com", - "starttls":true - }, - { - "port":465, - "hostname":"smtp.gmail.com", - "ssl":true - }, - { - "port":25, - "hostname":"smtp.gmail.com", - "starttls":true - } - ] - }, - "mx":[ - "aspmx2.googlemail.com", - "aspmx.l.google.com", - "aspmx3.googlemail.com", - "alt1.aspmx.l.google.com", - "alt2.aspmx.l.google.com" - ], - "domain-match":[ - "googlemail\\.com", - "gmail\\.com" - ] + "domain-match":["outlook.com"] + }, + "gmail":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"imap.gmail.com", + "ssl":true + } + ], + "smtp":[ + { + "port":587, + "hostname":"smtp.gmail.com", + "starttls":true + }, + { + "port":465, + "hostname":"smtp.gmail.com", + "ssl":true + }, + { + "port":25, + "hostname":"smtp.gmail.com", + "starttls":true + } + ] }, - "gmx":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"imap.gmx.com", - "ssl":true - }, - { - "port":143, - "hostname":"imap.gmx.com", - "starttls":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"mail.gmx.com", - "starttls":true - }, - { - "port":465, - "hostname":"mail.gmx.com", - "ssl":true - }, - { - "port":25, - "hostname":"mail.gmx.com", - "starttls":true - } - ] - }, - "domain-match":[ - "gmx\\..*", - "caramail\\..*" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Spam", - "sentmail":"Sent", - "trash":"Trash" + "mx":[ + "aspmx2.googlemail.com", + "aspmx.l.google.com", + "aspmx3.googlemail.com", + "alt1.aspmx.l.google.com", + "alt2.aspmx.l.google.com" + ], + "domain-match":[ + "googlemail\\.com", + "gmail\\.com" + ] + }, + "gmx":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"imap.gmx.com", + "ssl":true + }, + { + "port":143, + "hostname":"imap.gmx.com", + "starttls":true } + ], + "smtp":[ + { + "port":587, + "hostname":"mail.gmx.com", + "starttls":true + }, + { + "port":465, + "hostname":"mail.gmx.com", + "ssl":true + }, + { + "port":25, + "hostname":"mail.gmx.com", + "starttls":true + } + ] }, - "fastmail":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"mail.messagingengine.com", - "ssl":true - }, - { - "port":143, - "hostname":"mail.messagingengine.com", - "starttls":true - } - ], - "smtp":[ - { - "port":587, - "hostname":"mail.messagingengine.com", - "starttls":true - }, - { - "port":465, - "hostname":"mail.messagingengine.com", - "ssl":true - }, - { - "port":25, - "hostname - 2":"mail.messagingengine.com", - "starttls":true - } - ] - }, - "domain-match":[ - "123mail\\.org", - "fastmail\\..*", - "airpost\\.net", - "eml\\.cc", - "fmail\\.co\\.uk", - "fmgirl\\.com", - "fmguy\\.com", - "mailbolt\\.com", - "mailcan\\.com", - "mailhaven\\.com", - "mailmight\\.com", - "ml1\\.net", - "mm\\.st", - "myfastmail\\.com", - "proinbox\\.com", - "promessage\\.com", - "rushpost\\.com", - "sent\\.as", - "sent\\.at", - "sent\\.com", - "speedymail\\.org", - "warpmail\\.net", - "xsmail\\.com", - "150mail\\.com", - "150ml\\.com", - "16mail\\.com", - "2-mail\\.com", - "4email\\.net", - "50mail\\.com", - "allmail\\.net", - "bestmail\\.us", - "cluemail\\.com", - "elitemail\\.org", - "emailcorner\\.net", - "emailengine\\.net", - "emailengine\\.org", - "emailgroups\\.net", - "emailplus\\.org", - "emailuser\\.net", - "f-m\\.fm", - "fast-email\\.com", - "fast-mail\\.org", - "fastem\\.com", - "fastemail\\.us", - "fastemailer\\.com", - "fastest\\.cc", - "fastimap\\.com", - "fastmailbox\\.net", - "fastmessaging\\.com", - "fea\\.st", - "fmailbox\\.com", - "ftml\\.net", - "h-mail\\.us", - "hailmail\\.net", - "imap-mail\\.com", - "imap\\.cc", - "imapmail\\.org", - "inoutbox\\.com", - "internet-e-mail\\.com", - "internet-mail\\.org", - "internetemails\\.net", - "internetmailing\\.net", - "jetemail\\.net", - "justemail\\.net", - "letterboxes\\.org", - "mail-central\\.com", - "mail-page\\.com", - "mailandftp\\.com", - "mailas\\.com", - "mailc\\.net", - "mailforce\\.net", - "mailftp\\.com", - "mailingaddress\\.org", - "mailite\\.com", - "mailnew\\.com", - "mailsent\\.net", - "mailservice\\.ms", - "mailup\\.net", - "mailworks\\.org", - "mymacmail\\.com", - "nospammail\\.net", - "ownmail\\.net", - "petml\\.com", - "postinbox\\.com", - "postpro\\.net", - "realemail\\.net", - "reallyfast\\.biz", - "reallyfast\\.info", - "speedpost\\.net", - "ssl-mail\\.com", - "swift-mail\\.com", - "the-fastest\\.net", - "the-quickest\\.com", - "theinternetemail\\.com", - "veryfast\\.biz", - "veryspeedy\\.net", - "yepmail\\.net", - "your-mail\\.com", - "operamail\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk Mail", - "sentmail":"Sent Items", - "trash":"Trash" + "domain-match":[ + "gmx\\..*", + "caramail\\..*" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Spam", + "sentmail":"Sent", + "trash":"Trash" + } + }, + "fastmail":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"mail.messagingengine.com", + "ssl":true + }, + { + "port":143, + "hostname":"mail.messagingengine.com", + "starttls":true } + ], + "smtp":[ + { + "port":587, + "hostname":"mail.messagingengine.com", + "starttls":true + }, + { + "port":465, + "hostname":"mail.messagingengine.com", + "ssl":true + }, + { + "port":25, + "hostname - 2":"mail.messagingengine.com", + "starttls":true + } + ] }, - "apple":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"phonehome.apple.com", - "ssl":true - } - ], - "smtp":[ - { - "port":465, - "tls":true, - "hostname":"phonehome.apple.com" - }, - { - "port":587, - "hostname":"phonehome.apple.com", - "starttls":true - } - ] - }, - "domain-match":[ - "apple\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "123mail\\.org", + "fastmail\\..*", + "airpost\\.net", + "eml\\.cc", + "fmail\\.co\\.uk", + "fmgirl\\.com", + "fmguy\\.com", + "mailbolt\\.com", + "mailcan\\.com", + "mailhaven\\.com", + "mailmight\\.com", + "ml1\\.net", + "mm\\.st", + "myfastmail\\.com", + "proinbox\\.com", + "promessage\\.com", + "rushpost\\.com", + "sent\\.as", + "sent\\.at", + "sent\\.com", + "speedymail\\.org", + "warpmail\\.net", + "xsmail\\.com", + "150mail\\.com", + "150ml\\.com", + "16mail\\.com", + "2-mail\\.com", + "4email\\.net", + "50mail\\.com", + "allmail\\.net", + "bestmail\\.us", + "cluemail\\.com", + "elitemail\\.org", + "emailcorner\\.net", + "emailengine\\.net", + "emailengine\\.org", + "emailgroups\\.net", + "emailplus\\.org", + "emailuser\\.net", + "f-m\\.fm", + "fast-email\\.com", + "fast-mail\\.org", + "fastem\\.com", + "fastemail\\.us", + "fastemailer\\.com", + "fastest\\.cc", + "fastimap\\.com", + "fastmailbox\\.net", + "fastmessaging\\.com", + "fea\\.st", + "fmailbox\\.com", + "ftml\\.net", + "h-mail\\.us", + "hailmail\\.net", + "imap-mail\\.com", + "imap\\.cc", + "imapmail\\.org", + "inoutbox\\.com", + "internet-e-mail\\.com", + "internet-mail\\.org", + "internetemails\\.net", + "internetmailing\\.net", + "jetemail\\.net", + "justemail\\.net", + "letterboxes\\.org", + "mail-central\\.com", + "mail-page\\.com", + "mailandftp\\.com", + "mailas\\.com", + "mailc\\.net", + "mailforce\\.net", + "mailftp\\.com", + "mailingaddress\\.org", + "mailite\\.com", + "mailnew\\.com", + "mailsent\\.net", + "mailservice\\.ms", + "mailup\\.net", + "mailworks\\.org", + "mymacmail\\.com", + "nospammail\\.net", + "ownmail\\.net", + "petml\\.com", + "postinbox\\.com", + "postpro\\.net", + "realemail\\.net", + "reallyfast\\.biz", + "reallyfast\\.info", + "speedpost\\.net", + "ssl-mail\\.com", + "swift-mail\\.com", + "the-fastest\\.net", + "the-quickest\\.com", + "theinternetemail\\.com", + "veryfast\\.biz", + "veryspeedy\\.net", + "yepmail\\.net", + "your-mail\\.com", + "operamail\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk Mail", + "sentmail":"Sent Items", + "trash":"Trash" + } + }, + "apple":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"phonehome.apple.com", + "ssl":true } + ], + "smtp":[ + { + "port":465, + "tls":true, + "hostname":"phonehome.apple.com" + }, + { + "port":587, + "hostname":"phonehome.apple.com", + "starttls":true + } + ] }, - "asia-apple":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"phonehome.asia.apple.com", - "ssl":true - } - ], - "smtp":[ - { - "port":465, - "tls":true, - "hostname":"phonehome.asia.apple.com" - }, - { - "port":587, - "hostname":"phonehome.asia.apple.com", - "starttls":true - } - ] - }, - "domain-match":[ - "asia\\.apple\\.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "apple\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "asia-apple":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"phonehome.asia.apple.com", + "ssl":true } + ], + "smtp":[ + { + "port":465, + "tls":true, + "hostname":"phonehome.asia.apple.com" + }, + { + "port":587, + "hostname":"phonehome.asia.apple.com", + "starttls":true + } + ] }, - "rackspace":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"secure.emailsrvr.com", - "ssl":true - }, - { - "port":143, - "hostname":"secure.emailsrvr.com", - "starttls":true - }, - { - "port":143, - "hostname":"secure.emailsrvr.com" - } - ], - "smtp":[ - { - "port":465, - "hostname":"secure.emailsrvr.com", - "ssl":true - }, - { - "port":587, - "hostname":"secure.emailsrvr.com", - "starttls":true - }, - { - "port":25, - "hostname":"secure.emailsrvr.com", - "starttls":true - }, - { - "port":587, - "hostname":"secure.emailsrvr.com" - }, - { - "port":25, - "hostname":"secure.emailsrvr.com" - } - ] - }, - "mx":[ - "mx1.emailsrvr.com", - "mx2.emailsrvr.com" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "domain-match":[ + "asia\\.apple\\.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "rackspace":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"secure.emailsrvr.com", + "ssl":true + }, + { + "port":143, + "hostname":"secure.emailsrvr.com", + "starttls":true + }, + { + "port":143, + "hostname":"secure.emailsrvr.com" } + ], + "smtp":[ + { + "port":465, + "hostname":"secure.emailsrvr.com", + "ssl":true + }, + { + "port":587, + "hostname":"secure.emailsrvr.com", + "starttls":true + }, + { + "port":25, + "hostname":"secure.emailsrvr.com", + "starttls":true + }, + { + "port":587, + "hostname":"secure.emailsrvr.com" + }, + { + "port":25, + "hostname":"secure.emailsrvr.com" + } + ] }, - "zimbra":{ - "servers":{ - "imap":[ - { - "port":993, - "ssl":true - }, - { - "port":143, - "starttls":true - } - ], - "smtp":[ - { - "port":587, - "starttls":true - }, - { - "port":465, - "ssl":true - }, - { - "port":25, - "starttls":true - } - ] - }, - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent", - "trash":"Trash" + "mx":[ + "mx1.emailsrvr.com", + "mx2.emailsrvr.com" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "zimbra":{ + "servers":{ + "imap":[ + { + "port":993, + "ssl":true + }, + { + "port":143, + "starttls":true + } + ], + "smtp":[ + { + "port":587, + "starttls":true + }, + { + "port":465, + "ssl":true + }, + { + "port":25, + "starttls":true } + ] }, - "ovh":{ - "servers":{ - "imap":[ - { - "port":993, - "hostname":"mail.{domain}", - "ssl":true - }, - { - "port":143, - "hostname":"mail.{domain}" - } - ], - "smtp":[ - { - "port":465, - "hostname":"mail.{domain}", - "ssl":true - }, - { - "port":587, - "hostname":"mail.{domain}" - }, - { - "port":25, - "hostname":"mail.{domain}" - } - ] - }, - "mx":[ - "mx0.ovh.net", - "mx1.ovh.net", - "mx2.ovh.net", - "mx3.ovh.net", - "mx4.ovh.net" - ], - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent", + "trash":"Trash" + } + }, + "ovh":{ + "servers":{ + "imap":[ + { + "port":993, + "hostname":"mail.{domain}", + "ssl":true + }, + { + "port":143, + "hostname":"mail.{domain}" + } + ], + "smtp":[ + { + "port":465, + "hostname":"mail.{domain}", + "ssl":true + }, + { + "port":587, + "hostname":"mail.{domain}" + }, + { + "port":25, + "hostname":"mail.{domain}" } + ] }, - "fixed-port":{ - "servers":{ - "imap":[ - { - "ssl":true - }, - { - "starttls":true - } - ], - "smtp":[ - { - "starttls":true - }, - { - "ssl":true - } - ] - }, - "mailboxes":{ - "drafts":"Drafts", - "allmail":"Archive", - "spam":"Junk", - "sentmail":"Sent Messages", - "trash":"Deleted Messages" + "mx":[ + "mx0.ovh.net", + "mx1.ovh.net", + "mx2.ovh.net", + "mx3.ovh.net", + "mx4.ovh.net" + ], + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" + } + }, + "fixed-port":{ + "servers":{ + "imap":[ + { + "ssl":true + }, + { + "starttls":true } + ], + "smtp":[ + { + "starttls":true + }, + { + "ssl":true + } + ] + }, + "mailboxes":{ + "drafts":"Drafts", + "allmail":"Archive", + "spam":"Junk", + "sentmail":"Sent Messages", + "trash":"Deleted Messages" } + } } diff --git a/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/Imap+folders.swift b/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/Imap+folders.swift index c379c1658..e20dc3678 100644 --- a/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/Imap+folders.swift +++ b/FlowCrypt/Functionality/Services/Folders Services/RemoteFoldersProviderType/Imap+folders.swift @@ -6,6 +6,7 @@ // Copyright © 2019 FlowCrypt Limited. All rights reserved. // +import FlowCryptCommon import Foundation import Promises @@ -27,7 +28,10 @@ extension Imap: RemoteFoldersProviderType { guard let folders = value as? [MCOIMAPFolder] else { return reject(AppErr.cast("[MCOIMAPFolder]")) } - resolve(folders.compactMap(FolderObject.init)) + + // TODO: - Ticket - rework usage of EncryptedStorage().activeUser + let folderObjects = folders.compactMap { FolderObject(with: $0, user: EncryptedStorage().activeUser) } + resolve(folderObjects) } } } @@ -35,10 +39,13 @@ extension Imap: RemoteFoldersProviderType { // MARK: - Convenience private extension FolderObject { - convenience init?(with folder: MCOIMAPFolder, user: UserObject) { - guard let name = folder.name else { return nil } + convenience init?(with folder: MCOIMAPFolder, user: UserObject?) { + guard let user = user else { + Logger.logError("Can't initialise FolderObject without user") + return nil + } self.init( - name: name, + name: folder.name ?? folder.path, path: folder.path, image: nil, user: user diff --git a/FlowCryptUI/Cell Nodes/TextFieldCellNode.swift b/FlowCryptUI/Cell Nodes/TextFieldCellNode.swift index 3b0c8cf74..688d2a75f 100644 --- a/FlowCryptUI/Cell Nodes/TextFieldCellNode.swift +++ b/FlowCryptUI/Cell Nodes/TextFieldCellNode.swift @@ -20,6 +20,7 @@ public final class TextFieldCellNode: CellNode { public var width: CGFloat? public var backgroundColor: UIColor? public var keyboardType: UIKeyboardType + public let accessibilityIdentifier: String? public init( placeholder: NSAttributedString = NSAttributedString(string: "PLACEHOLDER"), @@ -31,7 +32,8 @@ public final class TextFieldCellNode: CellNode { height: CGFloat = 40, width: CGFloat? = nil, backgroundColor: UIColor? = nil, - keyboardType: UIKeyboardType = .default + keyboardType: UIKeyboardType = .default, + accessibilityIdentifier: String? = nil ) { self.placeholder = placeholder self.isSecureTextEntry = isSecureTextEntry @@ -43,6 +45,7 @@ public final class TextFieldCellNode: CellNode { self.width = width self.backgroundColor = backgroundColor self.keyboardType = keyboardType + self.accessibilityIdentifier = accessibilityIdentifier } } @@ -65,7 +68,11 @@ public final class TextFieldCellNode: CellNode { } public init(input: Input, action: TextFieldAction? = nil) { - textField = TextFieldNode(preferredHeight: input.height, action: action) + textField = TextFieldNode( + preferredHeight: input.height, + action: action, + accessibilityIdentifier: input.accessibilityIdentifier + ) self.input = input super.init() textFiledAction = action @@ -75,6 +82,7 @@ public final class TextFieldCellNode: CellNode { textField.textAlignment = input.textAlignment textField.textInsets = input.textInsets textField.keyboardType = input.keyboardType + textField.accessibilityIdentifier = input.accessibilityIdentifier if let color = input.backgroundColor { backgroundColor = color } diff --git a/FlowCryptUI/Nodes/TextFieldNode.swift b/FlowCryptUI/Nodes/TextFieldNode.swift index 75a3ba883..c678e2896 100644 --- a/FlowCryptUI/Nodes/TextFieldNode.swift +++ b/FlowCryptUI/Nodes/TextFieldNode.swift @@ -121,15 +121,15 @@ public final class TextFieldNode: ASDisplayNode { private var textFiledAction: TextFieldAction? private var onToolbarDoneAction: (() -> Void)? - - public init(preferredHeight: CGFloat?, action: TextFieldAction? = nil) { + + public init(preferredHeight: CGFloat?, action: TextFieldAction? = nil, accessibilityIdentifier: String?) { super.init() addSubnode(node) textFiledAction = action - setupTextField() + setupTextField(with: accessibilityIdentifier) } - private func setupTextField() { + private func setupTextField(with accessibilityIdentifier: String?) { DispatchQueue.main.async { self.textField.delegate = self self.textField.addTarget( @@ -141,6 +141,7 @@ public final class TextFieldNode: ASDisplayNode { guard let self = self else { return } self.textFiledAction?(.deleteBackward(self.textField)) } + self.textField.accessibilityIdentifier = accessibilityIdentifier } } diff --git a/FlowCryptUITests/Gmail.xctestplan b/FlowCryptUITests/Gmail.xctestplan new file mode 100644 index 000000000..add669d56 --- /dev/null +++ b/FlowCryptUITests/Gmail.xctestplan @@ -0,0 +1,38 @@ +{ + "configurations" : [ + { + "id" : "BC9E93DD-67F2-4920-AC82-5E2BB79F8DE4", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + "codeCoverage" : false, + "commandLineArgumentEntries" : [ + { + "argument" : "-AppleLanguages (en-US)" + }, + { + "argument" : "-AppleLocale en_US" + } + ], + "language" : "en", + "region" : "GB" + }, + "testTargets" : [ + { + "skippedTests" : [ + "SignInImapTest", + "SignInTest" + ], + "target" : { + "containerPath" : "container:FlowCrypt.xcodeproj", + "identifier" : "9FDF3640235A1B0100614596", + "name" : "FlowCryptUITests" + } + } + ], + "version" : 1 +} diff --git a/FlowCryptUITests/Imap.xctestplan b/FlowCryptUITests/Imap.xctestplan new file mode 100644 index 000000000..9ef407862 --- /dev/null +++ b/FlowCryptUITests/Imap.xctestplan @@ -0,0 +1,27 @@ +{ + "configurations" : [ + { + "id" : "B820487B-6581-49C7-83FE-216731F04DA6", + "name" : "Configuration 1", + "options" : { + + } + } + ], + "defaultOptions" : { + + }, + "testTargets" : [ + { + "skippedTests" : [ + "SignInGoogleTest" + ], + "target" : { + "containerPath" : "container:FlowCrypt.xcodeproj", + "identifier" : "9FDF3640235A1B0100614596", + "name" : "FlowCryptUITests" + } + } + ], + "version" : 1 +} diff --git a/FlowCryptUITests/Resources/AppTestHelper.swift b/FlowCryptUITests/Resources/AppTestHelper.swift index a545a4cb0..ce5852c73 100644 --- a/FlowCryptUITests/Resources/AppTestHelper.swift +++ b/FlowCryptUITests/Resources/AppTestHelper.swift @@ -47,7 +47,6 @@ extension AppTest { } // MARK: - Actions -private let logger = Logger.nested("UI Tests") extension AppTest { func sendMessage(to recipient: String ) { @@ -96,36 +95,6 @@ extension AppTest { _ = app.keys["\n"] } } - - func login(_ user: UserCredentials) { - logger.logInfo("Login with \(user.email)") - - // other account - logOutIfNeeded() - wait(0.3) - - logger.logInfo("Use other email provider") - let otherEmailButton = app.tables.buttons["Other email provider"] - otherEmailButton.tap() - - logger.logInfo("Fill all user credentials") - // email - let emailTextField = app.tables.textFields["Email"] - emailTextField.tap() - emailTextField.typeText(user.email) - - // password - let passwordTextField = app.tables.secureTextFields["Password"] - passwordTextField.tap() - passwordTextField.typeText(user.password) - - // connect - passwordTextField.swipeUp() - app.tables.buttons["Connect"].tap() - - logger.logInfo("Try to connect") - wait(10) - } func logOutIfNeeded() { logger.logInfo("Log out if needed") diff --git a/FlowCryptUITests/Resources/UserCredentials.swift b/FlowCryptUITests/Resources/UserCredentials.swift index 6283ba757..0d04bd6e2 100644 --- a/FlowCryptUITests/Resources/UserCredentials.swift +++ b/FlowCryptUITests/Resources/UserCredentials.swift @@ -17,29 +17,17 @@ struct UserCredentials: Codable, Equatable { static var empty = UserCredentials(email: "", password: "", pass: "", recovery: "", privateKey: "") - static var gmailDev: UserCredentials = { - Credentials.default - .users - .first(where: { $0.email == "ci.tests.gmail@flowcrypt.dev" })! - }() + /// ci.tests.gmail@flowcrypt.dev + static var gmailDev: UserCredentials = .user(with: "ci.tests.gmail@flowcrypt.dev") - static var main: UserCredentials = { - Credentials.default - .users - .first(where: { $0.email == "cryptup.tester@gmail.com" })! - }() - - static var noKeyBackUp: UserCredentials = { - Credentials.default - .users - .first(where: { $0.email == "flowcrypt.compatibility.ios.nokey@outlook.com" })! - }() - - static var compatibility: UserCredentials = { + /// default@flowcrypt.test + static var imapDev: UserCredentials = .user(with: "default@flowcrypt.test") + + static func user(with email: String) -> UserCredentials { Credentials.default .users - .first(where: { $0.email == "flowcrypt_compatibility_ios@outlook.com" })! - }() + .first(where: { $0.email == email })! + } } struct Credentials: Codable { diff --git a/FlowCryptUITests/SignInGoogleTest.swift b/FlowCryptUITests/SignInGoogleTest.swift index bc224ad56..8887eb4ee 100644 --- a/FlowCryptUITests/SignInGoogleTest.swift +++ b/FlowCryptUITests/SignInGoogleTest.swift @@ -9,11 +9,8 @@ import XCTest import FlowCryptCommon -private let logger = Logger.nested("UI Tests. Google") - class SignInGoogleTest: XCTestCase, AppTest { var app: XCUIApplication! - let user = UserCredentials.main override func setUp() { continueAfterFailure = false diff --git a/FlowCryptUITests/SignInImapTest.swift b/FlowCryptUITests/SignInImapTest.swift new file mode 100644 index 000000000..11b8f8a64 --- /dev/null +++ b/FlowCryptUITests/SignInImapTest.swift @@ -0,0 +1,364 @@ +// +// SignInViewControllerTest.swift +// FlowCryptUITests +// +// Created by Anton Kharchevskyi on 18.10.2019. +// Copyright © 2019 FlowCrypt Limited. All rights reserved. +// + +import XCTest +import FlowCryptCommon + +/// make ui_tests_imap +class SignInImapTest: XCTestCase, AppTest { + var app: XCUIApplication! + + override func setUp() { + continueAfterFailure = false + + logger.logInfo("Start App") + + app = XCUIApplicationBuilder() + .setupRegion() + .build() + .addSnapshot() + .launched() + + logger.logInfo("Wait for launch") + wait(10) + } +} + +// MARK: - Tests +extension SignInImapTest { + // login -> approve -> backups found -> enter pass phrase -> main flow + func test_1_successful_login_imap() { + let user = UserCredentials.imapDev + loginWithImap(user) + + passPhraseTextField.tap() + passPhraseTextField.typeText(user.pass) + goKeyboardButton.tap() + + wait(4) + XCTAssert(app.buttons["+"].exists) + } +} + +// MARK: - Convenience +extension SignInImapTest { + private var toolbarDoneButton: XCUIElement { + app.toolbars["Toolbar"].buttons["Done"] + } + + private func loginWithImap(_ user: UserCredentials) { + logger.logInfo("Login with \(user.email)") + + // other account + logOutIfNeeded() + wait(0.3) + + logger.logInfo("Use other email provider") + let otherEmailButton = app.tables.buttons["Other email provider"] + otherEmailButton.tap() + + logger.logInfo("Fill all user credentials") + + // email + let emailTextField = app.tables.textFields["Email"] + emailTextField.tap() + emailTextField.typeText(user.email) + wait(1) + + // move focus to username + goKeyboardButton.tap() + wait(1) + + // move focus to password + goKeyboardButton.tap() + app.typeText(user.password) + + // move focus to imap server (filled) + goKeyboardButton.tap() + + // move focus to imap port + goKeyboardButton.tap() + + // move focus to imap security type. Set none + toolbarDoneButton.tap() + app.pickerWheels["none"].tap() + toolbarDoneButton.tap() + + // move to smtp type + let smtpType = app.tables.textFields["SMTP type"] + smtpType.tap() + app.pickerWheels["none"].tap() + toolbarDoneButton.tap() + + app.tables.buttons["Connect"].tap() + + logger.logInfo("Try to connect") + wait(10) + } +} + +//extension SignInImapTest { +// // log in -> approve -> no backups -> switch email +// func test_1_login_no_backups() { +// // login with user without key backup +// +// login(UserCredentials.noKeyBackUp) +// +// // retry +// let buttons = app.alerts.scrollViews.otherElements.buttons +// buttons["Retry"].tap() +// wait(1) +// +// // switch to a new account +// buttons["Use other account"].tap() +// wait(2) +// +// // login +// test_6_login_good_pass() +// } +// +// func test_2_login_no_backups_generate() { +// // log in -> approve -> no backups -> generate pubkey -> weak pass phrase +// login(UserCredentials.noKeyBackUp) +// wait(1) +// +// let alertButtons = app.alerts.scrollViews.otherElements.buttons +// alertButtons["Create new Private Key"].tap() +// +// passPhraseTextField.tap() +// passPhraseTextField.typeText("Password") +// goKeyboardButton.tap() +// wait(2) +// +// XCTAssert(app.alerts["Error"].exists, "Error alert for weak pass phrase should exist") +// +// app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() +// wait(0.1) +// +// // log in -> approve -> no backups -> generate pubkey -> good pass phrase -> wrong repeat +// passPhraseTextField.tap() +// passPhraseTextField.typeText(user.pass) +// goKeyboardButton.tap() +// wait(2) +// +// app.alerts["Pass Phrase"].scrollViews.otherElements.buttons["OK"].tap() +// XCTAssert(app.alerts["Error"].exists, "Error alert for wrong repeat pass phrase should exist") +// +// app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() +// +// // log in -> approve -> no backups -> generate pubkey -> good pass phrase -> correct repeat -> create key +// passPhraseTextField.tap() +// let pass = user.pass.replacingOccurrences(of: " ", with: "") +// passPhraseTextField.typeText(pass) +// goKeyboardButton.tap() +// wait(2) +// +// // TODO: ANTON - fix this +// let secureTextField = app.alerts["Pass Phrase"].scrollViews.otherElements.collectionViews.cells.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 1).children(matching: .secureTextField).element +// secureTextField.typeText(pass) +// app.alerts["Pass Phrase"].scrollViews.otherElements.buttons["OK"].tap() +// wait(10) +// // Temporary confirm on error alert. +// if app.alerts["Error"].exists { +// app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() +// wait(2) +// } +// +// // delete backups to trash +// cells.forEach { _ in +// tapOnCell() +// app.navigationBars["Inbox"].buttons["Delete"].tap() +// wait(2) +// } +// +// // permanently delete backups +// menuButton.tap() +// tapOnMenu(folder: "Deleted") +// +// cells.forEach { _ in +// tapOnCell() +// self.app.navigationBars["Deleted"].buttons["Delete"].tap() +// self.app.alerts["Are you sure?"].scrollViews.otherElements.buttons["OK"].tap() +// wait(2) +// } +// } +// +// // log in -> cancel for gmail +// func test_3_login_cancel_gmail() { +// logOutIfNeeded() +// snapshot("splash") +// +// app.tables.buttons["gmail"].tap() +// wait(1) +// +// snapshot("auth") +// } +// +// // log in -> cancel +// func test_4_login_cancel() { +// login(user) +// +// let useAnotherAccountButton = app.tables.buttons["Use Another Account"] +// useAnotherAccountButton.tap() +// +// wait(1) +// XCTAssert(app.tables.buttons["Other email provider"].exists) +// } +// +// // log in -> approve -> bad pass phrase +// func test_5_login_bad_pass() { +// login(user) +// +// passPhraseTextField.tap() +// passPhraseTextField.typeText(user.pass + "wrong") +// tapOnGoButton() +// +// wait(0.2) +// let errorAlert = app.alerts["Error"] +// XCTAssert(errorAlert.exists, "Error alert is missing after entering wrong pass phrase") +// errorAlert.scrollViews.otherElements.buttons["OK"].tap() +// wait(0.2) +// +// app.tables.buttons["Use Another Account"].tap() +// } +// +// // log in -> approve -> loaded 1 backup -> good pass phrase -> inbox +// func test_6_login_good_pass() { +// login(user) +// +// passPhraseTextField.tap() +// passPhraseTextField.typeText(user.pass) +// +// snapshot("recover") +// tapOnGoButton() +// +// wait(1) +// XCTAssert(app.navigationBars["Inbox"].exists, "Could not login") +// } +// +// // restart app -> loads inbox +// func test_7_restart_app_load_inbox() { +// wait(1) +// XCTAssert(app.navigationBars["Inbox"].exists, "Inbox is not found after restarting the app") +// snapshot("inbox") +// +// tapOnCompose() +// wait(0.3) +// +// app.typeText("ElonMusk@gmail.com") +// app.tables.textFields["Subject"].tap() +// +// app.tables.textFields["Subject"].tap() +// app.typeText("SpaceX") +// +// snapshot("compose") +// app.navigationBars.buttons["arrow left c"].tap() +// wait(1) +// +// tapOnCell() +// snapshot("message") +// app.navigationBars.buttons["arrow left c"].tap() +// +// wait(1) +// +// menuButton.tap() +// snapshot("menu") +// +// tapOnMenu(folder: "Settings") +// snapshot("settings") +// } +// +// // send new msg -> inbox -> switch to sent -> open sent msg and verify content, recipient, subject +// func test_8_send_message() { +// // send message +// sendMessage(to: user.email) +// XCTAssert(app.navigationBars["Inbox"].exists, "Failed state after Sending message") +// +// // switch to sent +// menuButton.tap() +// +// app.tables +// .staticTexts +// .allElementsBoundByIndex +// .first(where: { $0.label.contains("Sent" ) })? +// .tap() +// +// wait(3) +// +// // open message +// tapOnCell() +// wait(5) +// +// XCTAssert(app.tables.staticTexts[user.email].exists, "Wrong recipient in sent message") +// XCTAssert(app.tables.staticTexts["Some Subject"].exists, "Wrong subject") +// XCTAssert(app.tables.staticTexts["Some text"].exists, "Wrong text") +// } +// +// // move msg to trash -> verify in trash +// func test_9_delete_msg() { +// // Move msg to Trash +// sendMessage(to: user.email) +// tapOnCell() +// +// app.navigationBars.buttons["Delete"].tap() +// wait(1) +// +// // Verify in Trash +// menuButton.tap() +// tapOnMenu(folder: "Deleted") +// XCTAssert(app.tables.cells.otherElements.staticTexts[user.email].exists, "There is no message in deleted") +// +// tapOnCell() +// let buttons = app.navigationBars.buttons +// let backButton = buttons["arrow left c"] +// +// wait(3) +// // Verify buttons in Trash folder +// XCTAssert(buttons["Delete"].exists, "Navigation bar should contain delete button") +// XCTAssert(buttons["help icn"].exists, "Navigation bar should contain help button") +// XCTAssert(backButton.exists, "Navigation bar should contain back button") +// XCTAssert(buttons.count == 3, "back, info, delete buttons should be only") +// +// // Open following first msg +// backButton.tap() +// menuButton.tap() +// tapOnMenu(folder: "Inbox") +// +// tapOnCell() +// } +// +// // move msg to archive -> verify in archive +// func test_10_archive() { +// sendMessage(to: user.email) +// tapOnCell() +// app.navigationBars.buttons["archive"].tap() +// wait(2) +// XCTAssert(app.navigationBars["Inbox"].exists, "Failed in sending message to archive") +// +// menuButton.tap() +// // TODO: ANTON - Archive +//// tapOnMenu(folder: "All Mail") +//// wait(1) +//// +//// XCTAssert(app.tables.staticTexts[user.email].exists, "Wrong recipient in sent message") +//// XCTAssert(app.tables.staticTexts["Some Subject"].exists, "Wrong subject") +// } +// +// // send new msg -> no pubkey +// func test_11_send_message_no_pub_key() { +// wait(2) +// sendMessage(to: "flowcrypt.nopubkey@gmail.com") +// wait(3) +// let errorAlert = app.alerts["Error"] +// XCTAssert(errorAlert.exists) +// } +//} + +/* + log in -> approve -> no backups -> generate pubkey -> switch accounts + */ diff --git a/FlowCryptUITests/SignInTest.swift b/FlowCryptUITests/SignInTest.swift deleted file mode 100644 index a620426d9..000000000 --- a/FlowCryptUITests/SignInTest.swift +++ /dev/null @@ -1,296 +0,0 @@ -// -// SignInViewControllerTest.swift -// FlowCryptUITests -// -// Created by Anton Kharchevskyi on 18.10.2019. -// Copyright © 2019 FlowCrypt Limited. All rights reserved. -// - -import XCTest -import FlowCryptCommon - -// TODO: - Tests for "Other email account" are temporary removed from FlowCryptUITests -private let logger = Logger.nested("UI Tests") - -// MARK: - Compatibility account - -class SignInTest: XCTestCase, AppTest { - var app: XCUIApplication! - private let user = UserCredentials.compatibility - - override func setUp() { - continueAfterFailure = false - - logger.logInfo("Start App") - - app = XCUIApplicationBuilder() - .setupRegion() - .build() - .addSnapshot() - .launched() - - logger.logInfo("Wait for launch") - wait(10) - } -} - -extension SignInTest { - // log in -> approve -> no backups -> switch email - func test_1_login_no_backups() { - // login with user without key backup - - login(UserCredentials.noKeyBackUp) - - // retry - let buttons = app.alerts.scrollViews.otherElements.buttons - buttons["Retry"].tap() - wait(1) - - // switch to a new account - buttons["Use other account"].tap() - wait(2) - - // login - test_6_login_good_pass() - } - - func test_2_login_no_backups_generate() { - // log in -> approve -> no backups -> generate pubkey -> weak pass phrase - login(UserCredentials.noKeyBackUp) - wait(1) - - let alertButtons = app.alerts.scrollViews.otherElements.buttons - alertButtons["Create new Private Key"].tap() - - passPhraseTextField.tap() - passPhraseTextField.typeText("Password") - goKeyboardButton.tap() - wait(2) - - XCTAssert(app.alerts["Error"].exists, "Error alert for weak pass phrase should exist") - - app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() - wait(0.1) - - // log in -> approve -> no backups -> generate pubkey -> good pass phrase -> wrong repeat - passPhraseTextField.tap() - passPhraseTextField.typeText(user.pass) - goKeyboardButton.tap() - wait(2) - - app.alerts["Pass Phrase"].scrollViews.otherElements.buttons["OK"].tap() - XCTAssert(app.alerts["Error"].exists, "Error alert for wrong repeat pass phrase should exist") - - app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() - - // log in -> approve -> no backups -> generate pubkey -> good pass phrase -> correct repeat -> create key - passPhraseTextField.tap() - let pass = user.pass.replacingOccurrences(of: " ", with: "") - passPhraseTextField.typeText(pass) - goKeyboardButton.tap() - wait(2) - - // TODO: ANTON - fix this - let secureTextField = app.alerts["Pass Phrase"].scrollViews.otherElements.collectionViews.cells.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element(boundBy: 1).children(matching: .secureTextField).element - secureTextField.typeText(pass) - app.alerts["Pass Phrase"].scrollViews.otherElements.buttons["OK"].tap() - wait(10) - // Temporary confirm on error alert. - if app.alerts["Error"].exists { - app.alerts["Error"].scrollViews.otherElements.buttons["OK"].tap() - wait(2) - } - - // delete backups to trash - cells.forEach { _ in - tapOnCell() - app.navigationBars["Inbox"].buttons["Delete"].tap() - wait(2) - } - - // permanently delete backups - menuButton.tap() - tapOnMenu(folder: "Deleted") - - cells.forEach { _ in - tapOnCell() - self.app.navigationBars["Deleted"].buttons["Delete"].tap() - self.app.alerts["Are you sure?"].scrollViews.otherElements.buttons["OK"].tap() - wait(2) - } - } - - // log in -> cancel for gmail - func test_3_login_cancel_gmail() { - logOutIfNeeded() - snapshot("splash") - - app.tables.buttons["gmail"].tap() - wait(1) - - snapshot("auth") - } - - // log in -> cancel - func test_4_login_cancel() { - login(user) - - let useAnotherAccountButton = app.tables.buttons["Use Another Account"] - useAnotherAccountButton.tap() - - wait(1) - XCTAssert(app.tables.buttons["Other email provider"].exists) - } - - // log in -> approve -> bad pass phrase - func test_5_login_bad_pass() { - login(user) - - passPhraseTextField.tap() - passPhraseTextField.typeText(user.pass + "wrong") - tapOnGoButton() - - wait(0.2) - let errorAlert = app.alerts["Error"] - XCTAssert(errorAlert.exists, "Error alert is missing after entering wrong pass phrase") - errorAlert.scrollViews.otherElements.buttons["OK"].tap() - wait(0.2) - - app.tables.buttons["Use Another Account"].tap() - } - - // log in -> approve -> loaded 1 backup -> good pass phrase -> inbox - func test_6_login_good_pass() { - login(user) - - passPhraseTextField.tap() - passPhraseTextField.typeText(user.pass) - - snapshot("recover") - tapOnGoButton() - - wait(1) - XCTAssert(app.navigationBars["Inbox"].exists, "Could not login") - } - - // restart app -> loads inbox - func test_7_restart_app_load_inbox() { - wait(1) - XCTAssert(app.navigationBars["Inbox"].exists, "Inbox is not found after restarting the app") - snapshot("inbox") - - tapOnCompose() - wait(0.3) - - app.typeText("ElonMusk@gmail.com") - app.tables.textFields["Subject"].tap() - - app.tables.textFields["Subject"].tap() - app.typeText("SpaceX") - - snapshot("compose") - app.navigationBars.buttons["arrow left c"].tap() - wait(1) - - tapOnCell() - snapshot("message") - app.navigationBars.buttons["arrow left c"].tap() - - wait(1) - - menuButton.tap() - snapshot("menu") - - tapOnMenu(folder: "Settings") - snapshot("settings") - } - - // send new msg -> inbox -> switch to sent -> open sent msg and verify content, recipient, subject - func test_8_send_message() { - // send message - sendMessage(to: user.email) - XCTAssert(app.navigationBars["Inbox"].exists, "Failed state after Sending message") - - // switch to sent - menuButton.tap() - - app.tables - .staticTexts - .allElementsBoundByIndex - .first(where: { $0.label.contains("Sent" ) })? - .tap() - - wait(3) - - // open message - tapOnCell() - wait(5) - - XCTAssert(app.tables.staticTexts[user.email].exists, "Wrong recipient in sent message") - XCTAssert(app.tables.staticTexts["Some Subject"].exists, "Wrong subject") - XCTAssert(app.tables.staticTexts["Some text"].exists, "Wrong text") - } - - // move msg to trash -> verify in trash - func test_9_delete_msg() { - // Move msg to Trash - sendMessage(to: user.email) - tapOnCell() - - app.navigationBars.buttons["Delete"].tap() - wait(1) - - // Verify in Trash - menuButton.tap() - tapOnMenu(folder: "Deleted") - XCTAssert(app.tables.cells.otherElements.staticTexts[user.email].exists, "There is no message in deleted") - - tapOnCell() - let buttons = app.navigationBars.buttons - let backButton = buttons["arrow left c"] - - wait(3) - // Verify buttons in Trash folder - XCTAssert(buttons["Delete"].exists, "Navigation bar should contain delete button") - XCTAssert(buttons["help icn"].exists, "Navigation bar should contain help button") - XCTAssert(backButton.exists, "Navigation bar should contain back button") - XCTAssert(buttons.count == 3, "back, info, delete buttons should be only") - - // Open following first msg - backButton.tap() - menuButton.tap() - tapOnMenu(folder: "Inbox") - - tapOnCell() - } - - // move msg to archive -> verify in archive - func test_10_archive() { - sendMessage(to: user.email) - tapOnCell() - app.navigationBars.buttons["archive"].tap() - wait(2) - XCTAssert(app.navigationBars["Inbox"].exists, "Failed in sending message to archive") - - menuButton.tap() - // TODO: ANTON - Archive -// tapOnMenu(folder: "All Mail") -// wait(1) -// -// XCTAssert(app.tables.staticTexts[user.email].exists, "Wrong recipient in sent message") -// XCTAssert(app.tables.staticTexts["Some Subject"].exists, "Wrong subject") - } - - // send new msg -> no pubkey - func test_11_send_message_no_pub_key() { - wait(2) - sendMessage(to: "flowcrypt.nopubkey@gmail.com") - wait(3) - let errorAlert = app.alerts["Error"] - XCTAssert(errorAlert.exists) - } -} - -/* - log in -> approve -> no backups -> generate pubkey -> switch accounts - */ diff --git a/FlowCryptUITests/TestCredentials.swift b/FlowCryptUITests/TestCredentials.swift index fb008dc2a..9a716b012 100644 --- a/FlowCryptUITests/TestCredentials.swift +++ b/FlowCryptUITests/TestCredentials.swift @@ -8,15 +8,12 @@ import XCTest import FlowCryptCommon -private let logger = Logger.nested("UI Tests") + +public let logger = Logger.nested("UI Tests") class TestCredentials: XCTestCase { func test_user_credentials() { - releasePrint("Test user credentials") - XCTAssert(UserCredentials.main != UserCredentials.empty) - XCTAssert(UserCredentials.noKeyBackUp != UserCredentials.empty) - XCTAssert(UserCredentials.compatibility != UserCredentials.empty) - - XCTAssert(!UserCredentials.noKeyBackUp.privateKey.isEmpty) + XCTAssert(UserCredentials.imapDev.email == "default@flowcrypt.test") + XCTAssert(UserCredentials.gmailDev.email == "ci.tests.gmail@flowcrypt.dev") } } diff --git a/Makefile b/Makefile index 7daff3c80..35236d9c5 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ dependencies: ui_tests: dependencies bundle exec fastlane test_ui --verbose +ui_tests_gmail: dependencies + bundle exec fastlane test_ui_gmail --verbose +ui_tests_imap: dependencies + bundle exec fastlane test_ui_imap --verbose format: Scripts/format.sh diff --git a/README.md b/README.md index 437507163..595b884a5 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,14 @@ bundle exec pod install ### Run UI Tests Follow steps in installation above, and then: - - from terminal: `make ui_tests` - - from Xcode: 1) Choose `FlowCryptUITests` run target on top and select a simulator 2) select Tests in Navigators area (cmd+6) 3) Scroll down to `FlowCryptUITests` in the navigator and run them all or run a particular one + - from terminal: + - `make ui_tests` - for all ui tests + - `make ui_tests_gmail` - for Gmail ui tests + - `make ui_tests_imap` - for Imap ui tests + - from Xcode: + 1) Choose `FlowCryptUITests` run target on top and select a simulator + 2) select Tests in Navigators area (cmd+6) + 3) Scroll down to `FlowCryptUITests` in the navigator and run them all or run a particular one Before running tests, please make sure keyboard is visible in simulator. (cmd+shift+k) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 51d128e6e..3228c043b 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -19,8 +19,15 @@ platform :ios do end # UITests - desc "Run UI Tests" + desc "Run all UI tests" lane :test_ui do + test_ui_prepare + test_ui_gmail + test_ui_imap + end + + desc "Run Gmail UI Tests" + lane :test_ui_gmail do test_ui_prepare scan( workspace: "FlowCrypt.xcworkspace", @@ -32,7 +39,26 @@ platform :ios do reset_simulator: true, prelaunch_simulator: true, include_simulator_logs: true, - skip_build: true + skip_build: true, + testplan: "Gmail" + ) + end + + desc "Run Imap UI Tests" + lane :test_ui_imap do + test_ui_prepare + scan( + workspace: "FlowCrypt.xcworkspace", + scheme: "FlowCryptUITests", + reinstall_app: true, + skip_build: true, + disable_slide_to_type: true, + force_quit_simulator: false, + reset_simulator: true, + prelaunch_simulator: true, + include_simulator_logs: true, + skip_build: true, + testplan: "Imap" ) end @@ -74,7 +100,8 @@ platform :ios do lane :do_everything do build unit_tests - # test_ui + # test_ui_gmail + # test_ui_imap # record_tests end