diff --git a/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormTableViewDataSource.swift b/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormTableViewDataSource.swift index 7f14b4789b6..67d27d0c77f 100644 --- a/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormTableViewDataSource.swift +++ b/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormTableViewDataSource.swift @@ -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.") @@ -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 diff --git a/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift b/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift index 976e20732a3..dffe95c1895 100644 --- a/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift +++ b/WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift @@ -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 { diff --git a/WooCommerce/UITestsFoundation/ProductDataStructs.swift b/WooCommerce/UITestsFoundation/ProductDataStructs.swift index 69a83297057..2bfcc8124a9 100644 --- a/WooCommerce/UITestsFoundation/ProductDataStructs.swift +++ b/WooCommerce/UITestsFoundation/ProductDataStructs.swift @@ -1,3 +1,4 @@ +/// Mocks for products on product list public struct ProductMock: Codable { public let response: ProductResponseData } @@ -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 diff --git a/WooCommerce/UITestsFoundation/Screens/Products/ProductsScreen.swift b/WooCommerce/UITestsFoundation/Screens/Products/ProductsScreen.swift index 2591151f056..1f2065b7240 100644 --- a/WooCommerce/UITestsFoundation/Screens/Products/ProductsScreen.swift +++ b/WooCommerce/UITestsFoundation/Screens/Products/ProductsScreen.swift @@ -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() + } } diff --git a/WooCommerce/UITestsFoundation/Screens/Products/SingleProductScreen.swift b/WooCommerce/UITestsFoundation/Screens/Products/SingleProductScreen.swift index 62a6c6e00a4..fab49e9076e 100644 --- a/WooCommerce/UITestsFoundation/Screens/Products/SingleProductScreen.swift +++ b/WooCommerce/UITestsFoundation/Screens/Products/SingleProductScreen.swift @@ -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) + XCTAssertTrue(app.textViews[productName].exists) + } } diff --git a/WooCommerce/UITestsFoundation/XCTest+Extensions.swift b/WooCommerce/UITestsFoundation/XCTest+Extensions.swift index fc95035910f..dbaad7cdd1e 100644 --- a/WooCommerce/UITestsFoundation/XCTest+Extensions.swift +++ b/WooCommerce/UITestsFoundation/XCTest+Extensions.swift @@ -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) } diff --git a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj index 4cd11356481..d245fc59e4e 100644 --- a/WooCommerce/WooCommerce.xcodeproj/project.pbxproj +++ b/WooCommerce/WooCommerce.xcodeproj/project.pbxproj @@ -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 */; }; @@ -3153,6 +3154,7 @@ 800A5BC3275889EC009DE2CD /* reports_revenue_stats_month.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_month.json; sourceTree = ""; }; 800A5BC4275889EC009DE2CD /* reports_revenue_stats_year.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = reports_revenue_stats_year.json; sourceTree = ""; }; 800A5BCA2759CE4B009DE2CD /* ProductsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsTests.swift; sourceTree = ""; }; + 806062F129432BB8006BB1F9 /* products_add_new.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_add_new.json; sourceTree = ""; }; 80AD2CA12782B4EB00A63DE8 /* products_list_1.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = products_list_1.json; sourceTree = ""; }; 80AD2CA327858BAB00A63DE8 /* StatsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsTests.swift; sourceTree = ""; }; 80AD2CA527859B4400A63DE8 /* reports_leaderboards_stats_day.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = reports_leaderboards_stats_day.json; sourceTree = ""; }; @@ -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 = ""; @@ -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 */, diff --git a/WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift b/WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift index 1c1038530be..1db722b3e26 100644 --- a/WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift +++ b/WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift @@ -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 diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_customer_details.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_customer_details.json index 3b455941f37..ebb6eefd7dd 100644 --- a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_customer_details.json +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_customer_details.json @@ -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" } @@ -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": [], diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_fee.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_fee.json index 3089cc14403..c3cc3f88b2d 100644 --- a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_fee.json +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_fee.json @@ -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" } @@ -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": [{ diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_product.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_product.json index 400e57e2757..affbe7e5290 100644 --- a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_product.json +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_product.json @@ -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": { @@ -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": [], diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_shipping.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_shipping.json index 1c78ef92027..f5e6e35c144 100644 --- a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_shipping.json +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/orders/orders_3337_add_shipping.json @@ -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" } @@ -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": [{ diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products.json index bbfae633b62..74ae3e1f4ef 100644 --- a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products.json +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products.json @@ -18,113 +18,6 @@ "status": 200, "jsonBody": { "data": [{ - "id": 2129, - "name": "Akoya Pearl shades", - "slug": "akoya-pearl-shades", - "permalink": "https:\/\/automatticwidgets.wpcomstaging.com\/product\/akoya-pearl-shades\/", - "date_created": "2020-01-28T09:53:36", - "date_created_gmt": "2020-01-28T09:53:36", - "date_modified": "2020-01-28T09:57:12", - "date_modified_gmt": "2020-01-28T09:57:12", - "type": "simple", - "status": "publish", - "featured": false, - "catalog_visibility": "visible", - "description": "", - "short_description": "", - "sku": "", - "price": "110", - "regular_price": "110", - "sale_price": "", - "date_on_sale_from": null, - "date_on_sale_from_gmt": null, - "date_on_sale_to": null, - "date_on_sale_to_gmt": null, - "on_sale": false, - "purchasable": true, - "total_sales": 5, - "virtual": false, - "downloadable": false, - "downloads": [], - "download_limit": -1, - "download_expiry": -1, - "external_url": "", - "button_text": "", - "tax_status": "taxable", - "tax_class": "", - "manage_stock": false, - "stock_quantity": null, - "backorders": "no", - "backorders_allowed": false, - "backordered": false, - "low_stock_amount": null, - "sold_individually": false, - "weight": "", - "dimensions": { - "length": "", - "width": "", - "height": "" - }, - "shipping_required": true, - "shipping_taxable": true, - "shipping_class": "", - "shipping_class_id": 0, - "reviews_allowed": false, - "average_rating": "0.00", - "rating_count": 0, - "upsell_ids": [], - "cross_sell_ids": [], - "parent_id": 0, - "purchase_note": "", - "categories": [], - "tags": [], - "images": [{ - "id": 2127, - "date_created": "2020-01-28T09:52:58", - "date_created_gmt": "2020-01-28T09:52:58", - "date_modified": "2020-01-28T09:52:58", - "date_modified_gmt": "2020-01-28T09:52:58", - "src": "https:\/\/i0.wp.com\/automatticwidgets.wpcomstaging.com\/wp-content\/uploads\/2020\/01\/Mask-Group-2.png?fit=200%2C201&ssl=1", - "name": "Mask Group-2", - "alt": "" - }], - "attributes": [], - "default_attributes": [], - "variations": [], - "grouped_products": [], - "menu_order": 0, - "price_html": "$<\/span>110.00<\/bdi><\/span>", - "related_ids": [], - "meta_data": [{ - "id": 2596, - "key": "_product_addons", - "value": [] - }, { - "id": 2597, - "key": "_product_addons_exclude_global", - "value": "0" - }, { - "id": 2613, - "key": "_wpas_done_all", - "value": "1" - }, { - "id": 4051, - "key": "_last_editor_used_jetpack", - "value": "classic-editor" - }], - "stock_status": "instock", - "jetpack_publicize_connections": [], - "jetpack_likes_enabled": false, - "jetpack_sharing_enabled": true, - "_links": { - "self": [{ - "href": "https:\/\/automatticwidgets.wpcomstaging.com\/wp-json\/wc\/v3\/products\/2129" - }], - "collection": [{ - "href": "https:\/\/automatticwidgets.wpcomstaging.com\/wp-json\/wc\/v3\/products" - }] - } - }, { "id": 2130, "name": "Black Coral shades", "slug": "black-coral-shades", diff --git a/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products_add_new.json b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products_add_new.json new file mode 100644 index 00000000000..0396d1de172 --- /dev/null +++ b/WooCommerce/WooCommerceUITests/Mocks/mappings/jetpack-blogs/wc/products/products_add_new.json @@ -0,0 +1,126 @@ +{ + "request": { + "method": "POST", + "urlPath": "/rest/v1.1/jetpack-blogs/161477129/rest-api/", + "bodyPatterns": [ + { "matches": ".*path=/wc/v3/products%26_method%3Dpost" }, + { "contains": "name%22%3A%22Akoya%20Pearl%20shades" } + ] + }, + "response": { + "status": 200, + "jsonBody": { + "data": { + "id": 2129, + "name": "Akoya Pearl shades", + "slug": "akoya-pearl-shades", + "permalink": "https:\/\/automatticwidgets.wpcomstaging.com\/product\/akoya-pearl-shades\/", + "date_created": "{{#assign 'customformat'}}yyyy-MM-dd'T'HH:mm:ss{{/assign}}{{now format=customformat}}", + "date_created_gmt": "{{now format=customformat}}", + "date_modified": "{{now format=customformat}}", + "date_modified_gmt": "{{now format=customformat}}", + "type": "simple", + "status": "publish", + "featured": false, + "catalog_visibility": "visible", + "description": "", + "short_description": "", + "sku": "", + "price": "110", + "regular_price": "110", + "sale_price": "", + "date_on_sale_from": null, + "date_on_sale_from_gmt": null, + "date_on_sale_to": null, + "date_on_sale_to_gmt": null, + "on_sale": false, + "purchasable": true, + "total_sales": 0, + "virtual": false, + "downloadable": false, + "downloads": [], + "download_limit": -1, + "download_expiry": -1, + "external_url": "", + "button_text": "", + "tax_status": "taxable", + "tax_class": "", + "manage_stock": false, + "stock_quantity": null, + "backorders": "no", + "backorders_allowed": false, + "backordered": false, + "low_stock_amount": null, + "sold_individually": false, + "weight": "", + "dimensions": { + "length": "", + "width": "", + "height": "" + }, + "shipping_required": true, + "shipping_taxable": true, + "shipping_class": "", + "shipping_class_id": 0, + "reviews_allowed": true, + "average_rating": "0", + "rating_count": 0, + "upsell_ids": [], + "cross_sell_ids": [], + "parent_id": 0, + "purchase_note": "", + "categories": [], + "tags": [], + "images": [{ + "id": 2127, + "date_created": "2020-01-28T09:52:58", + "date_created_gmt": "2020-01-28T09:52:58", + "date_modified": "2020-01-28T09:52:58", + "date_modified_gmt": "2020-01-28T09:52:58", + "src": "https:\/\/i0.wp.com\/automatticwidgets.wpcomstaging.com\/wp-content\/uploads\/2020\/01\/Mask-Group-2.png?fit=200%2C201&ssl=1", + "name": "Mask Group-2", + "alt": "" + }], + "attributes": [], + "default_attributes": [], + "variations": [], + "grouped_products": [], + "menu_order": 0, + "price_html": "", + "related_ids": [], + "meta_data": [{ + "id": 2596, + "key": "_product_addons", + "value": [] + }, { + "id": 2597, + "key": "_product_addons_exclude_global", + "value": "0" + }, { + "id": 2613, + "key": "_wpas_done_all", + "value": "1" + }, { + "id": 4051, + "key": "_last_editor_used_jetpack", + "value": "classic-editor" + }], + "stock_status": "instock", + "has_options": false, + "jetpack_likes_enabled": true, + "_links": { + "self": [ + { + "href": "https:\/\/automatticwidgets.wpcomstaging.com\/wp-json\/wc\/v3\/products\/2129" + } + ], + "collection": [ + { + "href": "https:\/\/automatticwidgets.wpcomstaging.com\/wp-json\/wc\/v3\/products" + } + ] + } + } + } + } +} diff --git a/WooCommerce/WooCommerceUITests/README.md b/WooCommerce/WooCommerceUITests/README.md index 0824bda0c8b..dc305c22070 100644 --- a/WooCommerce/WooCommerceUITests/README.md +++ b/WooCommerce/WooCommerceUITests/README.md @@ -43,7 +43,7 @@ The following flows are covered/planned to be covered by UI tests. Tests that ar - [x] Order Creation flow can be dismissed 4. Products - [x] Products list and single product screens load - - [ ] Add new product - Simple physical product + - [x] Add new product - Simple physical product - [ ] Add new product - Simple virtual product - [ ] Add new product - Variable product - [ ] Add new product - Grouped product diff --git a/WooCommerce/WooCommerceUITests/Tests/ProductsTests.swift b/WooCommerce/WooCommerceUITests/Tests/ProductsTests.swift index 29ad5f94e25..13ce4003e67 100644 --- a/WooCommerce/WooCommerceUITests/Tests/ProductsTests.swift +++ b/WooCommerce/WooCommerceUITests/Tests/ProductsTests.swift @@ -3,6 +3,14 @@ import XCTest final class ProductsTests: XCTestCase { + let productTypes = [ + "physical": "Simple physical product", + "virtual": "Simple virtual product", + "variable": "Variable product", + "grouped": "Grouped product", + "external": "External product" + ] + override func setUpWithError() throws { continueAfterFailure = false @@ -23,4 +31,15 @@ final class ProductsTests: XCTestCase { .goBackToProductList() .verifyProductsScreenLoaded() } + + func test_add_simple_physical_product() throws { + let product = try GetMocks.readNewProductData() + + try TabNavComponent().goToProductsScreen() + .tapAddProduct() + .selectProductType(productType: productTypes["physical"]!) + .addProductTitle(productTitle: product.name) + .publishProduct() + .verifyNewProductScreenLoaded(productName: product.name) + } }