Skip to content

Commit 2164629

Browse files
committed
Add screen object elements and methods to add note to a new order
1 parent ce3bd84 commit 2164629

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/CustomerNoteSection/CustomerNoteSection.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ private struct CustomerNoteSectionContent: View {
8383
}
8484
.buttonStyle(PlusButtonStyle())
8585
.padding([.leading, .bottom, .trailing])
86+
.accessibilityIdentifier("add-customer-note-button")
8687
}
8788
}
8889

WooCommerce/UITestsFoundation/Screens/Orders/NewOrderScreen.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public final class NewOrderScreen: ScreenObject {
3131
$0.buttons["add-fee-button"]
3232
}
3333

34+
private let addNoteButtonGetter: (XCUIApplication) -> XCUIElement = {
35+
$0.buttons["add-customer-note-button"]
36+
}
37+
3438
private var createButton: XCUIElement { createButtonGetter(app) }
3539

3640
/// Cancel button in the Navigation bar.
@@ -57,6 +61,10 @@ public final class NewOrderScreen: ScreenObject {
5761
///
5862
private var addFeeButton: XCUIElement { addFeeButtonGetter(app) }
5963

64+
/// Add Note button in the Customer Note section.
65+
///
66+
private var addNoteButton: XCUIElement { addNoteButtonGetter(app) }
67+
6068
public init(app: XCUIApplication = XCUIApplication()) throws {
6169
try super.init(
6270
expectedElementGetters: [ createButtonGetter ],
@@ -106,6 +114,14 @@ public final class NewOrderScreen: ScreenObject {
106114
return try AddFeeScreen()
107115
}
108116

117+
/// Opens the Customer Note screen.
118+
/// - Returns: Customer Note screen object.
119+
@discardableResult
120+
public func openCustomerNoteScreen() throws -> CustomerNoteScreen {
121+
addNoteButton.tap()
122+
return try CustomerNoteScreen()
123+
}
124+
109125
// MARK: - High-level Order Creation actions
110126

111127
/// Creates a remote order with all of the entered order data.
@@ -161,6 +177,15 @@ public final class NewOrderScreen: ScreenObject {
161177
.confirmFee()
162178
}
163179

180+
/// Adds a note on the Customer Note screen.
181+
/// - Parameter text: Text to enter as the customer note.
182+
/// - Returns: New Order screen object.
183+
public func addCustomerNote(_ text: String) throws -> NewOrderScreen {
184+
return try openCustomerNoteScreen()
185+
.enterNote(text)
186+
.confirmNote()
187+
}
188+
164189
/// Cancels Order Creation process
165190
/// - Returns: Orders Screen object.
166191
@discardableResult

0 commit comments

Comments
 (0)