Skip to content

Inconsistent naming #794

Description

@dunkelziffer

Describe the bug

The user guide is pretty unambiguous what the definition of a scenario is:

Each public method defined in the preview class represents a unique scenario [...]

Source: https://lookbook.build/guide/concepts#scenarios

However, when I call Lookbook.preview.first.scenarios, I get a Lookbook::ScenarioCollection that contains Lookbook::ScenarioEntity AND Lookbook::ScenarioGroupEntity.

To Reproduce

class TestComponentPreview < ViewComponent::Preview
  # @!group Scenario Group

  def scenario_a
    render TestComponent.new
  end

  def scenario_b
    render TestComponent.new
  end

  # @!endgroup
end

This results in:

Lookbook.previews.first.scenarios.map(&:name)
# => ["scenario_group"]

However, scenario_group is not a method on my TestComponentPreview.

Expected behavior

Lookbook.previews.first.scenarios.map(&:name)
# => ["scenario_a", "scenario_b"]

Screenshots

Version numbers

Please complete the following information:

  • Lookbook: 2.3.14
  • ViewComponent: 4.6.0
  • Rails: 8.1.3
  • Ruby: 4.0.1

Additional context

As I workaround, I can fall back to the protected method scenario_entities:

Lookbook.previews.first.send(:scenario_entities).map(&:name)
# => ["scenario_a", "scenario_b"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions