Module: Primer::Accessibility
- Defined in:
- lib/primer/accessibility.rb
Overview
:nodoc:
Constant Summary collapse
- IGNORED_PREVIEWS =
Skip axe checks for components that should be tested as part of a larger component. Do not add to this list for any other reason!
[ Primer::Beta::MarkdownPreview, Primer::Beta::AutoCompleteItemPreview ].freeze
- AXE_RULES_TO_SKIP =
Skip ‘:region` which relates to preview page structure rather than individual component. Skip `:color-contrast` which requires primer design-level change.
{ # these will be skipped in CI but will still be tracked in Datadog will_fix: { global: %i[ color-contrast ], per_component: {} }, # these will always be skipped wont_fix: { global: %i[ region ], per_component: { Primer::Alpha::ToggleSwitch => { all_scenarios: %i[button-name] } } } }.freeze
Class Method Summary collapse
- .axe_rules_to_skip(component: nil, scenario_name: nil, flatten: false) ⇒ Object
- .ignore_preview?(preview_class) ⇒ Boolean
Class Method Details
.axe_rules_to_skip(component: nil, scenario_name: nil, flatten: false) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/primer/accessibility.rb', line 45 def axe_rules_to_skip(component: nil, scenario_name: nil, flatten: false) to_skip = { wont_fix: Set.new(AXE_RULES_TO_SKIP.dig(:wont_fix, :global) || []), will_fix: Set.new(AXE_RULES_TO_SKIP.dig(:will_fix, :global) || []) } if component to_skip[:wont_fix].merge(AXE_RULES_TO_SKIP.dig(:wont_fix, :per_component, component, :all_scenarios) || []) to_skip[:will_fix].merge(AXE_RULES_TO_SKIP.dig(:will_fix, :per_component, component, :all_scenarios) || []) if scenario_name to_skip[:wont_fix].merge(AXE_RULES_TO_SKIP.dig(:wont_fix, :per_component, component, scenario_name) || []) to_skip[:will_fix].merge(AXE_RULES_TO_SKIP.dig(:will_fix, :per_component, component, scenario_name) || []) end end if flatten flattened = to_skip.each_with_object(Set.new) do |(_, rule_set), memo| memo.merge(rule_set) end return flattened.to_a end to_skip.transform_values(&:to_a) end |
.ignore_preview?(preview_class) ⇒ Boolean
41 42 43 |
# File 'lib/primer/accessibility.rb', line 41 def ignore_preview?(preview_class) IGNORED_PREVIEWS.include?(preview_class) end |