mirror of
https://github.com/bitwarden/ios.git
synced 2026-02-04 02:14:09 -06:00
[PM-26063] Consolidate ViewInspector test helpers (#2101)
This commit is contained in:
parent
4d53d05e64
commit
68feef33cb
@ -3,6 +3,7 @@ import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import AuthenticatorShared
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import AuthenticatorShared
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
// MARK: - SelectLanguageViewTests
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
// MARK: - SettingsViewTests
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import AuthenticatorShared
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import BitwardenKit
|
||||
import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -4,6 +4,7 @@ import BitwardenKitMocks
|
||||
import BitwardenResources
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -5,6 +5,7 @@ import BitwardenResources
|
||||
import BitwardenSdk
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -5,6 +5,7 @@ import BitwardenResources
|
||||
import BitwardenSdk
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
import ViewInspectorTestHelpers
|
||||
import XCTest
|
||||
|
||||
@testable import BitwardenShared
|
||||
|
||||
@ -60,7 +60,8 @@ The iOS repository contains two main apps: Bitwarden Password Manager and Bitwar
|
||||
- `GlobalTestHelpers`: Shared functionality between the app's test targets.
|
||||
- `BitwardenKitMocks`: Mock implementations for BitwardenKit components.
|
||||
- `AuthenticatorBridgeKitMocks`: Mock implementations for AuthenticatorBridgeKit components.
|
||||
- `TestHelpers`: Additional test utilities and helpers.
|
||||
- `TestHelpers`: Additional test utilities and helpers.
|
||||
- `ViewInspectorTestHelpers`: ViewInspector-specific test helpers for UI testing.
|
||||
|
||||
### Architecture Structure
|
||||
|
||||
|
||||
@ -1,344 +0,0 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import ViewInspector
|
||||
|
||||
/// A generic type wrapper around `AsyncButton` to allow `ViewInspector` to find instances of `AsyncButton` without
|
||||
/// needing to know the type of its `Label`.
|
||||
///
|
||||
struct AsyncButtonType: BaseViewType {
|
||||
static var typePrefix: String = "AsyncButton"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.AsyncButton",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenTextField` to allow `ViewInspector` to find instances of
|
||||
/// `BitwardenTextField` without needing to know the details of it's implementation.
|
||||
///
|
||||
struct BitwardenTextFieldType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenTextField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenTextField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around ` BitwardenMenuFieldType` to allow `ViewInspector` to find instances of
|
||||
/// ` BitwardenMenuFieldType` without needing to know the details of it's implementation.
|
||||
///
|
||||
struct BitwardenMenuFieldType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenMenuField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenMenuField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenMultilineTextField` to allow `ViewInspector` to find
|
||||
/// instances of `BitwardenMultilineTextField` without needing to know the details of it's
|
||||
/// implementation.
|
||||
///
|
||||
struct BitwardenMultilineTextFieldType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenMultilineTextField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
"AuthenticatorShared.BitwardenMultilineTextField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `SettingsMenuField` to allow `ViewInspector` to find instances of
|
||||
/// `SettingsMenuField` without needing to know the details of it's implementation.
|
||||
///
|
||||
struct SettingsMenuFieldType: BaseViewType {
|
||||
static var typePrefix: String = "SettingsMenuField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.SettingsMenuField",
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: InspectableView
|
||||
|
||||
extension InspectableView {
|
||||
// MARK: Methods
|
||||
|
||||
/// Attempts to locate an async button with the provided title.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - title: The title to use while searching for a button.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: An async button, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
asyncButton title: String,
|
||||
locale _: Locale = .testsDefault,
|
||||
) throws -> InspectableView<AsyncButtonType> {
|
||||
try find(AsyncButtonType.self, containing: title)
|
||||
}
|
||||
|
||||
/// Attempts to locate an async button with the provided accessibility label.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - accessibilityLabel: The accessibility label to use while searching for a button.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A button, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
asyncButtonWithAccessibilityLabel accessibilityLabel: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<AsyncButtonType> {
|
||||
try find(AsyncButtonType.self) { view in
|
||||
try view.accessibilityLabel().string(locale: locale) == accessibilityLabel
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to locate a bitwarden menu field with the provided title.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - title: The title to use while searching for a menu field.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A `BitwardenMenuFieldType`, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
bitwardenMenuField title: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<BitwardenMenuFieldType> {
|
||||
try find(BitwardenMenuFieldType.self, containing: title, locale: locale)
|
||||
}
|
||||
|
||||
/// Attempts to locate a bitwarden multiline text field with the provided title.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - title: The title to use while searching for a text field.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A `BitwardenMultilineTextFieldType`, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
bitwardenMultilineTextField title: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<BitwardenMultilineTextFieldType> {
|
||||
try find(BitwardenMultilineTextFieldType.self, containing: title, locale: locale)
|
||||
}
|
||||
|
||||
/// Attempts to locate a bitwarden text field with the provided title.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - title: The title to use while searching for a text field.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A `BitwardenTextFieldType`, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
bitwardenTextField title: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<BitwardenTextFieldType> {
|
||||
try find(BitwardenTextFieldType.self, containing: title, locale: locale)
|
||||
}
|
||||
|
||||
/// Attempts to locate a bitwarden text field with the provided accessibility label.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - accessibilityLabel: The accessibility label to use while searching for a button.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A `BitwardenTextFieldType`, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
bitwardenTextFieldWithAccessibilityLabel accessibilityLabel: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<BitwardenTextFieldType> {
|
||||
try find(BitwardenTextFieldType.self) { view in
|
||||
try view.accessibilityLabel().string(locale: locale) == accessibilityLabel
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to locate a button with the provided id.
|
||||
///
|
||||
/// - Parameter id: The id to use while searching for a button.
|
||||
/// - Returns: A button, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(buttonWithId id: AnyHashable) throws -> InspectableView<ViewType.Button> {
|
||||
try find(ViewType.Button.self) { view in
|
||||
try view.id() == id
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to locate a button with the provided accessibility label.
|
||||
///
|
||||
/// - Parameter accessibilityLabel: The accessibility label to use while searching for a button.
|
||||
/// - Returns: A button, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
buttonWithAccessibilityLabel accessibilityLabel: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<ViewType.Button> {
|
||||
try find(ViewType.Button.self) { view in
|
||||
try view.accessibilityLabel().string(locale: locale) == accessibilityLabel
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to locate a picker with the provided label.
|
||||
///
|
||||
/// - Parameter label: The label to use while searching for a picker.
|
||||
/// - Returns: A picker, if one can be located.
|
||||
/// - Throws: Throws an error if a picker was unable to be located.
|
||||
///
|
||||
func find(
|
||||
picker label: String,
|
||||
) throws -> InspectableView<ViewType.Picker> {
|
||||
try find(ViewType.Picker.self, containing: label)
|
||||
}
|
||||
|
||||
/// Attempts to locate a text field with the provided label.
|
||||
///
|
||||
/// - Parameter label: The label to use while searching for a text field.
|
||||
/// - Returns: A text field, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(textField label: String) throws -> InspectableView<ViewType.TextField> {
|
||||
try find(ViewType.TextField.self, containing: label)
|
||||
}
|
||||
|
||||
/// Attempts to locate a secure field with the provided label.
|
||||
///
|
||||
/// - Parameter label: The label to use while searching for a secure field.
|
||||
/// - Returns: A secure field, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(secureField label: String) throws -> InspectableView<ViewType.SecureField> {
|
||||
try find(ViewType.SecureField.self, containing: label)
|
||||
}
|
||||
|
||||
/// Attempts to locate a settings menu field with the provided title.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - title: The title to use while searching for a menu field.
|
||||
/// - locale: The locale for text extraction.
|
||||
/// - Returns: A `SettingsMenuField`, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
settingsMenuField title: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<SettingsMenuFieldType> {
|
||||
try find(SettingsMenuFieldType.self, containing: title, locale: locale)
|
||||
}
|
||||
|
||||
/// Attempts to locate a slider with the provided accessibility label.
|
||||
///
|
||||
/// - Parameter accessibilityLabel: The accessibility label to use while searching for a slider.
|
||||
/// - Returns: A slider, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
sliderWithAccessibilityLabel accessibilityLabel: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<ViewType.Slider> {
|
||||
try find(ViewType.Slider.self) { view in
|
||||
try view.accessibilityLabel().string(locale: locale) == accessibilityLabel
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempts to locate a toggle with the provided accessibility label.
|
||||
///
|
||||
/// - Parameter accessibilityLabel: The accessibility label to use while searching for a toggle.
|
||||
/// - Returns: A toggle, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func find(
|
||||
toggleWithAccessibilityLabel accessibilityLabel: String,
|
||||
locale: Locale = .testsDefault,
|
||||
) throws -> InspectableView<ViewType.Toggle> {
|
||||
try find(ViewType.Toggle.self) { view in
|
||||
try view.accessibilityLabel().string(locale: locale) == accessibilityLabel
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Toolbar
|
||||
|
||||
/// Attempts to locate the toolbar cancel default button.
|
||||
///
|
||||
/// - Returns: A cancel toolbar button, if one can be located.
|
||||
/// - Throws: Throws an error if a view was unable to be located.
|
||||
///
|
||||
func findCancelToolbarButton() throws -> InspectableView<ViewType.Button> {
|
||||
try find(ViewType.Button.self) { view in
|
||||
try view.accessibilityIdentifier() == "CancelButton"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == AsyncButtonType {
|
||||
/// Simulates a tap on an `AsyncButton`. This method is asynchronous and allows the entire `async` `action` on the
|
||||
/// button to run before returning.
|
||||
///
|
||||
func tap() async throws {
|
||||
typealias Callback = () async -> Void
|
||||
let mirror = Mirror(reflecting: self)
|
||||
if let action = mirror.descendant("content", "view", "action") as? Callback {
|
||||
await action()
|
||||
} else {
|
||||
throw InspectionError.attributeNotFound(
|
||||
label: "action",
|
||||
type: String(describing: AsyncButtonType.self),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenTextFieldType {
|
||||
/// Locates the raw binding on this textfield's text value. Can be used to simulate updating the text field.
|
||||
///
|
||||
func inputBinding() throws -> Binding<String> {
|
||||
let mirror = Mirror(reflecting: self)
|
||||
if let binding = mirror.descendant("content", "view", "_text") as? Binding<String> {
|
||||
return binding
|
||||
} else {
|
||||
throw InspectionError.attributeNotFound(
|
||||
label: "_text",
|
||||
type: String(describing: BitwardenTextFieldType.self),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenMultilineTextFieldType {
|
||||
/// Locates the raw binding on this textfield's text value. Can be used to simulate updating the text field.
|
||||
///
|
||||
func inputBinding() throws -> Binding<String> {
|
||||
let mirror = Mirror(reflecting: self)
|
||||
if let binding = mirror.descendant("content", "view", "_text") as? Binding<String> {
|
||||
return binding
|
||||
} else {
|
||||
throw InspectionError.attributeNotFound(
|
||||
label: "_text",
|
||||
type: String(describing: BitwardenMultilineTextFieldType.self),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenMenuFieldType {
|
||||
/// Selects a new value in the menu field.
|
||||
///
|
||||
func select(newValue: any Hashable) throws {
|
||||
let picker = try find(ViewType.Picker.self)
|
||||
try picker.select(value: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == SettingsMenuFieldType {
|
||||
/// Selects a new value in the menu field.
|
||||
///
|
||||
func select(newValue: any Hashable) throws {
|
||||
let picker = try find(ViewType.Picker.self)
|
||||
try picker.select(value: newValue)
|
||||
}
|
||||
}
|
||||
@ -6,12 +6,12 @@ import XCTest
|
||||
// swiftlint:disable file_length
|
||||
|
||||
/// A generic type wrapper around `ActionCard` to allow `ViewInspector` to find instances of
|
||||
/// `ActionCard` without needing to know the details of it's implementation.
|
||||
/// `ActionCard` without needing to know the details of its implementation.
|
||||
///
|
||||
struct ActionCardType: BaseViewType {
|
||||
static var typePrefix: String = "ActionCard"
|
||||
public struct ActionCardType: BaseViewType {
|
||||
public static var typePrefix: String = "ActionCard"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenShared.ActionCard",
|
||||
]
|
||||
}
|
||||
@ -19,106 +19,118 @@ struct ActionCardType: BaseViewType {
|
||||
/// A generic type wrapper around `AsyncButton` to allow `ViewInspector` to find instances of `AsyncButton` without
|
||||
/// needing to know the type of its `Label`.
|
||||
///
|
||||
struct AsyncButtonType: BaseViewType {
|
||||
static var typePrefix: String = "AsyncButton"
|
||||
public struct AsyncButtonType: BaseViewType {
|
||||
public static var typePrefix: String = "AsyncButton"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.AsyncButton",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenSlider` to allow `ViewInspector` to find instances of `BitwardenSlider`
|
||||
/// without needing to know the details of it's implementation.
|
||||
/// without needing to know the details of its implementation.
|
||||
///
|
||||
struct BitwardenSliderType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenSlider"
|
||||
public struct BitwardenSliderType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenSlider"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenSlider",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenStepper` to allow `ViewInspector` to find instances of
|
||||
/// `BitwardenStepper` without needing to know the details of it's implementation.
|
||||
/// `BitwardenStepper` without needing to know the details of its implementation.
|
||||
///
|
||||
struct BitwardenStepperType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenStepper"
|
||||
public struct BitwardenStepperType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenStepper"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenStepper",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenTextField` to allow `ViewInspector` to find instances of
|
||||
/// `BitwardenTextField` without needing to know the details of it's implementation.
|
||||
/// `BitwardenTextField` without needing to know the details of its implementation.
|
||||
///
|
||||
struct BitwardenTextFieldType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenTextField"
|
||||
public struct BitwardenTextFieldType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenTextField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenTextField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around ` BitwardenMenuFieldType` to allow `ViewInspector` to find instances of
|
||||
/// ` BitwardenMenuFieldType` without needing to know the details of it's implementation.
|
||||
/// ` BitwardenMenuFieldType` without needing to know the details of its implementation.
|
||||
///
|
||||
struct BitwardenMenuFieldType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenMenuField"
|
||||
public struct BitwardenMenuFieldType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenMenuField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenMenuField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenUITextViewType` to allow `ViewInspector` to find
|
||||
/// instances of `BitwardenUITextViewType` without needing to know the details of it's
|
||||
/// A generic type wrapper around `BitwardenMultilineTextField` to allow `ViewInspector` to find
|
||||
/// instances of `BitwardenMultilineTextField` without needing to know the details of its
|
||||
/// implementation.
|
||||
///
|
||||
struct BitwardenUITextViewType: BaseViewType {
|
||||
static var typePrefix: String = "BitwardenUITextView"
|
||||
public struct BitwardenMultilineTextFieldType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenMultilineTextField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"AuthenticatorShared.BitwardenMultilineTextField",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `BitwardenUITextViewType` to allow `ViewInspector` to find
|
||||
/// instances of `BitwardenUITextViewType` without needing to know the details of its
|
||||
/// implementation.
|
||||
///
|
||||
public struct BitwardenUITextViewType: BaseViewType {
|
||||
public static var typePrefix: String = "BitwardenUITextView"
|
||||
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.BitwardenUITextView",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `FloatingActionButton` to allow `ViewInspector` to find instances
|
||||
/// of `FloatingActionButton` without needing to know the details of it's implementation.
|
||||
/// of `FloatingActionButton` without needing to know the details of its implementation.
|
||||
///
|
||||
struct FloatingActionButtonType: BaseViewType {
|
||||
static var typePrefix: String = "FloatingActionButton"
|
||||
public struct FloatingActionButtonType: BaseViewType {
|
||||
public static var typePrefix: String = "FloatingActionButton"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenShared.FloatingActionButton",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `LoadingView` to allow `ViewInspector` to find instances of
|
||||
/// `LoadingView` without needing to know the details of it's implementation.
|
||||
/// `LoadingView` without needing to know the details of its implementation.
|
||||
///
|
||||
struct LoadingViewType: BaseViewType {
|
||||
static var typePrefix: String = "LoadingView"
|
||||
public struct LoadingViewType: BaseViewType {
|
||||
public static var typePrefix: String = "LoadingView"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenShared.LoadingView",
|
||||
]
|
||||
}
|
||||
|
||||
/// A generic type wrapper around `SettingsMenuField` to allow `ViewInspector` to find instances of
|
||||
/// `SettingsMenuField` without needing to know the details of it's implementation.
|
||||
/// `SettingsMenuField` without needing to know the details of its implementation.
|
||||
///
|
||||
struct SettingsMenuFieldType: BaseViewType {
|
||||
static var typePrefix: String = "SettingsMenuField"
|
||||
public struct SettingsMenuFieldType: BaseViewType {
|
||||
public static var typePrefix: String = "SettingsMenuField"
|
||||
|
||||
static var namespacedPrefixes: [String] = [
|
||||
public static var namespacedPrefixes: [String] = [
|
||||
"BitwardenKit.SettingsMenuField",
|
||||
]
|
||||
}
|
||||
|
||||
// MARK: InspectableView
|
||||
|
||||
extension InspectableView {
|
||||
public extension InspectableView {
|
||||
// MARK: Methods
|
||||
|
||||
/// Attempts to locate an action card with the provided title.
|
||||
@ -369,7 +381,7 @@ extension InspectableView {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == AsyncButtonType {
|
||||
public extension InspectableView where View == AsyncButtonType {
|
||||
/// Simulates a tap on an `AsyncButton`. This method is asynchronous and allows the entire `async` `action` on the
|
||||
/// button to run before returning.
|
||||
///
|
||||
@ -387,7 +399,7 @@ extension InspectableView where View == AsyncButtonType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenTextFieldType {
|
||||
public extension InspectableView where View == BitwardenTextFieldType {
|
||||
/// Locates the raw binding on this textfield's text value. Can be used to simulate updating the text field.
|
||||
///
|
||||
func inputBinding() throws -> Binding<String> {
|
||||
@ -403,7 +415,23 @@ extension InspectableView where View == BitwardenTextFieldType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenSliderType {
|
||||
public extension InspectableView where View == BitwardenMultilineTextFieldType {
|
||||
/// Locates the raw binding on this textfield's text value. Can be used to simulate updating the text field.
|
||||
///
|
||||
func inputBinding() throws -> Binding<String> {
|
||||
let mirror = Mirror(reflecting: self)
|
||||
if let binding = mirror.descendant("content", "view", "_text") as? Binding<String> {
|
||||
return binding
|
||||
} else {
|
||||
throw InspectionError.attributeNotFound(
|
||||
label: "_text",
|
||||
type: String(describing: BitwardenMultilineTextFieldType.self),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension InspectableView where View == BitwardenSliderType {
|
||||
/// Simulates a drag gesture on the slider to set a new value.
|
||||
///
|
||||
func setValue(_ value: Double) throws {
|
||||
@ -425,7 +453,7 @@ extension InspectableView where View == BitwardenSliderType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenUITextViewType {
|
||||
public extension InspectableView where View == BitwardenUITextViewType {
|
||||
/// Locates the raw binding on this textfield's text value. Can be used to simulate updating the text field.
|
||||
///
|
||||
func inputBinding() throws -> Binding<String> {
|
||||
@ -441,7 +469,7 @@ extension InspectableView where View == BitwardenUITextViewType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenMenuFieldType {
|
||||
public extension InspectableView where View == BitwardenMenuFieldType {
|
||||
/// Selects a new value in the menu field.
|
||||
///
|
||||
func select(newValue: any Hashable) throws {
|
||||
@ -450,7 +478,7 @@ extension InspectableView where View == BitwardenMenuFieldType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == SettingsMenuFieldType {
|
||||
public extension InspectableView where View == SettingsMenuFieldType {
|
||||
/// Selects a new value in the menu field.
|
||||
///
|
||||
func select(newValue: any Hashable) throws {
|
||||
@ -459,7 +487,7 @@ extension InspectableView where View == SettingsMenuFieldType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == BitwardenStepperType {
|
||||
public extension InspectableView where View == BitwardenStepperType {
|
||||
/// Decrements the stepper.
|
||||
///
|
||||
func decrement() throws {
|
||||
@ -475,7 +503,7 @@ extension InspectableView where View == BitwardenStepperType {
|
||||
}
|
||||
}
|
||||
|
||||
extension InspectableView where View == FloatingActionButtonType {
|
||||
public extension InspectableView where View == FloatingActionButtonType {
|
||||
/// Simulates a tap on an `AsyncButton` within a `FloatingActionButton`. This method is
|
||||
/// asynchronous and allows the entire `async` `action` on the button to run before returning.
|
||||
///
|
||||
@ -151,7 +151,6 @@ targets:
|
||||
- target: BitwardenKit/AuthenticatorBridgeKit
|
||||
- target: BitwardenKit/TestHelpers
|
||||
- package: SnapshotTesting
|
||||
- package: ViewInspector
|
||||
randomExecutionOrder: true
|
||||
|
||||
AuthenticatorShared:
|
||||
@ -237,8 +236,6 @@ targets:
|
||||
- "**/*SnapshotTests.*"
|
||||
- "**/*ViewInspectorTests.*"
|
||||
- path: GlobalTestHelpers-bwa
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
- path: AuthenticatorShared/Sourcery/Generated
|
||||
optional: true
|
||||
- path: AuthenticatorShared/Sourcery/Generated/AutoMockable.generated.swift
|
||||
@ -267,8 +264,6 @@ targets:
|
||||
- "**/TestHelpers/*"
|
||||
- "**/Fixtures/*"
|
||||
- path: GlobalTestHelpers-bwa
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
- path: AuthenticatorShared/Sourcery/Generated
|
||||
optional: true
|
||||
- path: AuthenticatorShared/Sourcery/Generated/AutoMockable.generated.swift
|
||||
@ -308,5 +303,6 @@ targets:
|
||||
- target: BitwardenKit/AuthenticatorBridgeKitMocks
|
||||
- target: BitwardenKit/BitwardenKitMocks
|
||||
- target: BitwardenKit/TestHelpers
|
||||
- target: BitwardenKit/ViewInspectorTestHelpers
|
||||
- package: ViewInspector
|
||||
randomExecutionOrder: true
|
||||
|
||||
@ -210,6 +210,7 @@ targets:
|
||||
- target: BitwardenKit
|
||||
- target: BitwardenKitMocks
|
||||
- target: TestHelpers
|
||||
- target: ViewInspectorTestHelpers
|
||||
- package: ViewInspector
|
||||
randomExecutionOrder: true
|
||||
BitwardenResources:
|
||||
@ -284,4 +285,15 @@ targets:
|
||||
dependencies:
|
||||
- target: Networking
|
||||
- package: SnapshotTesting
|
||||
ViewInspectorTestHelpers:
|
||||
type: framework
|
||||
platform: iOS
|
||||
settings:
|
||||
base:
|
||||
ENABLE_TESTING_SEARCH_PATHS: YES
|
||||
GENERATE_INFOPLIST_FILE: YES
|
||||
sources:
|
||||
- path: ViewInspectorTestHelpers
|
||||
dependencies:
|
||||
- package: ViewInspector
|
||||
|
||||
|
||||
@ -221,8 +221,6 @@ targets:
|
||||
- "**/*Tests.*"
|
||||
- "**/TestHelpers/*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
dependencies:
|
||||
- target: Bitwarden
|
||||
- target: BitwardenShared
|
||||
@ -259,8 +257,6 @@ targets:
|
||||
- "**/*Tests.*"
|
||||
- "**/TestHelpers/*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
dependencies:
|
||||
- target: BitwardenActionExtension
|
||||
- target: BitwardenShared
|
||||
@ -296,8 +292,6 @@ targets:
|
||||
- "**/*Tests.*"
|
||||
- "**/TestHelpers/*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
dependencies:
|
||||
- target: BitwardenAutoFillExtension
|
||||
- target: BitwardenShared
|
||||
@ -333,8 +327,6 @@ targets:
|
||||
- "**/*Tests.*"
|
||||
- "**/TestHelpers/*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
dependencies:
|
||||
- target: BitwardenShareExtension
|
||||
- target: BitwardenShared
|
||||
@ -420,8 +412,6 @@ targets:
|
||||
- "**/*SnapshotTests.*"
|
||||
- "**/*ViewInspectorTests.*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
- path: BitwardenShared/Sourcery/Generated
|
||||
optional: true
|
||||
- path: BitwardenShared/Sourcery/Generated/AutoMockable.generated.swift
|
||||
@ -453,8 +443,6 @@ targets:
|
||||
- "**/TestHelpers/*"
|
||||
- "**/Fixtures/*"
|
||||
- path: GlobalTestHelpers
|
||||
excludes:
|
||||
- "**/InspectableView.*"
|
||||
- path: BitwardenShared/Sourcery/Generated
|
||||
optional: true
|
||||
- path: BitwardenShared/Sourcery/Generated/AutoMockable.generated.swift
|
||||
@ -495,6 +483,7 @@ targets:
|
||||
- target: BitwardenShared
|
||||
- target: BitwardenKit/BitwardenKitMocks
|
||||
- target: BitwardenKit/TestHelpers
|
||||
- target: BitwardenKit/ViewInspectorTestHelpers
|
||||
- package: ViewInspector
|
||||
randomExecutionOrder: true
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user