Class: SpreeCmCommissioner::LoadTest::GenerateBookingTicketData

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb

Overview

Generates the booking_ticket_flow load-test data for one variant so it can be used by the k6 booking flow. An admin 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.

Flow: pick a ticket variant in admin -> copy this payload into load_testing/config/fixture/platform/booking_ticket_flow/.json -> Env.fixture() reads that file when running k6 (load_testing/tests/platform/booking_ticket_flow).

Returns success({ data: ..., issues: [...] }). issues is empty when the variant is ready to load-test; otherwise it lists why the booking flow would fail. The same 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.

Instance Method Summary collapse

Instance Method Details

#call(variant:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb', line 19

def call(variant:)
  product = variant.product
  event = product.event
  issues = issues_for(variant, event)

  data = {
    event_permalink: event&.permalink,
    product_slug: product.slug,
    product_id: product.id,
    variant_id: variant.id,
    # Informational only — the k6 flow never reads this. Carries the readiness check into
    # the copied JSON itself, so it's visible later without regenerating from admin.
    metadata: {
      ready: issues.empty?,
      issues: issues
    }
  }

  success(data: data, issues: issues)
rescue StandardError => e
  failure(nil, e.message)
end