diff --git a/Tests/AppTests/ViewSnapshotTests.swift b/Tests/AppTests/ViewSnapshotTests.swift index bddcab4..9e77736 100644 --- a/Tests/AppTests/ViewSnapshotTests.swift +++ b/Tests/AppTests/ViewSnapshotTests.swift @@ -73,6 +73,40 @@ final class ViewSnapshotTests: XCTestCase { // assertSnapshot(of: res.body.string, as: .html) // } // } + + func testUserViews() async throws { + try await withDependencies { + $0.database.users = .mock + } operation: { + @Dependency(\.database) var database + + try await configure(app, makeDatabaseClient: { _ in database }) + + try app.test(.GET, router.path(for: .user(.form))) { res in + assertSnapshot(of: res.body.string, as: .html) + } + + try app.test(.POST, router.path(for: .user(.index))) { req in + req.body = ByteBuffer(string: "username=test&email=test@test.com&password=super-secret&confirmPassword=super-secret") + } afterResponse: { res in + assertSnapshot(of: res.body.string, as: .html) + } + + try app.test(.GET, router.path(for: .user(.index))) { res in + assertSnapshot(of: res.body.string, as: .html) + } + + try app.test(.GET, router.path(for: .user(.get(id: UUID(0))))) { res in + assertSnapshot(of: res.body.string, as: .html) + } + + try app.test(.PATCH, router.path(for: .user(.update(id: UUID(0), updates: .mock)))) { req in + req.body = .init(string: "username=test&email=test@test.com") + } afterResponse: { res in + assertSnapshot(of: res.body.string, as: .html) + } + } + } } extension DatabaseClient.Employees { @@ -87,6 +121,22 @@ extension DatabaseClient.Employees { } } +extension DatabaseClient.Users { + static var mock: Self { + .init( + count: { 1 }, + create: { _ in User.mock }, + delete: { _ in }, + fetchAll: { [User.mock] }, + get: { _ in User.mock }, + login: { _ in User.Token.mock }, + logout: { _ in }, + token: { _ in User.Token.mock }, + update: { _, _ in User.mock } + ) + } +} + extension Date { static var mock: Self { Date(timeIntervalSince1970: 1_234_567_890) @@ -140,6 +190,18 @@ extension User.Create { } } +extension User.Token { + static var mock: Self { + .init(id: UUID(1), userID: UUID(0), value: "test-token") + } +} + +extension User.Update { + static var mock: Self { + User.Update(username: "test", email: "test@test.com") + } +} + extension Vendor { static var mock: Self { .init(id: UUID(0), name: "Test", branches: nil, createdAt: .mock, updatedAt: .mock) diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeCreate.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeCreate.1.html deleted file mode 100644 index f7f933d..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeCreate.1.html +++ /dev/null @@ -1 +0,0 @@ -Testy Mctestface \ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeForm.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeForm.1.html deleted file mode 100644 index 07f5b73..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeForm.1.html +++ /dev/null @@ -1 +0,0 @@ -Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Employees


Employees are who purchase orders can be issued to.


Name
Testy Mctestface
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeGet.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeGet.1.html deleted file mode 100644 index d81307b..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeGet.1.html +++ /dev/null @@ -1 +0,0 @@ -Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Employees


Employees are who purchase orders can be issued to.


Name
Testy Mctestface
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.1.html deleted file mode 100644 index df00bd3..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.1.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.2.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.2.html deleted file mode 100644 index e381095..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeSelect.2.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeUpdate.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeUpdate.1.html deleted file mode 100644 index f7f933d..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeUpdate.1.html +++ /dev/null @@ -1 +0,0 @@ -Testy Mctestface \ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testPurchaseOrderIndex.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testPurchaseOrderIndex.1.html deleted file mode 100644 index 5ca5c5e..0000000 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testPurchaseOrderIndex.1.html +++ /dev/null @@ -1 +0,0 @@ -Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Purchase Orders



POWork OrderCustomerVendorMaterialsCreated For
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.1.html new file mode 100644 index 0000000..83bc1ed --- /dev/null +++ b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.1.html @@ -0,0 +1 @@ +Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Users


Users are who can login and issue purchase orders for employees.


UsernameEmail
testtest@example.com
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.2.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.2.html new file mode 100644 index 0000000..e5e94b4 --- /dev/null +++ b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.2.html @@ -0,0 +1 @@ +testtest@example.com \ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeIndex.1.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.3.html similarity index 56% rename from Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeIndex.1.html rename to Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.3.html index d2162e7..c4c6b22 100644 --- a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testEmployeeIndex.1.html +++ b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.3.html @@ -1 +1 @@ -Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Employees


Employees are who purchase orders can be issued to.


Name
Testy Mctestface
\ No newline at end of file +Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Users


Users are who can login and issue purchase orders for employees.


UsernameEmail
testtest@example.com
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.4.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.4.html new file mode 100644 index 0000000..db9aadc --- /dev/null +++ b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.4.html @@ -0,0 +1 @@ +Purchase Orders
xPurchase OrdersUsersEmployeesVendors
Logout

Users


Users are who can login and issue purchase orders for employees.


Created:Updated:
UsernameEmail
testtest@example.com
\ No newline at end of file diff --git a/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.5.html b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.5.html new file mode 100644 index 0000000..e5e94b4 --- /dev/null +++ b/Tests/AppTests/__Snapshots__/ViewSnapshotTests/testUserViews.5.html @@ -0,0 +1 @@ +testtest@example.com \ No newline at end of file