Implemented phase 5 for the POC prototype in the Website service.
This commit is contained in:
1 parent
89a7a7b8e5
commit
31d2d98d49
46 files changed
+4039
-162
No files matched your search
@@ -173,6 +173,38 @@ struct AppTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func `landing page to catch up once a copy is sold`() async throws {
|
||||
try await app(
|
||||
staticFilesPath: staticFilesPath
|
||||
).test(.router) { client in
|
||||
let sold = #"href="/listing/echo-country-3""#
|
||||
let before = try await client.execute(uri: "/", method: .get) { response in
|
||||
#expect(String(buffer: response.body).contains(sold))
|
||||
|
||||
return try #require(response.headers[.eTag])
|
||||
}
|
||||
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
|
||||
|
||||
try await client.execute(uri: "/listing/echo-country-3/buy", method: .post, headers: signedIn) { response in
|
||||
#expect(response.status == .seeOther)
|
||||
}
|
||||
|
||||
try await client.execute(uri: "/", method: .get, headers: [.ifNoneMatch: before]) { response in
|
||||
// The page changed, so the entity tag a browser holds no longer revalidates.
|
||||
#expect(response.status == .ok)
|
||||
#expect(response.headers[.eTag] != before)
|
||||
#expect(!String(buffer: response.body).contains(sold))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
func `error page to be served for an unknown listing`() async throws {
|
||||
try await app(
|
||||
|
||||
Reference in new issue
Block a user