Sha256: 145722453d436fd5a6cab2b9309a1650ae15969a77ae48783fe8b11ab470b02b

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module DaVinciCRDTestKit
  class SubmittedResponseValidationTest < Inferno::Test
    include CardsValidation

    title 'Custom CDS Service Response is valid'
    id :crd_submitted_response_validation

    input :custom_response, optional: true

    def hook_name
      config.options[:hook_name]
    end

    def response_label(_index = nil)
      'Custom response'
    end

    def valid_cards
      @valid_cards ||= []
    end

    def validate_system_actions(system_actions)
      return if system_actions.nil?

      system_actions.each do |action|
        action_fields_validation(action)
      end
    end

    run do
      omit_if custom_response.blank?, 'Custom response was not provided'

      assert_valid_json custom_response

      custom_response_hash = JSON.parse(custom_response)

      perform_cards_validation(custom_response_hash['cards'])

      validate_system_actions(custom_response_hash['systemActions'])

      no_error_validation('Custom response is not valid. Check messages for issues found.')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
davinci_crd_test_kit-0.10.0 lib/davinci_crd_test_kit/client_tests/submitted_response_validation.rb
davinci_crd_test_kit-0.9.1 lib/davinci_crd_test_kit/client_tests/submitted_response_validation.rb
davinci_crd_test_kit-0.9.1.rc lib/davinci_crd_test_kit/client_tests/submitted_response_validation.rb