Skip to content

Commit 0172581

Browse files
authored
Merge pull request synonymdev#213 from synonymdev/test/boost
Test/boost
2 parents 2380fd5 + 48cd52a commit 0172581

File tree

7 files changed

+92
-37
lines changed

7 files changed

+92
-37
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
# - { name: onchain_boost_receive_widgets, grep: "@onchain|@boost|@receive|@widgets" }
108108
# - { name: settings, grep: "@settings" }
109109
# - { name: security, grep: "@security" }
110-
- { name: e2e, grep: "@onboarding|@onchain_1|@numberpad|@widgets" }
110+
- { name: e2e, grep: "@onboarding|@onchain_1|@numberpad|@widgets|@boost" }
111111

112112
name: e2e-tests - ${{ matrix.shard.name }}
113113

Bitkit/Components/NavigationBar.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct NavigationBar: View {
4848
.foregroundColor(.textPrimary)
4949
.frame(width: 24, height: 24)
5050
}
51+
.accessibilityIdentifier("NavigationBack")
5152
} else {
5253
Spacer()
5354
.frame(width: 24, height: 24)

Bitkit/Components/SheetIntro.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ struct SheetIntro: View {
1212
let testID: String?
1313
let onCancel: (() -> Void)?
1414
let onContinue: () -> Void
15+
private var baseTestID: String {
16+
testID ?? "SheetIntro"
17+
}
1518

1619
init(
1720
navTitle: String,
@@ -52,20 +55,23 @@ struct SheetIntro: View {
5255
.frame(width: UIScreen.main.bounds.width * 0.8)
5356
.frame(maxHeight: 256)
5457
.padding(.bottom, 32)
58+
.accessibilityIdentifier("\(baseTestID)Image")
5559

5660
DisplayText(title, accentColor: accentColor)
5761
.padding(.bottom, 14)
5862
.frame(maxWidth: .infinity, alignment: .leading)
5963

6064
BodyMText(description, accentFont: accentFont)
6165
.frame(maxWidth: .infinity, alignment: .leading)
66+
.accessibilityIdentifier("\(baseTestID)Description")
6267
}
6368

6469
buttonStack
6570
.padding(.top, 32)
6671
}
6772
.padding(.horizontal, 32)
68-
.accessibilityIdentifier(testID ?? "SheetIntro")
73+
.accessibilityElement(children: .contain)
74+
.accessibilityIdentifier(baseTestID)
6975
}
7076

7177
@ViewBuilder
@@ -78,19 +84,22 @@ struct SheetIntro: View {
7884
) {
7985
onCancel()
8086
}
87+
.accessibilityIdentifier("\(baseTestID)Cancel")
8188

8289
CustomButton(
8390
title: continueText
8491
) {
8592
onContinue()
8693
}
94+
.accessibilityIdentifier("\(baseTestID)Continue")
8795
}
8896
} else {
8997
CustomButton(
9098
title: continueText
9199
) {
92100
onContinue()
93101
}
102+
.accessibilityIdentifier("\(baseTestID)Continue")
94103
}
95104
}
96105
}

