Using a `data-toggle` attribute, which we do since commit07fd5084f, made Foundation generate an `aria-expanded` attribute to a radio button, but this attribute can't be present in radio buttons. This makes sense, since the main purpose of a radio button in a form is to choose an option, not to show/hide content. This resulted in the following error when checking the page with Axe: ``` Found 1 accessibility violation: aria-allowed-attr: Elements must only use supported ARIA attributes (critical) https://dequeuniversity.com/rules/axe/4.10/aria-allowed-attr?application=axeAPI The following 2 nodes violate this rule: Selector: #dashboard_action_action_type_proposed_action HTML: <input data-toggle="request_to_administrators short_description" type="radio" value="proposed_action" checked="checked" name="dashboard_action[action_type]" id="dashboard_action_action_type_proposed_action" aria-expanded="true" aria-controls="request_to_administrators"> Fix all of the following: - ARIA attribute is not allowed: aria-expanded="true" Selector: #dashboard_action_action_type_resource HTML: <input data-toggle="request_to_administrators short_description" type="radio" value="resource" name="dashboard_action[action_type]" id="dashboard_action_action_type_resource" aria-expanded="true" aria-controls="request_to_administrators"> Fix all of the following: - ARIA attribute is not allowed: aria-expanded="true" ``` So we're using custom JavaScript instead. We're also making the `short_description` field act as intended; since the changes in commit07fd5084fit was never shown because it had the `hide` HTML class and it didn't have a `data-toggler` attribute.
125 lines
3.6 KiB
Ruby
125 lines
3.6 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Admin dashboard actions", :admin do
|
|
it_behaves_like "nested documentable",
|
|
"administrator",
|
|
"dashboard_action",
|
|
"new_admin_dashboard_action_path",
|
|
{},
|
|
"documentable_fill_new_valid_dashboard_action",
|
|
"Save",
|
|
"Action created successfully"
|
|
|
|
context "when visiting index" do
|
|
context "and no actions defined" do
|
|
before do
|
|
visit admin_dashboard_actions_path
|
|
end
|
|
|
|
scenario "shows only default actions" do
|
|
expect(page).to have_content("Polls")
|
|
expect(page).to have_content("Email")
|
|
expect(page).to have_content("Poster")
|
|
|
|
expect(page).to have_link "Edit", count: 3
|
|
end
|
|
end
|
|
|
|
context "and actions defined" do
|
|
let!(:action) { create(:dashboard_action) }
|
|
|
|
before do
|
|
visit admin_dashboard_actions_path
|
|
end
|
|
|
|
scenario "shows the action data" do
|
|
expect(page).to have_content(action.title)
|
|
end
|
|
end
|
|
end
|
|
|
|
context "when creating an action" do
|
|
let(:action) { build(:dashboard_action) }
|
|
|
|
before do
|
|
visit admin_dashboard_actions_path
|
|
click_link "Create resource or action"
|
|
end
|
|
|
|
scenario "Creates a new action" do
|
|
fill_in "Title", with: action.title
|
|
fill_in_ckeditor "Description", with: action.description
|
|
|
|
click_button "Save"
|
|
|
|
expect(page).to have_content(action.title)
|
|
end
|
|
|
|
scenario "Renders create form in case data is invalid" do
|
|
click_button "Save"
|
|
|
|
expect(page).to have_content("error prevented this Dashboard/Action from being saved.")
|
|
end
|
|
end
|
|
|
|
context "when editing an action" do
|
|
let!(:action) { create(:dashboard_action) }
|
|
|
|
before do
|
|
visit admin_dashboard_actions_path
|
|
within "#dashboard_action_#{action.id}" do
|
|
click_link "Edit"
|
|
end
|
|
end
|
|
|
|
scenario "Updates the action" do
|
|
expect(page).to have_checked_field "Proposed action"
|
|
expect(page).to have_unchecked_field "Resource"
|
|
expect(page).not_to have_field "Short description"
|
|
expect(page).not_to have_field "Include in the resource a button to " \
|
|
"request the resource from administrators"
|
|
|
|
choose "Resource"
|
|
check "Include in the resource a button to request the resource from administrators"
|
|
|
|
fill_in "Title", with: "Great action!"
|
|
fill_in "Short description", with: "And awesome too!"
|
|
click_button "Save"
|
|
|
|
expect(page).to have_content "Great action!"
|
|
end
|
|
|
|
scenario "Renders edit form in case data is invalid" do
|
|
fill_in "Title", with: "x"
|
|
click_button "Save"
|
|
expect(page).to have_content("error prevented this Dashboard/Action from being saved.")
|
|
end
|
|
end
|
|
|
|
context "when destroying an action" do
|
|
let!(:action) { create(:dashboard_action) }
|
|
|
|
scenario "deletes the action" do
|
|
visit admin_dashboard_actions_path
|
|
|
|
accept_confirm("Are you sure? This action will delete \"#{action.title}\" and can't be undone.") do
|
|
click_button "Delete"
|
|
end
|
|
|
|
expect(page).not_to have_content(action.title)
|
|
end
|
|
|
|
scenario "cannot delete actions that have been executed" do
|
|
create(:dashboard_executed_action, action: action)
|
|
|
|
visit admin_dashboard_actions_path
|
|
|
|
accept_confirm("Are you sure? This action will delete \"#{action.title}\" and can't be undone.") do
|
|
click_button "Delete"
|
|
end
|
|
|
|
expect(page).to have_content("Cannot delete record because dependent executed actions exist")
|
|
end
|
|
end
|
|
end
|