Class: SpreeCmCommissioner::LoadTest::GenerateBookingTicketData
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::LoadTest::GenerateBookingTicketData
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb
Overview
Generates the cash_on_booking_ticket_flow / aba_booking_ticket_flow load-test data for one variant so it can be used by the k6 booking flow. An admin/organizer picks a ticket variant in the dashboard; this reads its product / variant / event straight off the models and returns the payload the flow needs, plus a "can this actually be booked?" check so the tester knows it will drive the flow. Mirrors GenerateVotingFixtureData's cash-on/ABA payment resolution (gems/spree_cm_commissioner/app/services/spree_cm_commissioner/load_test/ generate_voting_fixture_data.rb) for the same two payment methods, applied to a variant instead of a voting session.
Flow: pick a ticket variant in admin/organizer -> copy this payload into
load_testing/config/fixture/<platform|tenant>/
Returns success({ data: ..., issues: [...] }). issues is empty when the variant is ready
to load-test; otherwise it lists why the booking flow would fail — including "no payment
method configured" for whichever flow you asked for. issues (plus a ready flag) are
duplicated into data[:metadata] so they travel with the copied JSON — the k6 flow ignores
that key, it's there for a human to read later.
Constant Summary collapse
- FLOWS =
%w[cash_on_booking_ticket_flow aba_booking_ticket_flow].freeze
- PAYWAY_CHECKOUT_PATH =
ABA's checkout endpoint is fixed regardless of tenant/environment — only
host(sandbox vs production) differs, and that comes off the payment method. See Vpago::PaywayV2::Checkout#checkout_url in gems/spree_vpago. Mirrors GenerateVotingFixtureData::PAYWAY_CHECKOUT_PATH. '/api/payment-gateway/v1/payments/purchase'.freeze
Instance Method Summary collapse
-
#call(variant:, flow: 'cash_on_booking_ticket_flow') ⇒ Object
flow: which payment method to resolve — 'cash_on_booking_ticket_flow' (the default) or 'aba_booking_ticket_flow' (ABA/PayWay v2, adds a
paywayblock).
Instance Method Details
#call(variant:, flow: 'cash_on_booking_ticket_flow') ⇒ Object
flow: which payment method to resolve — 'cash_on_booking_ticket_flow' (the default) or
'aba_booking_ticket_flow' (ABA/PayWay v2, adds a payway block).
Whether the variant needs load_testing/tests/platform/seat_selection_booking_flow instead of
the plain booking_ticket_flow isn't a choice the caller makes — it's read straight off
variant.seat_selection_enabled? (same signal add-to-cart itself uses), restricted to
platform-hosted products since seat_selection_booking_flow has no tenant sibling yet. That
result is surfaced as metadata[:select_seat] and, when true, adds quantity_per_booking to
the payload since that flow's Create Draft Order step needs to know how many seats to pick.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb', line 45 def call(variant:, flow: 'cash_on_booking_ticket_flow') raise ArgumentError, "Unknown flow: #{flow.inspect} (expected one of: #{FLOWS.join(', ')})" unless FLOWS.include?(flow) product = variant.product event = product.event select_seat = variant.seat_selection_enabled? && product.tenant_id.blank? issues = issues_for(variant, event, require_seat_selection: select_seat) data = { event_permalink: event&.permalink, product_slug: product.slug, product_id: product.id, variant_id: variant.id } data[:quantity_per_booking] = 1 if select_seat issues.concat(payment_method_issues(variant, flow, data)) # Informational only — the k6 flow never reads this. Carries the readiness check (and which # flow it was checked against) into the copied JSON itself, so it's visible later without # regenerating from admin/organizer. data[:metadata] = { ready: issues.empty?, select_seat: select_seat, issues: issues } success(data: data, issues: issues) rescue StandardError => e failure(nil, e.) end |