Bitkit/Views/Wallets/Activity/ActivityExplorerView.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,15 @@ struct ActivityExplorerView: View {
7676
private struct InfoSection: View {
7777
let title: String
7878
let content: String
79+
let testId: String?
7980
@EnvironmentObject var app: AppViewModel
8081

82+
init(title: String, content: String, testId: String? = nil) {
83+
self.title = title
84+
self.content = content
85+
self.testId = testId
86+
}
87+
8188
var body: some View {
8289
Button {
8390
UIPasteboard.general.string = content
@@ -94,6 +101,7 @@ struct ActivityExplorerView: View {
94101
}
95102
}
96103
.buttonStyle(.plain)
104+
.accessibilityIdentifierIfPresent(testId)
97105
}
98106
}
99107

@@ -112,7 +120,8 @@ struct ActivityExplorerView: View {
112120
if let onchain {
113121
InfoSection(
114122
title: t("wallet__activity_tx_id"),
115-
content: onchain.txId
123+
content: onchain.txId,
124+
testId: "TXID"
116125
)
117126

118127
if let txDetails {
@@ -153,7 +162,8 @@ struct ActivityExplorerView: View {
153162

154163
InfoSection(
155164
title: t(key, variables: ["num": String(index + 1)]),
156-
content: boostTxId
165+
content: boostTxId,
166+
testId: onchain.txType == .received ? "CPFPBoosted" : "RBFBoosted"
157167
)
158168
}
159169
}

Bitkit/Views/Wallets/Activity/ActivityIcon.swift

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,54 @@ struct ActivityIcon: View {
3131
}
3232

3333
var body: some View {
34-
if isLightning {
35-
if status == .failed {
34+
Group {
35+
if isLightning {
36+
if status == .failed {
37+
CircularIcon(
38+
icon: "x-circle",
39+
iconColor: .purpleAccent,
40+
backgroundColor: .purple16,
41+
size: size
42+
)
43+
} else if status == .pending {
44+
CircularIcon(
45+
icon: "hourglass-simple",
46+
iconColor: .purpleAccent,
47+
backgroundColor: .purple16,
48+
size: size
49+
)
50+
} else {
51+
CircularIcon(
52+
icon: txType == .sent ? "arrow-up" : "arrow-down",
53+
iconColor: .purpleAccent,
54+
backgroundColor: .purple16,
55+
size: size
56+
)
57+
}
58+
} else if isBoosted && !(confirmed ?? false) {
3659
CircularIcon(
37-
icon: "x-circle",
38-
iconColor: .purpleAccent,
39-
backgroundColor: .purple16,
40-
size: size
41-
)
42-
} else if status == .pending {
43-
CircularIcon(
44-
icon: "hourglass-simple",
45-
iconColor: .purpleAccent,
46-
backgroundColor: .purple16,
60+
icon: "timer-alt",
61+
iconColor: .yellow,
62+
backgroundColor: .yellow16,
4763
size: size
4864
)
4965
} else {
66+
let paymentIcon = txType == PaymentType.sent ? "arrow-up" : "arrow-down"
5067
CircularIcon(
51-
icon: txType == .sent ? "arrow-up" : "arrow-down",
52-
iconColor: .purpleAccent,
53-
backgroundColor: .purple16,
68+
icon: isTransfer ? "arrow-up-down" : paymentIcon,
69+
iconColor: .brandAccent,
70+
backgroundColor: .brand16,
5471
size: size
5572
)
5673
}
57-
} else if isBoosted && !(confirmed ?? false) {
58-
CircularIcon(
59-
icon: "timer-alt",
60-
iconColor: .yellow,
61-
backgroundColor: .yellow16,
62-
size: size
63-
)
64-
} else {
65-
let paymentIcon = txType == PaymentType.sent ? "arrow-up" : "arrow-down"
66-
CircularIcon(
67-
icon: isTransfer ? "arrow-up-down" : paymentIcon,
68-
iconColor: .brandAccent,
69-
backgroundColor: .brand16,
70-
size: size
71-
)
7274
}
75+
.accessibilityIdentifierIfPresent(iconAccessibilityIdentifier)
76+
}
77+
78+
private var iconAccessibilityIdentifier: String? {
79+
if !isLightning, isBoosted, !(confirmed ?? false) {
80+
return "BoostingIcon"
81+
}
82+
return nil
7383
}
7484
}

Bitkit/Views/Wallets/Activity/ActivityItemView.swift

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ struct ActivityItemView: View {
112112
}
113113
}
114114

115+
private var statusAccessibilityIdentifier: String? {
116+
switch viewModel.activity {
117+
case let .onchain(activity):
118+
if activity.confirmed == true {
119+
return "StatusConfirmed"
120+
}
121+
if activity.isBoosted {
122+
return "StatusBoosting"
123+
}
124+
return "StatusConfirming"
125+
case .lightning:
126+
return nil
127+
}
128+
}
129+
115130
var body: some View {
116131
VStack(alignment: .leading, spacing: 0) {
117132
NavigationBar(title: navigationTitle)
@@ -124,7 +139,6 @@ struct ActivityItemView: View {
124139
Spacer()
125140
ActivityIcon(activity: viewModel.activity, size: 48)
126141
}
127-
.accessibilityIdentifier("ActivityAmount")
128142
.padding(.bottom, 16)
129143

130144
statusSection
@@ -208,6 +222,7 @@ struct ActivityItemView: View {
208222
}
209223
}
210224
}
225+
.accessibilityIdentifierIfPresent(statusAccessibilityIdentifier)
211226
.padding(.bottom, 16)
212227

213228
Divider()
@@ -263,8 +278,9 @@ struct ActivityItemView: View {
263278
Image("user")
264279
.foregroundColor(accentColor)
265280
.frame(width: 16, height: 16)
266-
MoneyText(sats: Int(activity.value), size: .bodySSB)
281+
MoneyText(sats: Int(activity.value), size: .bodySSB, testIdentifier: "MoneyText")
267282
}
283+
.accessibilityElement(children: .contain)
268284
.accessibilityIdentifier("ActivityAmount")
269285
.padding(.bottom, 16)
270286

@@ -281,8 +297,9 @@ struct ActivityItemView: View {
281297
Image("timer")
282298
.foregroundColor(accentColor)
283299
.frame(width: 16, height: 16)
284-
MoneyText(sats: Int(fee), size: .bodySSB)
300+
MoneyText(sats: Int(fee), size: .bodySSB, testIdentifier: "MoneyText")
285301
}
302+
.accessibilityElement(children: .contain)
286303
.accessibilityIdentifier("ActivityFee")
287304
.padding(.bottom, 16)
288305

Bitkit/Views/Wallets/Sheets/BoostSheet.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct BoostSheet: View {
2626
@EnvironmentObject private var wallet: WalletViewModel
2727
@EnvironmentObject private var currency: CurrencyViewModel
2828
@EnvironmentObject private var activityList: ActivityListViewModel
29+
@EnvironmentObject private var navigation: NavigationViewModel
2930
let config: BoostSheetItem
3031

3132
@State private var feeRate: UInt32?
@@ -115,6 +116,7 @@ struct BoostSheet: View {
115116
.cornerRadius(200)
116117
}
117118
.disabled(currentFeeRate <= minFeeRate)
119+
.accessibilityIdentifier("Minus")
118120

119121
Spacer()
120122

@@ -141,12 +143,14 @@ struct BoostSheet: View {
141143
.cornerRadius(200)
142144
}
143145
.disabled(currentFeeRate >= maxFeeRate)
146+
.accessibilityIdentifier("Plus")
144147
}
145148

146149
CustomButton(title: "Use Suggested Fee", size: .small) {
147150
isEditingFee = false
148151
editedFeeRate = nil
149152
}
153+
.accessibilityIdentifier("RecommendedFeeButton")
150154
}
151155
.padding(.vertical, 12)
152156
.cornerRadius(12)
@@ -203,6 +207,7 @@ struct BoostSheet: View {
203207
}
204208
.buttonStyle(PlainButtonStyle())
205209
.disabled(feeRate == nil || fetchingFees)
210+
.accessibilityIdentifier("CustomFeeButton")
206211
}
207212
.padding(.vertical, 12)
208213
.cornerRadius(12)
@@ -219,6 +224,8 @@ struct BoostSheet: View {
219224
}
220225
}
221226
.padding(.horizontal, 16)
227+
.accessibilityElement(children: .contain)
228+
.accessibilityIdentifier(isIncoming ? "CPFPBoost" : "RBFBoost")
222229
}
223230
.onAppear {
224231
fetchFeeRate()
@@ -391,6 +398,7 @@ struct BoostSheet: View {
391398

392399
Logger.info("Boost transaction completed successfully, hiding sheet", context: "BoostSheet.performBoost")
393400
sheets.hideSheet()
401+
navigation.reset()
394402

395403
} catch {
396404
Logger.error("Failed to boost transaction: \(error)", context: "BoostSheet.performBoost")

0 commit comments

Comments
 (0)