feat: Adds purchase order view tests.
This commit is contained in:
@@ -63,20 +63,41 @@ struct ViewControllerTests {
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
// func purchaseOrderViews() async throws {
|
||||
// try await withSnapshotTesting(record: record) {
|
||||
// try await withDependencies {
|
||||
// $0.database.purchaseOrders = .mock
|
||||
// $0.viewController = .liveValue
|
||||
// } operation: {
|
||||
// @Dependency(\.viewController) var viewController
|
||||
//
|
||||
// let htmlString = try await viewController.render(.login(.index(next: "/purchase-orders")))
|
||||
// assertSnapshot(of: htmlString, as: .html)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@Test
|
||||
func purchaseOrderViews() async throws {
|
||||
try await withSnapshotTesting(record: record) {
|
||||
try await withDependencies {
|
||||
$0.dateFormatter = .liveValue
|
||||
$0.database.purchaseOrders = .mock
|
||||
$0.viewController = .liveValue
|
||||
} operation: {
|
||||
@Dependency(\.viewController) var viewController
|
||||
|
||||
var htmlString = try await viewController.render(.purchaseOrder(.index))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
|
||||
htmlString = try await viewController.render(.purchaseOrder(.form))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
|
||||
htmlString = try await viewController.render(.purchaseOrder(.create(.mock)))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
|
||||
htmlString = try await viewController.render(.purchaseOrder(.get(id: 1)))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
|
||||
htmlString = try await viewController.render(.purchaseOrder(.page(page: 1, limit: 25)))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
|
||||
for context in ViewRoute.PurchaseOrderRoute.Search.Context.allCases {
|
||||
htmlString = try await viewController.render(.purchaseOrder(.search(.index(
|
||||
context: context,
|
||||
table: true
|
||||
))))
|
||||
assertSnapshot(of: htmlString, as: .html)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func userViews() async throws {
|
||||
@@ -183,6 +204,21 @@ extension DatabaseClient.Employees {
|
||||
}
|
||||
}
|
||||
|
||||
extension DatabaseClient.PurchaseOrders {
|
||||
|
||||
static var mock: Self {
|
||||
.init(
|
||||
create: { _ in .mock },
|
||||
fetchAll: { [.mock] },
|
||||
fetchPage: { _ in .init(items: [.mock], metadata: .init(page: 1, per: 1, total: 1)) },
|
||||
get: { _ in .mock },
|
||||
delete: { _ in },
|
||||
search: { _, _ in .init(items: [.mock], metadata: .init(page: 1, per: 1, total: 1)) }
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension DatabaseClient.Users {
|
||||
static var mock: Self {
|
||||
.init(
|
||||
@@ -341,3 +377,9 @@ extension PurchaseOrder {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension PurchaseOrder.Create {
|
||||
static var mock: Self {
|
||||
.init(materials: "bar", customer: "Testy McTestface", createdByID: UUID(0), createdForID: UUID(0), vendorBranchID: UUID(0))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user