Skip to content

Commit

Permalink
test(bookings): visitor-kiosk visitor checkin flow
Browse files Browse the repository at this point in the history
  • Loading branch information
chillfox committed Aug 13, 2024
1 parent f9da286 commit 85f803c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/controllers/bookings_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2234,4 +2234,44 @@ describe Bookings do
booking.deleted.should be_true
booking.children.not_nil!.all? { |b| b.deleted == true }.should be_true
end

context "[visitor-kiosk]", tags: ["visitor-kiosk"] do
it "checks in a visitor" do
tenant = get_tenant

Check warning on line 2240 in spec/controllers/bookings_spec.cr

View workflow job for this annotation

GitHub Actions / Ameba

Lint/UselessAssign

Useless assignment to variable `tenant`
Raw output
> tenant = get_tenant
  ^

starting = Random.new.rand(5..19).minutes.from_now.to_unix
ending = Random.new.rand(25..39).minutes.from_now.to_unix

visitor_email = Faker::Internet.email

# Create booking with attendee
create_booking_response = client.post(BOOKINGS_BASE, headers: headers,
body: %({"asset_id":"room_one","booking_start":#{starting},"booking_end":#{ending},"booking_type":"room","attendees": [
{
"name": "#{Faker::Name.first_name}",
"email": "#{visitor_email}",
"checked_in": false,
"visit_expected": true
}]})
)
create_booking_response.status_code.should eq(201)
booking = Booking.from_json(create_booking_response.body)

# Find guest by email
guest_response = client.get("#{GUESTS_BASE}/#{visitor_email}", headers: headers)
guest_response.status_code.should eq(200)
guest_id = JSON.parse(guest_response.body)["id"]

Check warning on line 2263 in spec/controllers/bookings_spec.cr

View workflow job for this annotation

GitHub Actions / Ameba

Lint/UselessAssign

Useless assignment to variable `guest_id`
Raw output
> guest_id = JSON.parse(guest_response.body)["id"]
  ^

# update induction state on booking
update_state_response = client.post("#{BOOKINGS_BASE}/#{booking.id}/update_state?state=inducted", headers: headers)
update_state_response.status_code.should eq(200)
booking = Booking.from_json(update_state_response.body)
booking.induction.should be_true

# change booking guests to attendees
booking.attendees = booking.guests
booking.guests = nil
update_response = client.patch("#{BOOKINGS_BASE}/#{booking.id}", headers: headers, body: booking.to_json)

Check warning on line 2274 in spec/controllers/bookings_spec.cr

View workflow job for this annotation

GitHub Actions / Ameba

Lint/UselessAssign

Useless assignment to variable `update_response`
Raw output
> update_response = client.patch("#{BOOKINGS_BASE}/#{booking.id}", headers: headers, body: booking.to_json)
  ^
end
end
end

0 comments on commit 85f803c

Please sign in to comment.