From 2bcc049405f36297f2303cf0c2119e43dd5826e3 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 14 Feb 2023 17:04:30 +1100 Subject: [PATCH] Fixed an issue where Appium couldn't long press message bubbles --- .../Message Cells/VisibleMessageCell.swift | 11 +++++++++-- SessionUIKit/Components/TappableLabel.swift | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index 6ac622f60..40e4b25fc 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -1,6 +1,7 @@ // Copyright © 2022 Rangeproof Pty Ltd. All rights reserved. import UIKit +import SessionUIKit import SignalUtilitiesKit import SessionUtilitiesKit import SessionMessagingKit @@ -771,12 +772,18 @@ final class VisibleMessageCell: MessageCell, TappableLabelDelegate { // MARK: - Interaction override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { - if let bodyTappableLabel = bodyTappableLabel { - let btIngetBodyTappableLabelCoordinates = convert(point, to: bodyTappableLabel) + // We are currently using Appium to do automated UI testing, unfortunately it seems to run into + // issues when trying to long-press an element which has custom interaction logic - the TappableLabel + // only needs to custom handle touches for interacting with links so we check to see if it contains + // links before forwarding touches to it + if let bodyTappableLabel: TappableLabel = bodyTappableLabel, bodyTappableLabel.containsLinks { + let btIngetBodyTappableLabelCoordinates: CGPoint = convert(point, to: bodyTappableLabel) + if bodyTappableLabel.bounds.contains(btIngetBodyTappableLabelCoordinates) { return bodyTappableLabel } } + return super.hitTest(point, with: event) } diff --git a/SessionUIKit/Components/TappableLabel.swift b/SessionUIKit/Components/TappableLabel.swift index b982cade5..3e86970c5 100644 --- a/SessionUIKit/Components/TappableLabel.swift +++ b/SessionUIKit/Components/TappableLabel.swift @@ -55,6 +55,10 @@ public class TappableLabel: UILabel { } } + public var containsLinks: Bool { + return !links.isEmpty + } + // MARK: - Initialization public override init(frame: CGRect) {