Skip to content

HTML cannot be rendered if a 'text/json' attachment is present #1787

Open
@mitchgrout

Description

@mitchgrout

👓 What did you see?

Given an object which represents some JSON object, attach(object, "text/json") will correctly add an attachment envelope to the output message stream, and will be included in the HTML body. However, attempting to open this report (at least in Chrome) results in only a white screen being rendered.

If for example, object = { "foo": 42 }, then within the message stream we have (prettified):

{
  "attachment": {
    "body": {"foo":42},
    "contentEncoding": "IDENTITY",
    "mediaType": "text/json",
    "testCaseStartedId": "a92d9794-86d9-4c14-a913-1f8ddb736289",
    "testStepId": "5996f98b-fe36-48e3-94be-b3b2433344c2"
  }
}

✅ What did you expect to see?

The page should continue to be loadable, and either display the attached text/json in a plaintext form or in any other way.

📦 Which tool/library version are you using?

cucumber-html-formatter v19.2.0

🔬 How could we reproduce it?

  1. Create features/test.feature with:
# features/test.feature
Feature: Reproduction of problem
  Scenario: Example scenario
    When nothing happens
  1. Create features/step_definitions/all.rb with:
When('nothing happens') { }
  1. Create features/support/env.rb with:
After do |test|
  context = {
    "foo" => 42,
  }

  attach(context, "text/json")
end
  1. Run cucumber -f html -o cucumber.html
  2. Load the cucumber.html into a browser of choice, and check that:
    1. only a white screen is displayed, and
    2. the attachment message is present in the message list, and
    3. if the attachment message is removed, the page is rendered correctly

📚 Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions