FactoryBot.define do
  factory :broadcast do
    association :project
    name "My Live Stream"

    transient do
      skip_create_callback false
    end

    trait :with_stream do
      stream_uid "mux_stream"
      stream_key "mux_key"
      stream_playback_uid "mux_playback_id"
      status "created"
      streamer_status "idle"
    end

    trait :with_files do
      files { [Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf')] }
    end

    after(:build) do |broadcast, evaluator|
      if evaluator.skip_create_callback
        broadcast.class.skip_callback(:create, :after, :create_mux_live_stream, raise: false)
      end
    end
  end
end
