Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactive snapshot tests #2139

Merged
merged 7 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion lib/primer/static/generate_previews.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ def call
scenarios = parent_scenario.type == :scenario_group ? parent_scenario.scenarios : [parent_scenario]

scenarios.map do |scenario|
snapshot_tag = scenario.tags.find { |tag| tag.tag_name == "snapshot" }
snapshot = if snapshot_tag.nil?
"false"
elsif snapshot_tag.text.blank?
"true"
else
snapshot_tag.text
end
{
preview_path: scenario.lookup_path,
name: scenario.name,
snapshot: scenario.tags.any? { |e| e.tag_name == "snapshot" }.to_s,
snapshot: snapshot,
skip_rules: Primer::Accessibility.axe_rules_to_skip(
component: component,
scenario_name: scenario.name
Expand Down
5 changes: 5 additions & 0 deletions previews/primer/alpha/action_menu_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def content_labels

# @label Default
#
# @snapshot interactive
def default
render(Primer::Alpha::ActionMenu.new(menu_id: "menu-1")) do |menu|
menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
Expand All @@ -50,6 +51,7 @@ def default

# @label Wide
#
# @snapshot interactive
def wide
render(Primer::Alpha::ActionMenu.new(select_variant: :single, size: :medium)) do |menu|
menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "A wider menu" }
Expand Down Expand Up @@ -119,6 +121,7 @@ def links

# @label Single item selected
#
# @snapshot interactive
def single_selected_item
render(Primer::Alpha::ActionMenu.new(select_variant: :single)) do |menu|
menu.with_show_button { "Menu" }
Expand All @@ -130,6 +133,7 @@ def single_selected_item

# @label Single Select with Internal Label
#
# @snapshot interactive
def single_select_with_internal_label
render(Primer::Alpha::ActionMenu.new(select_variant: :single, dynamic_label: true, dynamic_label_prefix: "Menu")) do |menu|
menu.with_show_button { |button| button.with_trailing_action_icon(icon: :"triangle-down"); "Menu" }
Expand All @@ -143,6 +147,7 @@ def single_select_with_internal_label

# @label Multiple items selected
#
# @snapshot interactive
def multiple_selected_items
render(Primer::Alpha::ActionMenu.new(select_variant: :multiple)) do |menu|
menu.with_show_button { "Menu" }
Expand Down
1 change: 1 addition & 0 deletions previews/primer/alpha/dialog_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def playground(title: "Test Dialog", subtitle: nil, size: :medium, button_text:
# @param visually_hide_title [Boolean] toggle
# @param button_text [String] text
# @param body_text [String] text
# @snapshot interactive
def default(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: position, position_narrow: position_narrow, visually_hide_title: visually_hide_title)) do |d|
d.with_show_button { button_text }
Expand Down
1 change: 1 addition & 0 deletions previews/primer/alpha/dropdown_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def playground(overlay: :default, with_caret: false)

# @label Default
#
# @snapshot interactive
def default
render(Primer::Alpha::Dropdown.new) do |component|
component.with_button { "Dropdown" }
Expand Down
Loading
Loading