mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Adding accessibility ids for closed group testing, messaging tests, onboarding tests and linked device testing
This commit is contained in:
parent
6d36450b83
commit
f1dd8a8a53
14 changed files with 61 additions and 20 deletions
|
@ -13,6 +13,8 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
let profileId: String
|
||||
let role: GroupMember.Role
|
||||
let profile: Profile?
|
||||
let accessibilityLabel: String?
|
||||
let accessibilityId: String?
|
||||
}
|
||||
|
||||
private let threadId: String
|
||||
|
@ -31,6 +33,7 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
private lazy var groupNameLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.accessibilityLabel = "Group name"
|
||||
result.isAccessibilityElement = true
|
||||
result.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
result.lineBreakMode = .byTruncatingTail
|
||||
|
@ -45,6 +48,8 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
usesDefaultHeight: false
|
||||
)
|
||||
result.textAlignment = .center
|
||||
result.isAccessibilityElement = true
|
||||
result.accessibilityIdentifier = "Group name text field"
|
||||
|
||||
return result
|
||||
}()
|
||||
|
@ -52,6 +57,7 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
private lazy var addMembersButton: SessionButton = {
|
||||
let result: SessionButton = SessionButton(style: .bordered, size: .medium)
|
||||
result.accessibilityLabel = "Add members"
|
||||
result.isAccessibilityElement = true
|
||||
result.setTitle("vc_conversation_settings_invite_button_title".localized(), for: .normal)
|
||||
result.addTarget(self, action: #selector(addMembers), for: UIControl.Event.touchUpInside)
|
||||
result.contentEdgeInsets = UIEdgeInsets(top: 0, leading: Values.mediumSpacing, bottom: 0, trailing: Values.mediumSpacing)
|
||||
|
@ -62,6 +68,8 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
@objc private lazy var tableView: UITableView = {
|
||||
let result: UITableView = UITableView()
|
||||
result.accessibilityLabel = "Contact"
|
||||
result.accessibilityIdentifier = "Contact"
|
||||
result.isAccessibilityElement = true
|
||||
result.dataSource = self
|
||||
result.delegate = self
|
||||
result.separatorStyle = .none
|
||||
|
@ -352,7 +360,9 @@ final class EditClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegat
|
|||
GroupMemberDisplayInfo(
|
||||
profileId: profile.id,
|
||||
role: .standard,
|
||||
profile: profile
|
||||
profile: profile,
|
||||
accessibilityLabel: "Contact",
|
||||
accessibilityId: "Contact"
|
||||
)
|
||||
}
|
||||
self?.membersAndZombies = (self?.membersAndZombies ?? [])
|
||||
|
|
|
@ -48,6 +48,8 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
result.themeBorderColor = .borderSeparator
|
||||
result.layer.cornerRadius = 13
|
||||
result.delegate = self
|
||||
result.accessibilityIdentifier = "Group name input"
|
||||
result.isAccessibilityElement = true
|
||||
|
||||
return result
|
||||
}()
|
||||
|
@ -133,6 +135,8 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
result.translatesAutoresizingMaskIntoConstraints = false
|
||||
result.setTitle("CREATE_GROUP_BUTTON_TITLE".localized(), for: .normal)
|
||||
result.addTarget(self, action: #selector(createClosedGroup), for: .touchUpInside)
|
||||
result.accessibilityIdentifier = "Create group"
|
||||
result.isAccessibilityElement = true
|
||||
result.set(.width, to: 160)
|
||||
|
||||
return result
|
||||
|
@ -151,6 +155,8 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
let closeButton = UIBarButtonItem(image: #imageLiteral(resourceName: "X"), style: .plain, target: self, action: #selector(close))
|
||||
closeButton.themeTintColor = .textPrimary
|
||||
navigationItem.rightBarButtonItem = closeButton
|
||||
navigationItem.leftBarButtonItem?.accessibilityIdentifier = "Cancel"
|
||||
navigationItem.leftBarButtonItem?.isAccessibilityElement = true
|
||||
|
||||
// Set up content
|
||||
setUpViewHierarchy()
|
||||
|
@ -204,8 +210,9 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
title: profile.displayName(),
|
||||
rightAccessory: .radio(isSelected: { [weak self] in
|
||||
self?.selectedContacts.contains(profile.id) == true
|
||||
})
|
||||
),
|
||||
}),
|
||||
accessibilityIdentifier: "Contact"
|
||||
),
|
||||
style: .edgeToEdge,
|
||||
position: Position.with(indexPath.row, count: data[indexPath.section].elements.count)
|
||||
)
|
||||
|
@ -286,6 +293,7 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
explanation: message,
|
||||
cancelTitle: "BUTTON_OK".localized(),
|
||||
cancelStyle: .alert_text
|
||||
|
||||
)
|
||||
)
|
||||
present(modal, animated: true)
|
||||
|
|
|
@ -137,6 +137,8 @@ extension ConversationVC:
|
|||
range: (message as NSString).range(of: self.viewModel.threadData.displayName)
|
||||
),
|
||||
confirmTitle: "modal_blocked_button_title".localized(),
|
||||
confirmAccessibilityLabel: "Confirm block",
|
||||
cancelAccessibilityLabel: "Cancel block",
|
||||
dismissOnConfirm: false // Custom dismissal logic
|
||||
) { [weak self] _ in
|
||||
self?.viewModel.unblockContact()
|
||||
|
|
|
@ -268,7 +268,9 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate {
|
|||
lastSearchText: String?
|
||||
) {
|
||||
self.viewModel = cellViewModel
|
||||
|
||||
self.bubbleView.accessibilityIdentifier = "Message Body"
|
||||
self.bubbleView.isAccessibilityElement = true
|
||||
self.bubbleView.accessibilityLabel = cellViewModel.body
|
||||
// We want to add spacing between "clusters" of messages to indicate that time has
|
||||
// passed (even if there wasn't enough time to warrant showing a date header)
|
||||
let shouldAddTopInset: Bool = (
|
||||
|
|
|
@ -120,7 +120,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
NavItem(
|
||||
id: .done,
|
||||
systemItem: .done,
|
||||
accessibilityIdentifier: "Done button"
|
||||
accessibilityIdentifier: "Done"
|
||||
) { [weak self] in
|
||||
self?.setIsEditing(false)
|
||||
|
||||
|
@ -128,6 +128,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
self?.threadVariant == .contact,
|
||||
let threadId: String = self?.threadId,
|
||||
let editedDisplayName: String = self?.editedDisplayName
|
||||
|
||||
else { return }
|
||||
|
||||
let updatedNickname: String = editedDisplayName
|
||||
|
@ -182,7 +183,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
/// fetch (after the ones in `ValueConcurrentObserver.asyncStart`/`ValueConcurrentObserver.syncStart`)
|
||||
/// just in case the database has changed between the two reads - unfortunately it doesn't look like there is a way to prevent this
|
||||
private lazy var _observableSettingsData: ObservableData = ValueObservation
|
||||
.trackingConstantRegion { [weak self, dependencies, threadId = self.threadId, threadVariant = self.threadVariant] db -> [SectionModel] in
|
||||
.trackingConstantRegion { [weak self, dependencies, threadId = self.threadId, threadVariant = self.threadVariant] db -> [SectionModel] in
|
||||
let userPublicKey: String = getUserHexEncodedPublicKey(db, dependencies: dependencies)
|
||||
let maybeThreadViewModel: SessionThreadViewModel? = try SessionThreadViewModel
|
||||
.conversationSettingsQuery(threadId: threadId, userPublicKey: userPublicKey)
|
||||
|
@ -351,7 +352,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
.withRenderingMode(.alwaysTemplate)
|
||||
),
|
||||
title: "EDIT_GROUP_ACTION".localized(),
|
||||
accessibilityIdentifier: "\(ThreadSettingsViewModel.self).edit_group",
|
||||
accessibilityIdentifier: "Edit group",
|
||||
accessibilityLabel: "Edit group",
|
||||
onTap: { [weak self] in
|
||||
self?.transitionToScreen(EditClosedGroupVC(threadId: threadId))
|
||||
|
@ -367,7 +368,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
.withRenderingMode(.alwaysTemplate)
|
||||
),
|
||||
title: "LEAVE_GROUP_ACTION".localized(),
|
||||
accessibilityIdentifier: "\(ThreadSettingsViewModel.self).leave_group",
|
||||
accessibilityIdentifier: "Leave group",
|
||||
accessibilityLabel: "Leave group",
|
||||
confirmationInfo: ConfirmationModal.Info(
|
||||
title: "CONFIRM_LEAVE_GROUP_TITLE".localized(),
|
||||
|
@ -424,7 +425,7 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
threadViewModel.threadVariant != .closedGroup ||
|
||||
currentUserIsClosedGroupMember
|
||||
),
|
||||
accessibilityIdentifier: "\(ThreadSettingsViewModel.self).notify_for_mentions_only",
|
||||
accessibilityIdentifier: "Mentions only notification setting",
|
||||
accessibilityLabel: "Mentions only",
|
||||
onTap: {
|
||||
let newValue: Bool = !(threadViewModel.threadOnlyNotifyForMentions == true)
|
||||
|
@ -514,12 +515,11 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
nil :
|
||||
"BLOCK_USER_BEHAVIOR_EXPLANATION".localized()
|
||||
),
|
||||
accessibilityLabel: "Confirm block",
|
||||
confirmTitle: (threadViewModel.threadIsBlocked == true ?
|
||||
"BLOCK_LIST_UNBLOCK_BUTTON".localized() :
|
||||
"BLOCK_LIST_BLOCK_BUTTON".localized()
|
||||
),
|
||||
confirmAccessibilityLabel: "Confirm blocked user",
|
||||
confirmAccessibilityLabel: "Confirm block",
|
||||
confirmStyle: .danger,
|
||||
cancelStyle: .alert_text
|
||||
),
|
||||
|
@ -652,7 +652,9 @@ class ThreadSettingsViewModel: SessionTableViewModel<ThreadSettingsViewModel.Nav
|
|||
nil
|
||||
),
|
||||
accessibilityLabel: oldBlockedState == false ? "User blocked" : "Confirm unblock",
|
||||
accessibilityId: "OK",
|
||||
cancelTitle: "BUTTON_OK".localized(),
|
||||
cancelAccessibilityLabel: "OK",
|
||||
cancelStyle: .alert_text
|
||||
)
|
||||
)
|
||||
|
|
|
@ -22,7 +22,6 @@ final class ConversationTitleView: UIView {
|
|||
|
||||
private lazy var titleLabel: UILabel = {
|
||||
let result: UILabel = UILabel()
|
||||
result.accessibilityLabel = "Username"
|
||||
result.font = .boldSystemFont(ofSize: Values.mediumFontSize)
|
||||
result.themeTextColor = .textPrimary
|
||||
result.lineBreakMode = .byTruncatingTail
|
||||
|
@ -125,6 +124,9 @@ final class ConversationTitleView: UIView {
|
|||
)
|
||||
|
||||
self.titleLabel.text = name
|
||||
self.titleLabel.accessibilityIdentifier = "Username"
|
||||
self.titleLabel.isAccessibilityElement = true
|
||||
self.titleLabel.accessibilityLabel = name
|
||||
self.titleLabel.font = .boldSystemFont(
|
||||
ofSize: (shouldHaveSubtitle ?
|
||||
Values.mediumFontSize :
|
||||
|
|
|
@ -466,6 +466,7 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi
|
|||
// Profile picture view
|
||||
let profilePictureSize = Values.verySmallProfilePictureSize
|
||||
let profilePictureView = ProfilePictureView()
|
||||
profilePictureView.accessibilityIdentifier = "User settings"
|
||||
profilePictureView.accessibilityLabel = "User settings"
|
||||
profilePictureView.isAccessibilityElement = true
|
||||
profilePictureView.size = profilePictureSize
|
||||
|
@ -532,6 +533,8 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi
|
|||
let threadViewModel: SessionThreadViewModel = section.elements[indexPath.row]
|
||||
let cell: FullConversationCell = tableView.dequeue(type: FullConversationCell.self, for: indexPath)
|
||||
cell.update(with: threadViewModel)
|
||||
cell.accessibilityIdentifier = "Conversation list item"
|
||||
cell.accessibilityLabel = threadViewModel.displayName
|
||||
return cell
|
||||
|
||||
default: preconditionFailure("Other sections should have no content")
|
||||
|
|
|
@ -173,6 +173,7 @@ final class RegisterVC : BaseVC {
|
|||
let hexEncodedPublicKey = x25519KeyPair.hexEncodedPublicKey
|
||||
publicKeyLabel.accessibilityLabel = hexEncodedPublicKey
|
||||
publicKeyLabel.accessibilityIdentifier = "Session ID generated"
|
||||
publicKeyLabel.isAccessibilityElement = true
|
||||
let characterCount = hexEncodedPublicKey.count
|
||||
var count = 0
|
||||
let limit = 32
|
||||
|
|
|
@ -124,7 +124,7 @@ class SettingsViewModel: SessionTableViewModel<SettingsViewModel.NavButton, Sett
|
|||
NavItem(
|
||||
id: .done,
|
||||
systemItem: .done,
|
||||
accessibilityIdentifier: "Done button"
|
||||
accessibilityIdentifier: "Done"
|
||||
) { [weak self] in
|
||||
let updatedNickname: String = (self?.editedDisplayName ?? "")
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
|
|
@ -72,7 +72,8 @@ final class UserSelectionVC: BaseVC, UITableViewDataSource, UITableViewDelegate
|
|||
title: profile.displayName(),
|
||||
rightAccessory: .radio(isSelected: { [weak self] in
|
||||
self?.selectedUsers.contains(profile.id) == true
|
||||
})
|
||||
}),
|
||||
accessibilityIdentifier: "Contact"
|
||||
),
|
||||
style: .edgeToEdge,
|
||||
position: Position.with(indexPath.row, count: users.count)
|
||||
|
|
|
@ -63,7 +63,7 @@ class SessionAvatarCell: UITableViewCell {
|
|||
fileprivate let displayNameContainer: UIView = {
|
||||
let view: UIView = UIView()
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.accessibilityLabel = "Edit name text field"
|
||||
view.accessibilityLabel = "Username"
|
||||
view.isAccessibilityElement = true
|
||||
|
||||
return view
|
||||
|
@ -71,7 +71,6 @@ class SessionAvatarCell: UITableViewCell {
|
|||
|
||||
private lazy var displayNameLabel: UILabel = {
|
||||
let label: UILabel = UILabel()
|
||||
label.accessibilityLabel = "Username"
|
||||
label.isAccessibilityElement = true
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.font = .ows_mediumFont(withSize: Values.veryLargeFontSize)
|
||||
|
@ -87,7 +86,9 @@ class SessionAvatarCell: UITableViewCell {
|
|||
let textField: TextField = TextField(placeholder: "Enter a name", usesDefaultHeight: false)
|
||||
textField.translatesAutoresizingMaskIntoConstraints = false
|
||||
textField.textAlignment = .center
|
||||
textField.accessibilityLabel = "Edit name text field"
|
||||
textField.accessibilityIdentifier = "Nickname"
|
||||
textField.accessibilityLabel = "Nickname"
|
||||
textField.isAccessibilityElement = true
|
||||
textField.alpha = 0
|
||||
|
||||
return textField
|
||||
|
|
|
@ -309,6 +309,7 @@ public class SessionCell: UITableViewCell {
|
|||
self.onExtraActionTap = info.extraAction?.onTap
|
||||
self.accessibilityIdentifier = info.accessibilityIdentifier
|
||||
self.accessibilityLabel = info.accessibilityLabel
|
||||
self.isAccessibilityElement = true
|
||||
|
||||
let leftFitToEdge: Bool = (info.leftAccessory?.shouldFitToEdge == true)
|
||||
let rightFitToEdge: Bool = (!leftFitToEdge && info.rightAccessory?.shouldFitToEdge == true)
|
||||
|
|
|
@ -228,7 +228,7 @@ class ThreadSettingsViewModelSpec: QuickSpec {
|
|||
ParentType.NavItem(
|
||||
id: .cancel,
|
||||
systemItem: .cancel,
|
||||
accessibilityIdentifier: "Cancel button"
|
||||
accessibilityIdentifier: "Cancel"
|
||||
)
|
||||
]))
|
||||
expect(viewModel.rightNavItems.firstValue())
|
||||
|
@ -236,7 +236,7 @@ class ThreadSettingsViewModelSpec: QuickSpec {
|
|||
ParentType.NavItem(
|
||||
id: .done,
|
||||
systemItem: .done,
|
||||
accessibilityIdentifier: "Done button"
|
||||
accessibilityIdentifier: "Done"
|
||||
)
|
||||
]))
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ class ThreadSettingsViewModelSpec: QuickSpec {
|
|||
ParentType.NavItem(
|
||||
id: .done,
|
||||
systemItem: .done,
|
||||
accessibilityIdentifier: "Done button"
|
||||
accessibilityIdentifier: "Done"
|
||||
)
|
||||
]))
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class ConfirmationModal: Modal {
|
|||
let explanation: String?
|
||||
let attributedExplanation: NSAttributedString?
|
||||
let accessibilityLabel: String?
|
||||
let accessibilityId: String?
|
||||
public let stateToShow: State
|
||||
let confirmTitle: String?
|
||||
let confirmAccessibilityLabel: String?
|
||||
|
@ -40,6 +41,7 @@ public class ConfirmationModal: Modal {
|
|||
explanation: String? = nil,
|
||||
attributedExplanation: NSAttributedString? = nil,
|
||||
accessibilityLabel: String? = nil,
|
||||
accessibilityId: String? = nil,
|
||||
stateToShow: State = .always,
|
||||
confirmTitle: String? = nil,
|
||||
confirmAccessibilityLabel: String? = nil,
|
||||
|
@ -55,6 +57,7 @@ public class ConfirmationModal: Modal {
|
|||
self.explanation = explanation
|
||||
self.attributedExplanation = attributedExplanation
|
||||
self.accessibilityLabel = accessibilityLabel
|
||||
self.accessibilityId = accessibilityId
|
||||
self.stateToShow = stateToShow
|
||||
self.confirmTitle = confirmTitle
|
||||
self.confirmAccessibilityLabel = confirmAccessibilityLabel
|
||||
|
@ -227,14 +230,19 @@ public class ConfirmationModal: Modal {
|
|||
info.attributedExplanation == nil
|
||||
)
|
||||
confirmButton.accessibilityLabel = info.confirmAccessibilityLabel
|
||||
confirmButton.accessibilityIdentifier = info.confirmAccessibilityLabel
|
||||
confirmButton.isAccessibilityElement = true
|
||||
confirmButton.setTitle(info.confirmTitle, for: .normal)
|
||||
confirmButton.setThemeTitleColor(info.confirmStyle, for: .normal)
|
||||
confirmButton.isHidden = (info.confirmTitle == nil)
|
||||
cancelButton.accessibilityLabel = info.cancelAccessibilityLabel
|
||||
cancelButton.accessibilityIdentifier = info.cancelAccessibilityLabel
|
||||
cancelButton.isAccessibilityElement = true
|
||||
cancelButton.setTitle(info.cancelTitle, for: .normal)
|
||||
cancelButton.setThemeTitleColor(info.cancelStyle, for: .normal)
|
||||
|
||||
self.accessibilityLabel = info.accessibilityLabel
|
||||
self.contentView.accessibilityIdentifier = info.accessibilityId
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
Loading…
Reference in a new issue