Skip to content

Commit c66708d

Browse files
committed
Test fixes
1 parent 8f80c01 commit c66708d

File tree

3 files changed

+6
-121
lines changed

3 files changed

+6
-121
lines changed

Modules/Tests/StorageTests/GRDB/PersistedProductBarcodeQueryTests.swift

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -63,68 +63,6 @@ struct PersistedProductBarcodeQueryTests {
6363
#expect(result == nil)
6464
}
6565

66-
@Test("posProductByGlobalUniqueID filters out downloadable products")
67-
func test_global_unique_id_query_filters_downloadable() async throws {
68-
// Given
69-
let globalUniqueID = "UPC-DOWNLOADABLE"
70-
let downloadableProduct = PersistedProduct(
71-
id: 2,
72-
siteID: siteID,
73-
name: "Downloadable Product",
74-
productTypeKey: "simple",
75-
fullDescription: nil,
76-
shortDescription: nil,
77-
sku: nil,
78-
globalUniqueID: globalUniqueID,
79-
price: "5.00",
80-
downloadable: true,
81-
parentID: 0,
82-
manageStock: false,
83-
stockQuantity: nil,
84-
stockStatusKey: "instock"
85-
)
86-
try await insertProduct(downloadableProduct)
87-
88-
// When
89-
let result = try await grdbManager.databaseConnection.read { db in
90-
try PersistedProduct.posProductByGlobalUniqueID(siteID: siteID, globalUniqueID: globalUniqueID).fetchOne(db)
91-
}
92-
93-
// Then
94-
#expect(result == nil)
95-
}
96-
97-
@Test("posProductByGlobalUniqueID filters out unsupported product types")
98-
func test_global_unique_id_query_filters_unsupported_types() async throws {
99-
// Given
100-
let globalUniqueID = "UPC-GROUPED"
101-
let groupedProduct = PersistedProduct(
102-
id: 3,
103-
siteID: siteID,
104-
name: "Grouped Product",
105-
productTypeKey: "grouped",
106-
fullDescription: nil,
107-
shortDescription: nil,
108-
sku: nil,
109-
globalUniqueID: globalUniqueID,
110-
price: "0.00",
111-
downloadable: false,
112-
parentID: 0,
113-
manageStock: false,
114-
stockQuantity: nil,
115-
stockStatusKey: "instock"
116-
)
117-
try await insertProduct(groupedProduct)
118-
119-
// When
120-
let result = try await grdbManager.databaseConnection.read { db in
121-
try PersistedProduct.posProductByGlobalUniqueID(siteID: siteID, globalUniqueID: globalUniqueID).fetchOne(db)
122-
}
123-
124-
// Then
125-
#expect(result == nil)
126-
}
127-
12866
// MARK: - Site Isolation Tests
12967

13068
@Test("Queries only return products from specified site")

Modules/Tests/StorageTests/GRDB/PersistedProductVariationBarcodeQueryTests.swift

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -80,54 +80,6 @@ struct PersistedProductVariationBarcodeQueryTests {
8080
#expect(result == nil)
8181
}
8282

83-
@Test("posVariationByGlobalUniqueID filters out downloadable variations")
84-
func test_global_unique_id_query_filters_downloadable() async throws {
85-
// Given
86-
let globalUniqueID = "VAR-DOWNLOADABLE"
87-
88-
// Insert parent product first
89-
let parentProduct = PersistedProduct(
90-
id: 10,
91-
siteID: siteID,
92-
name: "Parent Product",
93-
productTypeKey: "variable",
94-
fullDescription: nil,
95-
shortDescription: nil,
96-
sku: nil,
97-
globalUniqueID: nil,
98-
price: "0.00",
99-
downloadable: false,
100-
parentID: 0,
101-
manageStock: false,
102-
stockQuantity: nil,
103-
stockStatusKey: "instock"
104-
)
105-
try await insertProduct(parentProduct)
106-
107-
let downloadableVariation = PersistedProductVariation(
108-
id: 101,
109-
siteID: siteID,
110-
productID: 10,
111-
sku: nil,
112-
globalUniqueID: globalUniqueID,
113-
price: "5.00",
114-
downloadable: true,
115-
fullDescription: nil,
116-
manageStock: false,
117-
stockQuantity: nil,
118-
stockStatusKey: "instock"
119-
)
120-
try await insertVariation(downloadableVariation)
121-
122-
// When
123-
let result = try await grdbManager.databaseConnection.read { db in
124-
try PersistedProductVariation.posVariationByGlobalUniqueID(siteID: siteID, globalUniqueID: globalUniqueID).fetchOne(db)
125-
}
126-
127-
// Then
128-
#expect(result == nil)
129-
}
130-
13183
// MARK: - Site Isolation Tests
13284

13385
@Test("Queries only return variations from specified site")

Modules/Tests/YosemiteTests/PointOfSale/PointOfSaleLocalBarcodeScanServiceTests.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ struct PointOfSaleLocalBarcodeScanServiceTests {
182182
try await insertProduct(groupedProduct)
183183

184184
// When/Then - Should not find unsupported product type
185-
await #expect(throws: PointOfSaleBarcodeScanError.notFound(scannedCode: barcode)) {
185+
await #expect(throws: PointOfSaleBarcodeScanError.unsupportedProductType(scannedCode: barcode,
186+
productName: "Grouped Product",
187+
productType: .grouped)) {
186188
_ = try await sut.getItem(barcode: barcode)
187189
}
188190
}
@@ -210,17 +212,10 @@ struct PointOfSaleLocalBarcodeScanServiceTests {
210212
try await insertProduct(variableParentProduct)
211213

212214
// When/Then - Should throw unsupportedProductType error
213-
do {
215+
await #expect(throws: PointOfSaleBarcodeScanError.unsupportedProductType(scannedCode: barcode,
216+
productName: "Variable Parent Product",
217+
productType: .variable)) {
214218
_ = try await sut.getItem(barcode: barcode)
215-
Issue.record("Expected unsupportedProductType error but none was thrown")
216-
} catch let error as PointOfSaleBarcodeScanError {
217-
guard case .unsupportedProductType(let scannedCode, let productName, let productType) = error else {
218-
Issue.record("Expected unsupportedProductType error, got \(error)")
219-
return
220-
}
221-
#expect(scannedCode == barcode)
222-
#expect(productName == "Variable Parent Product")
223-
#expect(productType == .variable)
224219
}
225220
}
226221

0 commit comments

Comments
 (0)