Skip to content

Commit f9188e4

Browse files
authored
Merge pull request #9887 from woocommerce/add-external-product-test
[UI Test] - Add External Product Test
2 parents d66b3fa + 67c2eba commit f9188e4

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

WooCommerce/UITestsFoundation/Screens/Products/SingleProductScreen.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,20 @@ public final class SingleProductScreen: ScreenObject {
5656
XCTAssertTrue(app.staticTexts["Add variations"].exists)
5757
case "grouped":
5858
XCTAssertTrue(app.staticTexts["Grouped products"].exists)
59+
case "external":
60+
XCTAssertTrue(app.staticTexts["Add product link"].exists)
5961
default:
6062
XCTFail("Product Type \(productType) doesn't exist!")
6163
}
6264
}
6365

6466
public func verifyProductTypeScreenLoaded(productType: String) throws -> Self {
65-
let productTypeLabel = NSPredicate(format: "label ==[c] '\(productType)'")
67+
let productTypeLabel = productType + (productType == "external" ? "/Affiliate" : "")
68+
let productTypeLabelPredicate = NSPredicate(format: "label ==[c] '\(productTypeLabel)'")
6669

6770
// the common fields on add product screen
6871
XCTAssertTrue(app.cells["product-review-cell"].exists)
69-
XCTAssertTrue(app.staticTexts.containing(productTypeLabel).firstMatch.exists)
72+
XCTAssertTrue(app.staticTexts.containing(productTypeLabelPredicate).firstMatch.exists)
7073

7174
// different product types display different fields on add product screen
7275
// this is to validate that the correct screens are displayed
@@ -80,6 +83,10 @@ public final class SingleProductScreen: ScreenObject {
8083
case "grouped":
8184
XCTAssertTrue(app.staticTexts["Add products to the group"].exists)
8285
XCTAssertFalse(app.staticTexts["Inventory"].exists)
86+
case "external":
87+
XCTAssertTrue(app.staticTexts["Add product link"].exists)
88+
XCTAssertTrue(app.staticTexts["Add Price"].exists)
89+
XCTAssertFalse(app.staticTexts["Inventory"].exists)
8390
default:
8491
XCTFail("Product Type \(productType) doesn't exist!")
8592
}

WooCommerce/WooCommerceUITests/Flows/MockDataReader.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class GetMocks {
2222
"physical": "products_add_new_physical_2129",
2323
"virtual": "products_add_new_virtual_2123",
2424
"variable": "products_add_new_variable_2131",
25-
"grouped": "products_add_new_grouped_2130"
25+
"grouped": "products_add_new_grouped_2130",
26+
"external": "products_add_new_external_2132"
2627
]
2728

2829
static func getMockData(test: AnyClass, filename file: String) -> Data {

WooCommerce/WooCommerceUITests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The following flows are covered/planned to be covered by UI tests. Tests that ar
4747
- [x] Add new product - Simple virtual product
4848
- [x] Add new product - Variable product
4949
- [x] Add new product - Grouped product
50-
- [ ] Add new product - External product
50+
- [x] Add new product - External product
5151
- [x] Search product
5252
- [x] Filter product
5353
- [ ] Edit product

WooCommerce/WooCommerceUITests/Tests/ProductsTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ final class ProductsTests: XCTestCase {
4040
try ProductFlow.addAndVerifyNewProduct(productType: "grouped")
4141
}
4242

43+
func test_add_external_product() throws {
44+
try ProductFlow.addAndVerifyNewProduct(productType: "external")
45+
}
46+
4347
func test_search_product() throws {
4448
let products = try GetMocks.readProductsData()
4549

0 commit comments

Comments
 (0)