require "govuk_schemas"

module RandomContentHelpers
  def generate_random_edition(base_path)
    random = GovukSchemas::RandomExample.for_schema(publisher_schema: "placeholder")

    random.merge_and_validate(
      routes: [
        { path: base_path, type: "prefix" } # hard to do in schemas
      ],
      base_path: base_path,

      # TODOs:
      title: "Something not empty", # TODO: make schemas validate title length
      document_type: "guide", # TODO: remove after https://github.com/alphagov/govuk-content-schemas/pull/550 deployed
      rendering_app: "something", # TODO: make schemas validate rendering_app
      publishing_app: "something", # TODO: make schemas validate rendering_app
      redirects: [], # TODO: make schemas validate redirects
    )
  end

  def random_content_failure_message(response, edition)
    <<-DOC
    Failed #{response.request.method} #{response.request.fullpath}

    Content:
    #{JSON.pretty_generate(edition)}

    Response:
    #{JSON.pretty_generate(parsed_response)}"
    DOC
  end
end

require "govuk_schemas"

module RandomContentHelpers
  def generate_random_edition(base_path)
    random = GovukSchemas::RandomExample.for_schema(publisher_schema: "placeholder")

    random.merge_and_validate(
      routes: [
        { path: base_path, type: "prefix" } # hard to do in schemas
      ],
      base_path: base_path,

      # TODOs:
      title: "Something not empty", # TODO: make schemas validate title length
      document_type: "guide", # TODO: remove after https://github.com/alphagov/govuk-content-schemas/pull/550 deployed
      rendering_app: "government-frontend", # TODO: remove after https://github.com/alphagov/govuk-content-schemas/pull/575
      publishing_app: "publisher", # TODO: remove after https://github.com/alphagov/govuk-content-schemas/pull/575
      redirects: [], # TODO: make schemas validate redirects
    )
  end

  def random_content_failure_message(response, edition)
    <<-DOC
    Failed #{response.request.method} #{response.request.fullpath}

    Content:
    #{JSON.pretty_generate(edition)}

    Response:
    #{JSON.pretty_generate(parsed_response)}"
    DOC
  end
end

Use realistic values in rendering_app & publishing_app
Use realistic values in rendering_app & publishing_app

This is required to make
https://github.com/alphagov/govuk-content-schemas/pull/575 pass, which
will allow us to remove the overrides.
