Skip to content

Commit ce3bd84

Browse files
committed
Add screen object for Customer Note Edit screen
1 parent 5f8c7bc commit ce3bd84

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Notes Section/Customer Note/EditCustomerNote.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct EditCustomerNote<ViewModel: EditCustomerNoteViewModelProtocol>: View {
5454
.padding()
5555
.navigationTitle(Localization.title)
5656
.navigationBarTitleDisplayMode(.inline)
57+
.accessibilityIdentifier("edit-note-text-editor")
5758
.toolbar {
5859
ToolbarItem(placement: .cancellationAction) {
5960
Button(Localization.cancel, action: {
@@ -63,6 +64,7 @@ struct EditCustomerNote<ViewModel: EditCustomerNoteViewModelProtocol>: View {
6364
}
6465
ToolbarItem(placement: .confirmationAction) {
6566
navigationBarTrailingItem()
67+
.accessibilityIdentifier("edit-note-done-button")
6668
}
6769
}
6870
}
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 CustomerNoteScreen: ScreenObject {
5+
6+
private let noteTextEditorGetter: (XCUIApplication) -> XCUIElement = {
7+
$0.textViews["edit-note-text-editor"]
8+
}
9+
10+
private let doneButtonGetter: (XCUIApplication) -> XCUIElement = {
11+
$0.buttons["edit-note-done-button"]
12+
}
13+
14+
private var noteTextEditor: XCUIElement { noteTextEditorGetter(app) }
15+
16+
private var doneButton: XCUIElement { doneButtonGetter(app) }
17+
18+
init(app: XCUIApplication = XCUIApplication()) throws {
19+
try super.init(
20+
expectedElementGetters: [ noteTextEditorGetter ],
21+
app: app
22+
)
23+
}
24+
25+
/// Enters a customer note.
26+
/// - Parameter text: Text to enter as the customer note.
27+
/// - Returns: Customer Note screen object.
28+
@discardableResult
29+
public func enterNote(_ text: String) throws -> Self {
30+
noteTextEditor.typeText(text)
31+
return self
32+
}
33+
34+
/// Confirms entered note and closes Customer Note screen.
35+
/// - Returns: New Order screen object.
36+
@discardableResult
37+
public func confirmNote() 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
@@ -1263,6 +1263,7 @@
12631263
CC2A08022862400100510C4B /* orders_3337_add_shipping.json in Resources */ = {isa = PBXBuildFile; fileRef = CC2A08012862400100510C4B /* orders_3337_add_shipping.json */; };
12641264
CC2A08042863206000510C4B /* AddFeeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A08032863206000510C4B /* AddFeeScreen.swift */; };
12651265
CC2A08062863222500510C4B /* orders_3337_add_fee.json in Resources */ = {isa = PBXBuildFile; fileRef = CC2A08052863222500510C4B /* orders_3337_add_fee.json */; };
1266+
CC2A0808286337A300510C4B /* CustomerNoteScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A0807286337A300510C4B /* CustomerNoteScreen.swift */; };
12661267
CC2E72F727B6BFB800A62872 /* ProductVariationFormatterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2E72F627B6BFB800A62872 /* ProductVariationFormatterTests.swift */; };
12671268
CC440E1E2770C6AF0074C264 /* ProductInOrderViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC440E1D2770C6AF0074C264 /* ProductInOrderViewModel.swift */; };
12681269
CC4A4E962655273D00B75DCD /* ShippingLabelPaymentMethods.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC4A4E952655273D00B75DCD /* ShippingLabelPaymentMethods.swift */; };
@@ -3038,6 +3039,7 @@
30383039
CC2A08012862400100510C4B /* orders_3337_add_shipping.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = orders_3337_add_shipping.json; sourceTree = "<group>"; };
30393040
CC2A08032863206000510C4B /* AddFeeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeeScreen.swift; sourceTree = "<group>"; };
30403041
CC2A08052863222500510C4B /* orders_3337_add_fee.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = orders_3337_add_fee.json; sourceTree = "<group>"; };
3042+
CC2A0807286337A300510C4B /* CustomerNoteScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerNoteScreen.swift; sourceTree = "<group>"; };
30413043
CC2E72F627B6BFB800A62872 /* ProductVariationFormatterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductVariationFormatterTests.swift; sourceTree = "<group>"; };
30423044
CC440E1D2770C6AF0074C264 /* ProductInOrderViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInOrderViewModel.swift; sourceTree = "<group>"; };
30433045
CC4A4E952655273D00B75DCD /* ShippingLabelPaymentMethods.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelPaymentMethods.swift; sourceTree = "<group>"; };
@@ -8085,6 +8087,7 @@
80858087
C044961228058FE8003B3081 /* AddProductScreen.swift */,
80868088
CC71353A2862285300A28B42 /* AddShippingScreen.swift */,
80878089
CC2A08032863206000510C4B /* AddFeeScreen.swift */,
8090+
CC2A0807286337A300510C4B /* CustomerNoteScreen.swift */,
80888091
);
80898092
path = Orders;
80908093
sourceTree = "<group>";
@@ -8773,6 +8776,7 @@
87738776
3F0CF30F2704490A00EF3D71 /* SingleProductScreen.swift in Sources */,
87748777
3F0CF30C2704490A00EF3D71 /* LoginPasswordScreen.swift in Sources */,
87758778
C02747102822673800985EAE /* CustomerDetailsScreen.swift in Sources */,
8779+
CC2A0808286337A300510C4B /* CustomerNoteScreen.swift in Sources */,
87768780
3F0CF30E2704490A00EF3D71 /* PasswordScreen.swift in Sources */,
87778781
3F0CF3092704490A00EF3D71 /* BetaFeaturesScreen.swift in Sources */,
87788782
80B8D34C278E8A0C00FE6E6B /* MenuScreen.swift in Sources */,

0 commit comments

Comments
 (0)