Use a <main> tag on every page
Many pages had this tag, but many other didn't, which made navigation inconsistent for people using screen readers. Note that there are slight changes in two pages: * The homepage now includes the banner and the content of the `shared/header` element inside the <main> tag * The budgets index now includes the banner inside the <main> tag I see both potential advantages and disadvantages of this approach, since banners aren't necessarily related to the main content of a page but on the other hand they aren't the same across pages and people using screen readers might accidentally skip them if they jump to the <main> tag. So I'm choosing the option that is easier to implement. Note we're adding a `public-content` class to the <main> element in the application layout. This might be redundat because the element could already be accessed through the `.public main` selector, but this is consistent with the `admin-content` class used in the admin section, and without it the <main> element would sometimes have an empty class attribute and we'd have to use `if content_for?(:main_class)` or `tag.main` which IMHO makes the code less consistent. The Capybara::DSL monkey-patch is only done on the `visit` method because it's the only reliable one. Other methods like `click_link` generate AJAX requests, so `expect(page).to have_css "main", count: 1` might be executed before the AJAX request is finished, meaning it wouldn't properly test anything.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<main class="admin-budgets-show">
|
<% provide :main_class, "admin-budgets-show" %>
|
||||||
|
|
||||||
<%= back_link_to admin_budgets_path %>
|
<%= back_link_to admin_budgets_path %>
|
||||||
|
|
||||||
<%= header %>
|
<%= header %>
|
||||||
@@ -21,4 +22,3 @@
|
|||||||
<h3 id="actions_header"><%= t("admin.budgets.edit.actions") %></h3>
|
<h3 id="actions_header"><%= t("admin.budgets.edit.actions") %></h3>
|
||||||
<%= render Admin::Budgets::ActionsComponent.new(budget) %>
|
<%= render Admin::Budgets::ActionsComponent.new(budget) %>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="admin-budgets-wizard-headings-index">
|
<% provide :main_class, "admin-budgets-wizard-headings-index" %>
|
||||||
|
|
||||||
<%= back_link_to admin_budgets_wizard_budget_groups_path(budget, url_params), back_link_text %>
|
<%= back_link_to admin_budgets_wizard_budget_groups_path(budget, url_params), back_link_text %>
|
||||||
|
|
||||||
<%= header %>
|
<%= header %>
|
||||||
@@ -11,4 +12,3 @@
|
|||||||
<%= render Admin::BudgetHeadings::HeadingsComponent.new(headings) %>
|
<%= render Admin::BudgetHeadings::HeadingsComponent.new(headings) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render Admin::BudgetsWizard::Headings::CreationStepComponent.new(new_heading) %>
|
<%= render Admin::BudgetsWizard::Headings::CreationStepComponent.new(new_heading) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
<% provide :main_class, "budget-groups-index" %>
|
||||||
|
|
||||||
<% content_for :canonical do %>
|
<% content_for :canonical do %>
|
||||||
<%= render "shared/canonical", href: budget_groups_url %>
|
<%= render "shared/canonical", href: budget_groups_url %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<main class="budget-groups-index">
|
|
||||||
<%= header(before: back_link_to(budget_path(budget))) %>
|
<%= header(before: back_link_to(budget_path(budget))) %>
|
||||||
<%= render Budgets::GroupsAndHeadingsComponent.new(budget) %>
|
<%= render Budgets::GroupsAndHeadingsComponent.new(budget) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<main class="budget-investment-new">
|
<% provide :main_class, "budget-investment-new" %>
|
||||||
|
|
||||||
<%= back_link_to budgets_path %>
|
<%= back_link_to budgets_path %>
|
||||||
|
|
||||||
<%= header %>
|
<%= header %>
|
||||||
|
|
||||||
<%= render "/budgets/investments/form", form_url: budget_investments_path(budget) %>
|
<%= render "/budgets/investments/form", form_url: budget_investments_path(budget) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="debate-new">
|
<% provide :main_class, "debate-new" %>
|
||||||
|
|
||||||
<%= back_link_to debates_path, t("debates.index.section_header.title") %>
|
<%= back_link_to debates_path, t("debates.index.section_header.title") %>
|
||||||
|
|
||||||
<%= header do %>
|
<%= header do %>
|
||||||
@@ -17,4 +18,3 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<%= render Debates::FormComponent.new(debate) %>
|
<%= render Debates::FormComponent.new(debate) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="moderation-users-index">
|
<% provide :main_class, "moderation-users-index" %>
|
||||||
|
|
||||||
<h2><%= t("moderation.users.index.title") %></h2>
|
<h2><%= t("moderation.users.index.title") %></h2>
|
||||||
|
|
||||||
<%= render Admin::SearchComponent.new(label: t("moderation.users.index.search_placeholder")) %>
|
<%= render Admin::SearchComponent.new(label: t("moderation.users.index.search_placeholder")) %>
|
||||||
@@ -44,4 +45,3 @@
|
|||||||
|
|
||||||
<%= paginate users %>
|
<%= paginate users %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="proposal-new">
|
<% provide :main_class, "proposal-new" %>
|
||||||
|
|
||||||
<%= back_link_to proposals_path, t("proposals.index.section_header.title") %>
|
<%= back_link_to proposals_path, t("proposals.index.section_header.title") %>
|
||||||
|
|
||||||
<%= header do %>
|
<%= header do %>
|
||||||
@@ -16,4 +17,3 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<%= render Proposals::FormComponent.new(proposal, url: proposals_path) %>
|
<%= render Proposals::FormComponent.new(proposal, url: proposals_path) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% provide(:title) { title } %>
|
<% provide(:title) { title } %>
|
||||||
|
<% provide :main_class, "sdg-goals-index" %>
|
||||||
|
|
||||||
<main class="sdg-goals-index">
|
|
||||||
<% if header.present? %>
|
<% if header.present? %>
|
||||||
<%= render "shared/header", header: header %>
|
<%= render "shared/header", header: header %>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -22,4 +22,3 @@
|
|||||||
<%= render "shared/cards", cards: phase.cards.sort_by_order %>
|
<%= render "shared/cards", cards: phase.cards.sort_by_order %>
|
||||||
</section>
|
</section>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<% provide(:title) { goal.title } %>
|
<% provide(:title) { goal.title } %>
|
||||||
|
<% provide :main_class, "sdg-goal-show" %>
|
||||||
|
|
||||||
<main class="sdg-goal-show">
|
|
||||||
<%= back_link_to sdg_goals_path %>
|
<%= back_link_to sdg_goals_path %>
|
||||||
|
|
||||||
<article class="sdg-goal sdg-goal-<%= code %>">
|
<article class="sdg-goal sdg-goal-<%= code %>">
|
||||||
@@ -36,4 +36,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render SDG::Goals::TargetsComponent.new(goal) %>
|
<%= render SDG::Goals::TargetsComponent.new(goal) %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="subscriptions-edit">
|
<% provide :main_class, "subscriptions-edit" %>
|
||||||
|
|
||||||
<%= form_for user, url: subscriptions_path(token: user.subscriptions_token) do |f| %>
|
<%= form_for user, url: subscriptions_path(token: user.subscriptions_token) do |f| %>
|
||||||
<h2><%= t("account.show.notifications") %></h2>
|
<h2><%= t("account.show.notifications") %></h2>
|
||||||
|
|
||||||
@@ -10,4 +11,3 @@
|
|||||||
|
|
||||||
<%= f.submit t("account.show.save_changes_submit"), class: "button margin-top" %>
|
<%= f.submit t("account.show.save_changes_submit"), class: "button margin-top" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
<main id="ballot" class="budget-ballot-show">
|
<% provide :main_class, "budget-ballot-show" %>
|
||||||
|
|
||||||
|
<div id="ballot">
|
||||||
<%= render "budgets/ballot/ballot" %>
|
<%= render "budgets/ballot/ballot" %>
|
||||||
</main>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="budget-group-show">
|
<% provide :main_class, "budget-group-show" %>
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<%= back_link_to budget_path(@budget) %>
|
<%= back_link_to budget_path(@budget) %>
|
||||||
<h1><%= t("budgets.groups.show.title") %></h1>
|
<h1><%= t("budgets.groups.show.title") %></h1>
|
||||||
@@ -25,4 +26,3 @@
|
|||||||
<%= image_tag(image_path_for("map.jpg")) %>
|
<%= image_tag(image_path_for("map.jpg")) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<%= render Shared::BannerComponent.new("budgets") %>
|
<%= render Shared::BannerComponent.new("budgets") %>
|
||||||
|
|
||||||
<% provide :title do %><%= t("budgets.index.title") %><% end %>
|
<% provide :title do %><%= t("budgets.index.title") %><% end %>
|
||||||
|
<% provide :main_class, "budgets-index" %>
|
||||||
|
|
||||||
<% content_for :canonical do %>
|
<% content_for :canonical do %>
|
||||||
<%= render "shared/canonical", href: budgets_url %>
|
<%= render "shared/canonical", href: budgets_url %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<main class="budgets-index">
|
|
||||||
<% if @budget.present? %>
|
<% if @budget.present? %>
|
||||||
<%= render Budgets::BudgetComponent.new(@budget) %>
|
<%= render Budgets::BudgetComponent.new(@budget) %>
|
||||||
|
|
||||||
@@ -28,4 +28,3 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render Budgets::FooterComponent.new %>
|
<%= render Budgets::FooterComponent.new %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<main id="budget-investments-main">
|
|
||||||
<% if @search_terms || @advanced_search_terms %>
|
<% if @search_terms || @advanced_search_terms %>
|
||||||
<%= render Shared::SearchResultsSummaryComponent.new(
|
<%= render Shared::SearchResultsSummaryComponent.new(
|
||||||
results: @investments,
|
results: @investments,
|
||||||
@@ -87,4 +86,3 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
<%= render "shared/canonical", href: debates_url %>
|
<%= render "shared/canonical", href: debates_url %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<main>
|
|
||||||
<% if @search_terms || @advanced_search_terms %>
|
<% if @search_terms || @advanced_search_terms %>
|
||||||
<%= render Shared::SearchResultsSummaryComponent.new(
|
<%= render Shared::SearchResultsSummaryComponent.new(
|
||||||
results: @debates,
|
results: @debates,
|
||||||
@@ -82,6 +81,4 @@
|
|||||||
<%= render "shared/tag_cloud", taggable: "Debate" %>
|
<%= render "shared/tag_cloud", taggable: "Debate" %>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="admin-content <%= yield(:main_class) %>">
|
<main class="admin-content <%= yield(:main_class) %>">
|
||||||
<%= label_tag :show_menu, t("admin.menu.admin"),
|
<%= label_tag :show_menu, t("admin.menu.admin"),
|
||||||
"aria-hidden": true, class: "button hollow expanded" %>
|
"aria-hidden": true, class: "button hollow expanded" %>
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
|
|
||||||
<div class="wrapper <%= yield(:wrapper_class) %>">
|
<div class="wrapper <%= yield(:wrapper_class) %>">
|
||||||
<%= render "layouts/header", with_subnavigation: true %>
|
<%= render "layouts/header", with_subnavigation: true %>
|
||||||
<%= render "layouts/flash" %>
|
|
||||||
|
|
||||||
|
<main class="public-content <%= yield(:main_class) %>">
|
||||||
|
<%= render "layouts/flash" %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<%= render "dashboard/menu" %>
|
<%= render "dashboard/menu" %>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="admin-content">
|
<main class="admin-content <%= yield(:main_class) %>">
|
||||||
<%= label_tag :show_menu, t("admin.menu.admin"),
|
<%= label_tag :show_menu, t("admin.menu.admin"),
|
||||||
"aria-hidden": true, class: "button hollow expanded" %>
|
"aria-hidden": true, class: "button hollow expanded" %>
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<%= render "layouts/dashboard/proposal_totals" %>
|
<%= render "layouts/dashboard/proposal_totals" %>
|
||||||
<%= render "layouts/dashboard/proposal_header" %>
|
<%= render "layouts/dashboard/proposal_header" %>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-9 large-7 small-centered column">
|
<div class="small-12 medium-9 large-7 small-centered column">
|
||||||
<div class="auth-form margin">
|
<main class="auth-form margin <%= yield(:main_class) %>">
|
||||||
<%= render "layouts/flash" %>
|
<%= render "layouts/flash" %>
|
||||||
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
<%= render "shared/canonical", href: proposals_url %>
|
<%= render "shared/canonical", href: proposals_url %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<main>
|
|
||||||
<% if [
|
<% if [
|
||||||
@search_terms,
|
@search_terms,
|
||||||
@advanced_search_terms,
|
@advanced_search_terms,
|
||||||
@@ -125,6 +124,4 @@
|
|||||||
<%= render "proposals_lists" %>
|
<%= render "proposals_lists" %>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<main>
|
|
||||||
<div class="row proposals-summary">
|
<div class="row proposals-summary">
|
||||||
<div id="proposals" class="proposals-list small-12 medium-9 column">
|
<div id="proposals" class="proposals-list small-12 medium-9 column">
|
||||||
<%= back_link_to %>
|
<%= back_link_to %>
|
||||||
@@ -50,4 +49,3 @@
|
|||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<main class="topic-edit">
|
<% provide :main_class, "topic-edit" %>
|
||||||
|
|
||||||
<%= back_link_to community_path(@community) %>
|
<%= back_link_to community_path(@community) %>
|
||||||
|
|
||||||
<h1><%= t("community.topic.edit") %></h1>
|
<h1><%= t("community.topic.edit") %></h1>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<main class="topic-new">
|
<% provide :main_class, "topic-new" %>
|
||||||
|
|
||||||
<%= back_link_to community_path(@community) %>
|
<%= back_link_to community_path(@community) %>
|
||||||
|
|
||||||
<h1><%= t("community.topic.create") %></h1>
|
<h1><%= t("community.topic.create") %></h1>
|
||||||
@@ -14,4 +15,3 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<%= render "form" %>
|
<%= render "form" %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<main>
|
|
||||||
<div class="activity row margin-top">
|
<div class="activity row margin-top">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
|
||||||
@@ -25,4 +24,3 @@
|
|||||||
<%= render Users::PublicActivityComponent.new(@user) %>
|
<%= render Users::PublicActivityComponent.new(@user) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
<%= render "shared/header", header: @header %>
|
<%= render "shared/header", header: @header %>
|
||||||
|
|
||||||
<main>
|
|
||||||
<%= render "feeds" %>
|
<%= render "feeds" %>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -37,4 +36,3 @@
|
|||||||
recommended_debates: @recommended_debates,
|
recommended_debates: @recommended_debates,
|
||||||
recommended_proposals: @recommended_proposals %>
|
recommended_proposals: @recommended_proposals %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</main>
|
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="error">
|
<main class="error">
|
||||||
<h1>403</h1>
|
<h1>403</h1>
|
||||||
<h2>Access to this page has been disabled by the administrators.</h2>
|
<h2>Access to this page has been disabled by the administrators.</h2>
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="error">
|
<main class="error">
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<h2>Not found.</h2>
|
<h2>Not found.</h2>
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="error">
|
<main class="error">
|
||||||
<h1>422</h1>
|
<h1>422</h1>
|
||||||
<h2>The change you wanted was rejected.</h2>
|
<h2>The change you wanted was rejected.</h2>
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -33,9 +33,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="error">
|
<main class="error">
|
||||||
<h1>500</h1>
|
<h1>500</h1>
|
||||||
<h2>Internal server error.</h2>
|
<h2>Internal server error.</h2>
|
||||||
</div>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -53,6 +53,20 @@ end
|
|||||||
|
|
||||||
FactoryBot.use_parent_strategy = false
|
FactoryBot.use_parent_strategy = false
|
||||||
|
|
||||||
|
module Capybara
|
||||||
|
module DSL
|
||||||
|
alias_method :original_visit, :visit
|
||||||
|
|
||||||
|
def visit(url, ...)
|
||||||
|
original_visit(url, ...)
|
||||||
|
|
||||||
|
unless url.match?("robots.txt") || url.match?("active_storage/representations")
|
||||||
|
expect(page).to have_css "main", count: 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.register_driver :headless_chrome do |app|
|
Capybara.register_driver :headless_chrome do |app|
|
||||||
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
|
||||||
opts.add_argument "--headless"
|
opts.add_argument "--headless"
|
||||||
|
|||||||
Reference in New Issue
Block a user