Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private extension ProductFormTableViewDataSource {
}

cell.accessoryType = .none
cell.accessibilityIdentifier = "product-title"

let placeholder = NSLocalizedString("Title", comment: "Placeholder in the Product Title row on Product form screen.")

Expand Down Expand Up @@ -193,6 +194,7 @@ private extension ProductFormTableViewDataSource {
cell.textLabel?.text = placeholder
cell.textLabel?.applyBodyStyle()
cell.textLabel?.textColor = .textSubtle
cell.accessibilityIdentifier = "product-description"
}
if isEditable {
cell.accessoryType = .disclosureIndicator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,11 +970,21 @@ private extension ProductFormViewController {
}

func createPublishBarButtonItem() -> UIBarButtonItem {
return UIBarButtonItem(title: Localization.publishTitle, style: .done, target: self, action: #selector(publishProduct))
let publishButton = UIBarButtonItem(title: Localization.publishTitle,
style: .done,
target: self,
action: #selector(publishProduct))
publishButton.accessibilityIdentifier = "publish-product-button"
return publishButton
}

func createSaveBarButtonItem() -> UIBarButtonItem {
return UIBarButtonItem(title: Localization.saveTitle, style: .done, target: self, action: #selector(saveProductAndLogEvent))
let saveButton = UIBarButtonItem(title: Localization.saveTitle,
style: .done,
target: self,
action: #selector(saveProductAndLogEvent))
saveButton.accessibilityIdentifier = "save-product-button"
return saveButton
}

func createPreviewBarButtonItem() -> UIBarButtonItem {
Expand Down
15 changes: 15 additions & 0 deletions WooCommerce/UITestsFoundation/ProductDataStructs.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Mocks for products on product list
public struct ProductMock: Codable {
public let response: ProductResponseData
}
Expand All @@ -11,6 +12,20 @@ public struct ProductBodyData: Codable {
public let data: [ProductData]
}

/// Mocks for a new product
public struct NewProductMock: Codable {
public let response: NewProductResponseData
}

public struct NewProductResponseData: Codable {
public let status: Int
public let jsonBody: NewProductBodyData
}

public struct NewProductBodyData: Codable {
public let data: ProductData
}

public struct ProductData: Codable {
public let id: Int
public let name: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ public final class ProductsScreen: ScreenObject {
XCTAssertTrue(isLoaded)
return self
}

public func tapAddProduct() throws -> Self {
app.buttons["product-add-button"].tap()
return self
}

public func selectProductType(productType: String) throws -> SingleProductScreen {
app.staticTexts[productType].tap()
return try SingleProductScreen()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,20 @@ public final class SingleProductScreen: ScreenObject {

return self
}

public func addProductTitle(productTitle: String) throws -> Self {
app.cells["product-title"].enterText(text: productTitle)
return self
}

public func publishProduct() throws -> Self {
app.buttons["publish-product-button"].tap()
return self
}

public func verifyNewProductScreenLoaded(productName: String) {
XCTAssertTrue(app.buttons["save-product-button"].exists)
XCTAssertTrue(app.staticTexts["TIP"].exists)
Comment on lines +45 to +46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of checking that this screen contains the product name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XCTAssertTrue(app.textViews[productName].exists)
}
}
4 changes: 4 additions & 0 deletions WooCommerce/UITestsFoundation/XCTest+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ extension XCUIElement {
*/
func clearAndEnterText(text: String) -> Void {
clearTextIfNeeded()
enterText(text: text)
}

func enterText(text: String) -> Void {
self.tap()
self.typeText(text)
}
Expand Down
4 changes: 4 additions & 0 deletions WooCommerce/WooCommerce.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@
800A5BC7275889ED009DE2CD /* reports_revenue_stats_month.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */; };
800A5BC8275889ED009DE2CD /* reports_revenue_stats_year.json in Resources */ = {isa = PBXBuildFile; fileRef = 800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */; };
800A5BCB2759CE4B009DE2CD /* ProductsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */; };
806062F229432BB8006BB1F9 /* products_add_new.json in Resources */ = {isa = PBXBuildFile; fileRef = 806062F129432BB8006BB1F9 /* products_add_new.json */; };
80AD2CA22782B4EB00A63DE8 /* products_list_1.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA12782B4EB00A63DE8 /* products_list_1.json */; };
80AD2CA427858BAB00A63DE8 /* StatsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80AD2CA327858BAB00A63DE8 /* StatsTests.swift */; };
80AD2CA627859B4400A63DE8 /* reports_leaderboards_stats_day.json in Resources */ = {isa = PBXBuildFile; fileRef = 80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */; };
Expand Down Expand Up @@ -3153,6 +3154,7 @@
800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_month.json; sourceTree = "<group>"; };
800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_year.json; sourceTree = "<group>"; };
800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsTests.swift; sourceTree = "<group>"; };
806062F129432BB8006BB1F9 /* products_add_new.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_add_new.json; sourceTree = "<group>"; };
80AD2CA12782B4EB00A63DE8 /* products_list_1.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_1.json; sourceTree = "<group>"; };
80AD2CA327858BAB00A63DE8 /* StatsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsTests.swift; sourceTree = "<group>"; };
80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = reports_leaderboards_stats_day.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7822,6 +7824,7 @@
80AD2CA12782B4EB00A63DE8 /* products_list_1.json */,
80B8D3442785A08900FE6E6B /* products_list_2.json */,
80B8D3482785A0A900FE6E6B /* products_list_3.json */,
806062F129432BB8006BB1F9 /* products_add_new.json */,
);
path = products;
sourceTree = "<group>";
Expand Down Expand Up @@ -9672,6 +9675,7 @@
800A5BC8275889ED009DE2CD /* reports_revenue_stats_year.json in Resources */,
CC2A08062863222500510C4B /* orders_3337_add_fee.json in Resources */,
800A5BBC27586AE1009DE2CD /* products_reviews_6162.json in Resources */,
806062F229432BB8006BB1F9 /* products_add_new.json in Resources */,
800A5B6127548F53009DE2CD /* sites_posts_password.json in Resources */,
800A5BB427586A0E009DE2CD /* products_reviews_6155.json in Resources */,
800A5B5F27548F31009DE2CD /* site_info_wordpress_com.json in Resources */,
Expand Down
6 changes: 6 additions & 0 deletions WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class GetMocks {
return updatedData
}

