Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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
7 changes: 4 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ def text_byline(creation, options={})
def link_to_modal(content = "", options = {})
options[:class] ||= ""
options[:for] ||= ""
options[:title] ||= options[:for]

html_options = { class: "#{options[:class]} modal", title: options[:title] }
html_options[:"aria-label"] = options[:aria_label] if options[:aria_label]

link_to content, options[:for], html_options
end

Expand All @@ -183,12 +184,12 @@ def link_to_help(help_entry, link = '<span class="symbol question"><span>?</span
help_file = "#{ArchiveConfig.HELP_DIRECTORY}/#{help_entry}.html"
end

" ".html_safe + link_to_modal(link, for: help_file, title: help_entry.split('-').join(' ').capitalize, class: "help symbol question").html_safe
" ".html_safe + link_to_modal(link, for: help_file, aria_label: help_entry.split("-").join(" ").capitalize, class: "help symbol question").html_safe
end

def link_to_help_modal(help_path, title)
link = tag.span(tag.span(t("application_helper.help_modal.help_symbol")), class: %w[symbol question])
" ".html_safe + link_to_modal(link, for: help_path, title: title, class: "help symbol question")
" ".html_safe + link_to_modal(link, for: help_path, aria_label: title, class: "help symbol question")
end

# Inserts the flash alert messages for flash[:key] wherever
Expand Down
2 changes: 1 addition & 1 deletion config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,7 @@ en:
legend: Display
show_adult_content: Show me adult content without checking.
show_whole_work_default: Show the whole work by default.
locale_help_title: Locale preferences
locale_help_title: Locale preferences help
misc:
heading: Misc
legend: Misc
Expand Down
4 changes: 2 additions & 2 deletions features/other_a/help.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Help
Given I am logged in as "first_user"
When I go to the collections page
When I follow "New Collection"
And I follow "Collection moderated"
And I follow help tag "Collection moderated"
Then I should see "By default, collections are not moderated"

Scenario: view the help popup for chapter title
Expand All @@ -29,7 +29,7 @@ Feature: Help
And I fill in "content" with "Well, maybe not so epic."
And I press "Post"
And I follow "Add Chapter"
And I follow "Chapter title"
And I follow help tag "Chapter title"
Then I should see "You can add a chapter title"

Scenario: Asked to log in if trying to access the first login page as guest
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def with_scope(locator)
end
end

When /^(?:|I )follow help tag "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector| # rubocop:disable Cucumber/RegexStepName
with_scope(selector) do
find(:xpath, "//*[@aria-label='#{link}']").click
end
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be nicer to call this step "I open help modal", it probably wouldn't ever need the "within selector" part, and as sarken said, you can use the capybara option in the step definition, so it could look like this

When /^(?:|I )open help modal "([^"]*)"$/ do |link|
  Capybara.enable_aria_label = true
  step %{I follow "#{link}"}
end

and it doesn't really belong in web_steps.rb, you can make a new file help_steps.rb for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOH THATS WHAT

It looks like it would be possible to use that in the step definition

meant.

I didn't do that, because I thought "Capybara.enable_aria_label" would enable it globally and that sounds like it could have side effects in other tests?

I can do it like that though no problem

When /^(?:|I )follow '([^']*)'(?: within "([^"]*)")?$/ do |link, selector|
with_scope(selector) do
click_link(link)
Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/ao3modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ jQuery(document).ready(function() {
.filter(function() {
return $(this).closest('.userstuff').length === 0;
}).click(function(event){
_show($(this).attr('href'), $(this).attr('title'));
_show($(this).attr('href'), $(this).attr('title') ? $(this).attr('title') : $(this).attr('aria-label'));
event.preventDefault();
});

Expand Down
2 changes: 1 addition & 1 deletion public/javascripts/ao3modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading