Skip to content

Commit 40607a6

Browse files
committed
Add screen object for Add Fee screen
1 parent 9a5692c commit 40607a6

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/PaymentSection/FeeLineDetails.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct FeeLineDetails: View {
9999
presentation.wrappedValue.dismiss()
100100
}
101101
.disabled(viewModel.shouldDisableDoneButton)
102+
.accessibilityIdentifier("add-fee-done-button")
102103
}
103104
}
104105
}
@@ -120,6 +121,7 @@ struct FeeLineDetails: View {
120121
.onTapGesture {
121122
focusFixedAmountInput = true
122123
}
124+
.accessibilityIdentifier("add-fee-fixed-amount-field")
123125
}
124126
}
125127
.frame(minHeight: Layout.rowHeight)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import ScreenObject
2+
import XCTest
3+
4+
public final class AddFeeScreen: ScreenObject {
5+
6+
private let feeFixedAmountGetter: (XCUIApplication) -> XCUIElement = {
7+
$0.textFields["add-fee-fixed-amount-field"]
8+
}
9+
10+
private let doneButtonGetter: (XCUIApplication) -> XCUIElement = {
11+
$0.buttons["add-fee-done-button"]
12+
}
13+
14+
private var feeFixedAmountField: XCUIElement { feeFixedAmountGetter(app) }
15+
16+
private var doneButton: XCUIElement { doneButtonGetter(app) }
17+
18+
init(app: XCUIApplication = XCUIApplication()) throws {
19+
try super.init(
20+
expectedElementGetters: [ feeFixedAmountGetter ],
21+
app: app
22+
)
23+
}
24+
25+
/// Enters a fixed fee amount.
26+
/// - Returns: Add Fee screen object.
27+
@discardableResult
28+
public func enterFixedFee(amount: String) throws -> Self {
29+
feeFixedAmountField.tap()
30+
feeFixedAmountField.typeText(amount)
31+
return self
32+
}
33+
34+
/// Confirms entered fee and closes Add Fee screen.
35+
/// - Returns: New Order screen object.
36+
@discardableResult
37+
public func confirmFee() throws -> NewOrderScreen {
38+
doneButton.tap()
39+
return try NewOrderScreen()
40+
}
41+
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@
12611261
CC254F3626C437AB005F3C82 /* ShippingLabelCustomPackageForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC254F3526C437AB005F3C82 /* ShippingLabelCustomPackageForm.swift */; };
12621262
CC254F3826C43B52005F3C82 /* ShippingLabelCustomPackageFormViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC254F3726C43B52005F3C82 /* ShippingLabelCustomPackageFormViewModel.swift */; };
12631263
CC2A08022862400100510C4B /* orders_3337_add_shipping.json in Resources */ = {isa = PBXBuildFile; fileRef = CC2A08012862400100510C4B /* orders_3337_add_shipping.json */; };
1264+
CC2A08042863206000510C4B /* AddFeeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A08032863206000510C4B /* AddFeeScreen.swift */; };
12641265
CC2E72F727B6BFB800A62872 /* ProductVariationFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2E72F627B6BFB800A62872 /* ProductVariationFormatterTests.swift */; };
12651266
CC440E1E2770C6AF0074C264 /* ProductInOrderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC440E1D2770C6AF0074C264 /* ProductInOrderViewModel.swift */; };
12661267
CC4A4E962655273D00B75DCD /* ShippingLabelPaymentMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC4A4E952655273D00B75DCD /* ShippingLabelPaymentMethods.swift */; };
@@ -3034,6 +3035,7 @@
30343035
CC254F3526C437AB005F3C82 /* ShippingLabelCustomPackageForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelCustomPackageForm.swift; sourceTree = "<group>"; };
30353036
CC254F3726C43B52005F3C82 /* ShippingLabelCustomPackageFormViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelCustomPackageFormViewModel.swift; sourceTree = "<group>"; };
30363037
CC2A08012862400100510C4B /* orders_3337_add_shipping.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = orders_3337_add_shipping.json; sourceTree = "<group>"; };
3038+
CC2A08032863206000510C4B /* AddFeeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeeScreen.swift; sourceTree = "<group>"; };
30373039
CC2E72F627B6BFB800A62872 /* ProductVariationFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationFormatterTests.swift; sourceTree = "<group>"; };
30383040
CC440E1D2770C6AF0074C264 /* ProductInOrderViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInOrderViewModel.swift; sourceTree = "<group>"; };
30393041
CC4A4E952655273D00B75DCD /* ShippingLabelPaymentMethods.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPaymentMethods.swift; sourceTree = "<group>"; };
@@ -8079,6 +8081,7 @@
80798081
CC1AB56727FC5821003DEF43 /* OrderStatusScreen.swift */,
80808082
C044961228058FE8003B3081 /* AddProductScreen.swift */,
80818083
CC71353A2862285300A28B42 /* AddShippingScreen.swift */,
8084+
CC2A08032863206000510C4B /* AddFeeScreen.swift */,
80828085
);
80838086
path = Orders;
80848087
sourceTree = "<group>";
@@ -8778,6 +8781,7 @@
87788781
3F0CF3042704490A00EF3D71 /* PeriodStatsTable.swift in Sources */,
87798782
3F0CF3142704494A00EF3D71 /* TabNavComponent.swift in Sources */,
87808783
3F0CF3072704490A00EF3D71 /* LoginEmailScreen.swift in Sources */,
8784+
CC2A08042863206000510C4B /* AddFeeScreen.swift in Sources */,
87818785
3F0CF30D2704490A00EF3D71 /* LoginSiteAddressScreen.swift in Sources */,
87828786
80C3626B27704EE1005CEAD3 /* ProductDataStructs.swift in Sources */,
87838787
80C3627127745737005CEAD3 /* ReviewDataStructs.swift in Sources */,

0 commit comments

Comments
 (0)