static func readNewProductData() throws -> ProductData {
let originalData = try JSONDecoder().decode(NewProductMock.self, from: self.getMockData(test: ProductsTests.self, filename: "products_add_new"))

return try XCTUnwrap(originalData.response.jsonBody.data)
}

static func readReviewsData() throws -> [ReviewData] {
let originalData = try JSONDecoder().decode(ReviewMock.self, from: self.getMockData(test: ReviewsTests.self, filename: "products_reviews_all"))
var updatedData = originalData.response.jsonBody.data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"urlPath": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
"bodyPatterns": [
{ "matches": ".*path=/wc/v3/orders/3337%26_method%3Dpost.*" },
{ "contains": "%22product_id%22%3A2129" },
{ "contains": "%22product_id%22%3A2130" },
{ "contains": "%22fee_lines%22%3A%5B%5D" },
{ "contains": "%22shipping_lines%22%3A%5B%5D" },
{ "contains": "%22first_name%22%3A%22Mira%22" }
Expand Down Expand Up @@ -70,19 +70,19 @@
"meta_data": [],
"line_items": [{
"id": 1,
"name": "Akoya Pearl shades",
"product_id": 2129,
"name": "Black Coral shades",
"product_id": 2130,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "110.00",
"subtotal": "150.00",
"subtotal_tax": "0.00",
"total": "110.00",
"total": "150.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "",
"price": 110
"price": 150
}],
"tax_lines": [],
"shipping_lines": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"urlPath": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
"bodyPatterns": [
{ "matches": ".*path=/wc/v3/orders/3337%26_method%3Dpost.*" },
{ "contains": "%22product_id%22%3A2129" },
{ "contains": "%22product_id%22%3A2130" },
{ "contains": "%22name%22%3A%22Fee%22" },
{ "contains": "%22method_title%22%3A%22Flat%20Rate%22" },
{ "contains": "%22first_name%22%3A%22Mira%22" }
Expand Down Expand Up @@ -70,19 +70,19 @@
"meta_data": [],
"line_items": [{
"id": 1,
"name": "Akoya Pearl shades",
"product_id": 2129,
"name": "Black Coral shades",
"product_id": 2130,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "110.00",
"subtotal": "150.00",
"subtotal_tax": "0.00",
"total": "110.00",
"total": "150.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "",
"price": 110
"price": 150
}],
"tax_lines": [],
"shipping_lines": [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"bodyPatterns": [
{ "matches": ".*path=/wc/v3/orders%26_method%3Dpost.*" },
{ "contains": "%22status%22%3A%22auto-draft%22" },
{ "contains": "%22product_id%22%3A2129" }
{ "contains": "%22product_id%22%3A2130" }
]
},
"response": {
Expand Down Expand Up @@ -68,19 +68,19 @@
"meta_data": [],
"line_items": [{
"id": 1,
"name": "Akoya Pearl shades",
"product_id": 2129,
"name": "Black Coral shades",
"product_id": 2130,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "110.00",
"subtotal": "150.00",
"subtotal_tax": "0.00",
"total": "110.00",
"total": "150.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "",
"price": 110
"price": 150
}],
"tax_lines": [],
"shipping_lines": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"urlPath": "/rest/v1.1/jetpack-blogs/161477129/rest-api/",
"bodyPatterns": [
{ "matches": ".*path=/wc/v3/orders/3337%26_method%3Dpost.*" },
{ "contains": "%22product_id%22%3A2129" },
{ "contains": "%22product_id%22%3A2130" },
{ "contains": "%22fee_lines%22%3A%5B%5D" },
{ "contains": "%22method_title%22%3A%22Flat%20Rate%22" },
{ "contains": "%22first_name%22%3A%22Mira%22" }
Expand Down Expand Up @@ -70,19 +70,19 @@
"meta_data": [],
"line_items": [{
"id": 1,
"name": "Akoya Pearl shades",
"product_id": 2129,
"name": "Black Coral shades",
"product_id": 2130,
"variation_id": 0,
"quantity": 1,
"tax_class": "",
"subtotal": "110.00",
"subtotal": "150.00",
"subtotal_tax": "0.00",
"total": "110.00",
"total": "150.00",
"total_tax": "0.00",
"taxes": [],
"meta_data": [],
"sku": "",
"price": 110
"price": 150
}],
"tax_lines": [],
"shipping_lines": [{
Expand Down
Loading