September 2018
Intermediate to advanced
398 pages
9h 43m
English
From now on, every time we interact with the cart, we will have to pass the cookie with the session ID to bind our user with the cart. The test to get the list of products in the cart is as follows:
"list all the products in a cart" in {
val loginCookies = Await.result(wsClient.url(login).post("me").map(p => p.headers.get("Set-Cookie").map(_.head.split(";").head)), 1 seconds)
val play_session = loginCookies.get.split("=").tail.mkString("")
val response = (wsClient.url(productsInCartURL). addCookies(DefaultWSCookie("PLAY_SESSION", play_session)).get().futureValue
println(response)
response.status mustBe OK
val listOfProduct = decode[Seq[Cart]](response.body)
listOfProduct.right.get mustBe empty
}
First, we call the ...
Read now
Unlock full access