Skip to content

Commit 72eb812

Browse files
gbathreeclaude
andcommitted
Add view spec for invoice settings label associations
Verifies that all checkbox labels on the invoice settings page have `for` attributes that match their corresponding input `id` values, so screen readers announce the correct label for each control. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent be5189c commit 72eb812

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "admin/invoice_settings/edit.html.haml" do
4+
helper Spree::Admin::NavigationHelper
5+
6+
before do
7+
stub_template "spree/admin/shared/_configuration_menu.html.haml" => ""
8+
allow(view).to receive(:spree_current_user).and_return(build(:user))
9+
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).and_return(false)
10+
end
11+
12+
it "has labels correctly associated with their checkboxes" do
13+
render
14+
15+
expect(rendered).to have_css('label[for="preferences_enable_invoices_"]')
16+
expect(rendered).to have_css('input[id="preferences_enable_invoices_"]')
17+
18+
expect(rendered).to have_css('label[for="preferences_invoice_style2_"]')
19+
expect(rendered).to have_css('input[id="preferences_invoice_style2_"]')
20+
21+
expect(rendered).to have_css('label[for="preferences_enterprise_number_required_on_invoices_"]')
22+
expect(rendered).to have_css('input[id="preferences_enterprise_number_required_on_invoices_"]')
23+
end
24+
end
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "spree/admin/orders/_filters.html.haml" do
4+
helper Spree::Admin::NavigationHelper
5+
helper Spree::Admin::BaseHelper
6+
7+
before do
8+
user = create(:user)
9+
allow(view).to receive_messages spree_current_user: user
10+
allow(Spree::ShippingMethod).to receive(:managed_by).and_return(Spree::ShippingMethod.none)
11+
allow(Enterprise).to receive(:is_distributor).and_return(
12+
double(managed_by: Enterprise.none)
13+
)
14+
allow(OrderCycle).to receive(:managed_by).and_return(
15+
OrderCycle.none
16+
)
17+
end
18+
19+
it "has a label correctly associated with the date range input" do
20+
render
21+
22+
# The label's 'for' attribute must match the input's 'id'
23+
expect(rendered).to have_css('label[for="orders_date_range"]')
24+
expect(rendered).to have_css('input[id="orders_date_range"]')
25+
end
26+
27+
it "has a label correctly associated with the status select" do
28+
render
29+
30+
expect(rendered).to have_css('label[for="q_state_eq"]')
31+
expect(rendered).to have_css('select[id="q_state_eq"]')
32+
end
33+
34+
it "has a label correctly associated with the shipping method select" do
35+
render
36+
37+
expect(rendered).to have_css('label[for="shipping_method_id"]')
38+
expect(rendered).to have_css('select[id="shipping_method_id"]')
39+
end
40+
41+
it "has a label correctly associated with the distributor select" do
42+
render
43+
44+
expect(rendered).to have_css('label[for="q_distributor_id_in"]')
45+
expect(rendered).to have_css('select[id="q_distributor_id_in"]')
46+
end
47+
48+
it "has a label correctly associated with the order cycle select" do
49+
render
50+
51+
expect(rendered).to have_css('label[for="q_order_cycle_id_in"]')
52+
expect(rendered).to have_css('select[id="q_order_cycle_id_in"]')
53+
end
54+
end

0 commit comments

Comments
 (0)