From 0e38cab9f3b147aea53ac85ad34fae00c1d9e81e Mon Sep 17 00:00:00 2001 From: Anton Kharchevskyi Date: Wed, 8 Dec 2021 17:40:13 +0200 Subject: [PATCH 1/3] Add accessibility ids to menu and pub key --- .../Public Key/PublicKeyDetailViewController.swift | 3 ++- .../SideMenu/Menu/MyMenuViewDecorator.swift | 3 ++- FlowCrypt/Extensions/String+Extension.swift | 4 ++++ FlowCryptUI/Cell Nodes/InfoCellNode.swift | 10 ++++++++-- FlowCryptUI/Cell Nodes/SetupTitleNode.swift | 7 ++++++- FlowCryptUI/Nodes/TableViewController.swift | 5 +---- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift b/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift index 83ff08737..f1bd7ac0d 100644 --- a/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift +++ b/FlowCrypt/Controllers/Settings/KeySettings/Public Key/PublicKeyDetailViewController.swift @@ -47,7 +47,8 @@ extension PublicKeyDetailViewController: ASTableDelegate, ASTableDataSource { SetupTitleNode.Input( title: (self?.text ?? "").attributed(.regular(16)), insets: .side(16), - backgroundColor: .backgroundColor + backgroundColor: .backgroundColor, + accessibilityIdentifier: "publicKey" ) ) } diff --git a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift index 166732ac8..c13c816d1 100644 --- a/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift +++ b/FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewDecorator.swift @@ -83,7 +83,8 @@ extension InfoCellNode.Input { self.init( attributedText: viewModel.name .attributed(.regular(17), color: .mainTextColor), - image: viewModel.image + image: viewModel.image, + accessibilityIdentifier: "menuBarItem\(viewModel.name.capitalizingFirstLetter())" ) } } diff --git a/FlowCrypt/Extensions/String+Extension.swift b/FlowCrypt/Extensions/String+Extension.swift index bccc3673a..8966f1f52 100644 --- a/FlowCrypt/Extensions/String+Extension.swift +++ b/FlowCrypt/Extensions/String+Extension.swift @@ -14,4 +14,8 @@ extension String { let emailPredicate = NSPredicate(format: "SELF MATCHES %@", emailFormat) return emailPredicate.evaluate(with: self) } + + func capitalizingFirstLetter() -> String { + prefix(1).uppercased() + self.lowercased().dropFirst() + } } diff --git a/FlowCryptUI/Cell Nodes/InfoCellNode.swift b/FlowCryptUI/Cell Nodes/InfoCellNode.swift index 57df8d125..69288cf25 100644 --- a/FlowCryptUI/Cell Nodes/InfoCellNode.swift +++ b/FlowCryptUI/Cell Nodes/InfoCellNode.swift @@ -15,17 +15,20 @@ public final class InfoCellNode: CellNode { let image: UIImage? let insets: UIEdgeInsets let backgroundColor: UIColor? + let accessibilityIdentifier: String? public init( attributedText: NSAttributedString, image: UIImage?, insets: UIEdgeInsets = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16), - backgroundColor: UIColor? = nil + backgroundColor: UIColor? = nil, + accessibilityIdentifier: String? = nil ) { self.attributedText = attributedText self.image = image self.insets = insets self.backgroundColor = backgroundColor + self.accessibilityIdentifier = accessibilityIdentifier } } @@ -37,9 +40,12 @@ public final class InfoCellNode: CellNode { self.input = input super.init() self.textNode.attributedText = input?.attributedText + self.textNode.isAccessibilityElement = true + self.textNode.accessibilityIdentifier = input?.accessibilityIdentifier + self.imageNode.image = input?.image self.automaticallyManagesSubnodes = true - + if let backgroundColor = input?.backgroundColor { self.backgroundColor = backgroundColor } diff --git a/FlowCryptUI/Cell Nodes/SetupTitleNode.swift b/FlowCryptUI/Cell Nodes/SetupTitleNode.swift index a7ca2d570..c21366b2a 100644 --- a/FlowCryptUI/Cell Nodes/SetupTitleNode.swift +++ b/FlowCryptUI/Cell Nodes/SetupTitleNode.swift @@ -14,17 +14,20 @@ public final class SetupTitleNode: CellNode { let insets: UIEdgeInsets let selectedLineColor: UIColor? let backgroundColor: UIColor + let accessibilityIdentifier: String? public init( title: NSAttributedString, insets: UIEdgeInsets, selectedLineColor: UIColor? = nil, - backgroundColor: UIColor + backgroundColor: UIColor, + accessibilityIdentifier: String? = nil ) { self.title = title self.insets = insets self.selectedLineColor = selectedLineColor self.backgroundColor = backgroundColor + self.accessibilityIdentifier = accessibilityIdentifier } } private let input: Input @@ -35,6 +38,8 @@ public final class SetupTitleNode: CellNode { self.input = input super.init() textNode.attributedText = input.title + textNode.isAccessibilityElement = true + textNode.accessibilityIdentifier = input.accessibilityIdentifier backgroundColor = input.backgroundColor } diff --git a/FlowCryptUI/Nodes/TableViewController.swift b/FlowCryptUI/Nodes/TableViewController.swift index b0909d4cf..0e26f146a 100644 --- a/FlowCryptUI/Nodes/TableViewController.swift +++ b/FlowCryptUI/Nodes/TableViewController.swift @@ -33,12 +33,9 @@ public extension UINavigationItem { titleLabel.sizeToFit() titleView = titleLabel - let accessibilityIdentifier = "navigationItem\((id ?? ""))" - .replacingOccurrences(of: " ", with: "") - .capitalized titleLabel.isAccessibilityElement = true titleLabel.accessibilityTraits = .header - titleView?.accessibilityIdentifier = accessibilityIdentifier + titleView?.accessibilityIdentifier = "navigationItem\((id ?? "").capitalized)" titleView?.isAccessibilityElement = true titleView?.accessibilityTraits = .header isAccessibilityElement = true From 35a118542b567b0fb39782071f547a6c0e8ba189 Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Thu, 9 Dec 2021 11:45:12 +0200 Subject: [PATCH 2/3] added fixes for tests after update accessibility ids for menu items and for pubkey --- appium/tests/screenobjects/menu-bar.screen.ts | 10 +++++----- appium/tests/screenobjects/public-key.screen.ts | 13 +++---------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/appium/tests/screenobjects/menu-bar.screen.ts b/appium/tests/screenobjects/menu-bar.screen.ts index ef19723e9..a3163c4a8 100644 --- a/appium/tests/screenobjects/menu-bar.screen.ts +++ b/appium/tests/screenobjects/menu-bar.screen.ts @@ -4,11 +4,11 @@ import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { MENU_ICON: '~menu icn', - LOGOUT_BTN: '~Log out', - SETTINGS_BTN: '~Settings', - INBOX_BTN: '~INBOX', - SENT_BTN: '~SENT', - TRASH_BTN: '~TRASH', + LOGOUT_BTN: '~menuBarItemLog out', + SETTINGS_BTN: '~menuBarItemSettings', + INBOX_BTN: '~menuBarItemInbox', + SENT_BTN: '~menuBarItemSent', + TRASH_BTN: '~menuBarItemTrash', }; class MenuBarScreen extends BaseScreen { diff --git a/appium/tests/screenobjects/public-key.screen.ts b/appium/tests/screenobjects/public-key.screen.ts index f9fe233bc..b37ca1eeb 100644 --- a/appium/tests/screenobjects/public-key.screen.ts +++ b/appium/tests/screenobjects/public-key.screen.ts @@ -3,7 +3,7 @@ import BaseScreen from './base.screen'; const SELECTORS = { BACK_BTN: '~arrow left c', PUBLIC_KEY_HEADER: '-ios class chain:**/XCUIElementTypeStaticText[`label == "Public key"`]', - PUBLIC_KEY: '-ios class chain:**/XCUIElementTypeOther/XCUIElementTypeStaticText[1]', + PUBLIC_KEY: '~publicKey', }; class PublicKeyScreen extends BaseScreen { @@ -28,15 +28,8 @@ class PublicKeyScreen extends BaseScreen { await (await this.publicKeyHeader).waitForDisplayed(); const publicKeyEl = await this.publicKey; await publicKeyEl.waitForExist(); - // const pubkeyValue = await publicKeyEl.getAttribute('value'); - // todo - fixme https://github.com/FlowCrypt/flowcrypt-ios/issues/1068 - // [0-11] Error in "SETTINGS: user should see public key and should not see private key" - // Error: Expected 'e2e' to contain '-----BEGIN PGP PUBLIC KEY BLOCK-----'. - // at - // at PublicKeyScreen.checkPublicKey (/Users/tom/git/flowcrypt-ios/appium/tests/screenobjects/public-key.screen.ts:32:31) - // at processTicksAndRejections (node:internal/process/task_queues:96:5) - // at async UserContext. (/Users/tom/git/flowcrypt-ios/appium/tests/specs/settings/CheckSettingsForLoggedUser.spec.ts:34:5)`` - // await expect(pubkeyValue).toContain("-----BEGIN PGP PUBLIC KEY BLOCK-----"); + const pubkeyValue = await publicKeyEl.getAttribute('value'); + await expect(pubkeyValue).toContain("-----BEGIN PGP PUBLIC KEY BLOCK-----"); } } From 157c3ec11f576b6dd20b8a472e3a2c007d091aeb Mon Sep 17 00:00:00 2001 From: Dmitry Sotnikov Date: Thu, 9 Dec 2021 13:21:51 +0200 Subject: [PATCH 3/3] fixes for navigation menu items accessibility id --- appium/package.json | 2 +- appium/tests/screenobjects/mail-folder.screen.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appium/package.json b/appium/package.json index b8d456c78..505b273be 100644 --- a/appium/package.json +++ b/appium/package.json @@ -49,4 +49,4 @@ "wdio-video-reporter": "^3.1.3", "webdriverio": "7.16.10" } -} \ No newline at end of file +} diff --git a/appium/tests/screenobjects/mail-folder.screen.ts b/appium/tests/screenobjects/mail-folder.screen.ts index 6b151ead5..60b9a6a99 100644 --- a/appium/tests/screenobjects/mail-folder.screen.ts +++ b/appium/tests/screenobjects/mail-folder.screen.ts @@ -3,10 +3,10 @@ import TouchHelper from "../helpers/TouchHelper"; import ElementHelper from "../helpers/ElementHelper"; const SELECTORS = { - TRASH_HEADER: '~Navigationitemtrash', - SENT_HEADER: '~Navigationitemsent', + TRASH_HEADER: '~navigationItemTrash', + SENT_HEADER: '~navigationItemSent', CREATE_EMAIL_BUTTON: '-ios class chain:**/XCUIElementTypeButton[`label == "+"`]', - INBOX_HEADER: '~Navigationiteminbox', + INBOX_HEADER: '~navigationItemInbox', SEARCH_ICON: '~search icn', HELP_ICON: '~help icn', SEARCH_FIELD: '~searchAllEmailField'