Implemented phase 3 for the POC prototype in the Website service.
This commit is contained in:
1 parent
b1ceed7790
commit
0dc3fe6bea
29 files changed
+4089
-66
No files matched your search
@@ -127,6 +127,52 @@ struct AppTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func `buying to open a sale record for its buyer alone`() async throws {
|
||||
try await app(
|
||||
staticFilesPath: staticFilesPath
|
||||
).test(.router) { client in
|
||||
let form: HTTPFields = [.contentType: "application/x-www-form-urlencoded"]
|
||||
let cookie = try await client.execute(
|
||||
uri: "/sign-in",
|
||||
method: .post,
|
||||
headers: form,
|
||||
body: ByteBuffer(string: "return=/")
|
||||
) { response in
|
||||
String(try #require(response.headers[.setCookie]).prefix { $0 != ";" })
|
||||
}
|
||||
var signedIn = form
|
||||
|
||||
signedIn[.cookie] = cookie
|
||||
|
||||
let sale = try await client.execute(
|
||||
uri: "/listing/echo-country-3/buy",
|
||||
method: .post,
|
||||
headers: signedIn
|
||||
) { response in
|
||||
#expect(response.status == .seeOther)
|
||||
|
||||
return try #require(response.headers[.location])
|
||||
}
|
||||
|
||||
try await client.execute(
|
||||
uri: sale,
|
||||
method: .get,
|
||||
headers: [.cookie: cookie]
|
||||
) { response in
|
||||
#expect(response.status == .ok)
|
||||
#expect(String(buffer: response.body).contains("Awaiting payment"))
|
||||
}
|
||||
|
||||
try await client.execute(
|
||||
uri: sale,
|
||||
method: .get
|
||||
) { response in
|
||||
#expect(response.status == .found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func `error page to be served for an unknown listing`() async throws {
|
||||
try await app(
|
||||
|
||||
Reference in new issue
Block a user