22import { fakerPT_BR as faker } from '@faker-js/faker' ;
33
44describe ( 'Funcionalidade de consultar a reserva com o ID' , ( ) => {
5- it ( 'Verificar dados da reserva após consulta por ID' , ( ) => {
65
6+ var reserva = {
7+ "firstname" : faker . name . firstName ( ) ,
8+ "lastname" : faker . name . lastName ( ) ,
9+ "totalprice" : 3500 ,
10+ "depositpaid" : faker . datatype . boolean ( ) ,
11+ "bookingdates" : {
12+ "checkin" : "2026-09-26" ,
13+ "checkout" : "2025-10-02"
14+ } ,
15+ "additionalneeds" : faker . word . words ( )
16+ }
17+ it ( 'Verificar que dados da reserva estão corretos após consulta por ID' , ( ) => {
18+ //criação da reserva
19+ cy . createBooking ( reserva ) . then ( ( response ) => {
20+ const bookingId = response . body . bookingid
21+
22+
23+ //consulta e valida reserva
24+ cy . getBookingById ( bookingId ) . then ( ( response ) => {
25+ expect ( response . status ) . to . eq ( 200 )
26+
27+ expect ( response . body ) . to . have . property ( 'firstname' , reserva . firstname )
28+ expect ( response . body . lastname ) . to . eq ( reserva . lastname )
29+ expect ( response . body ) . to . have . property ( 'totalprice' , reserva . totalprice )
30+ expect ( response . body ) . to . have . property ( 'depositpaid' , reserva . depositpaid )
31+ expect ( response . body . bookingdates ) . to . have . property ( 'checkin' , reserva . bookingdates . checkin )
32+ expect ( response . body . bookingdates ) . to . have . property ( 'checkout' , reserva . bookingdates . checkout )
33+ expect ( response . body ) . to . have . property ( 'additionalneeds' , reserva . additionalneeds )
34+ } )
35+ } )
36+ } )
37+
38+ it ( 'Verificar erro 404 ao consultar por ID inexistente' , ( ) => {
39+ const bookingId = 789654
40+ cy . getBookingById ( bookingId ) . then ( ( response ) => {
41+ expect ( response . status ) . to . eq ( 404 )
42+ expect ( response . body ) . contains ( 'Not Found' )
43+ } )
744 } )
845} )
0 commit comments