Skip to content

Commit aeebda3

Browse files
feat: add New Case Contact button to new design case contacts page
Adds a primary-styled button to the header of the new design case contacts table that links to the existing new case contact flow. Accessible (aria-hidden on decorative icon) and responsive (flex-wrap on narrow viewports). Covers admin and volunteer roles in system specs. Spec structure aligned with shared_context pattern from b4758d1 to minimize future merge conflicts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 851785c commit aeebda3

2 files changed

Lines changed: 64 additions & 21 deletions

File tree

app/views/case_contacts/case_contacts_new_design/index.html.erb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<div class="title-wrapper pt-30">
2-
<div class="row align-items-center">
3-
<div class="title mb-30">
4-
<h1>Case Contacts</h1>
5-
</div>
2+
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-30">
3+
<h1>Case Contacts</h1>
4+
<%= link_to new_case_contact_path, class: "main-btn primary-btn btn-sm btn-hover" do %>
5+
<i class="lni lni-plus mr-10" aria-hidden="true"></i>
6+
New Case Contact
7+
<% end %>
68
</div>
79
</div>
810

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "rails_helper"
22

3-
RSpec.describe "Case Contact Table Row Expansion", type: :system, js: true do
3+
RSpec.describe "Case contacts new design", type: :system, js: true do
44
let(:organization) { create(:casa_org) }
55
let(:admin) { create(:casa_admin, casa_org: organization) }
66
let(:casa_case) { create(:casa_case, casa_org: organization) }
@@ -14,30 +14,71 @@
1414
case_contact: case_contact,
1515
contact_topic: contact_topic,
1616
value: "Youth is doing well in school")
17+
allow(Flipper).to receive(:enabled?).and_call_original
1718
allow(Flipper).to receive(:enabled?).with(:new_case_contact_table).and_return(true)
18-
sign_in admin
19-
visit case_contacts_new_design_path
2019
end
2120

22-
it "shows the expanded content after clicking the chevron" do
23-
find(".expand-toggle").click
24-
25-
expect(page).to have_content("What was discussed?")
26-
expect(page).to have_content("Youth is doing well in school")
21+
shared_context "signed in as admin" do
22+
before do
23+
sign_in admin
24+
visit case_contacts_new_design_path
25+
end
2726
end
2827

29-
it "shows notes in the expanded content" do
30-
find(".expand-toggle").click
28+
describe "New Case Contact button" do
29+
include_context "signed in as admin"
30+
31+
it "is visible to an admin" do
32+
expect(page).to have_link("New Case Contact", href: new_case_contact_path)
33+
end
34+
35+
it "navigates to the new case contact form when clicked as an admin" do
36+
click_link "New Case Contact"
37+
expect(page).to have_current_path(%r{/case_contacts/\d+/form/details})
38+
end
39+
40+
context "when signed in as a volunteer" do
41+
let(:volunteer) { create(:volunteer, casa_org: organization) }
42+
43+
before do
44+
sign_in volunteer
45+
visit case_contacts_new_design_path
46+
end
47+
48+
it "is visible to a volunteer" do
49+
expect(page).to have_link("New Case Contact", href: new_case_contact_path)
50+
end
3151

32-
expect(page).to have_content("Additional Notes")
33-
expect(page).to have_content("Important follow-up needed")
52+
it "navigates to the new case contact form when clicked as a volunteer" do
53+
click_link "New Case Contact"
54+
expect(page).to have_current_path(%r{/case_contacts/\d+/form/details})
55+
end
56+
end
3457
end
3558

36-
it "hides the expanded content after clicking the chevron again" do
37-
find(".expand-toggle").click
38-
expect(page).to have_content("Youth is doing well in school")
59+
describe "row expansion" do
60+
include_context "signed in as admin"
61+
62+
it "shows the expanded content after clicking the chevron" do
63+
find(".expand-toggle").click
64+
65+
expect(page).to have_content("What was discussed?")
66+
expect(page).to have_content("Youth is doing well in school")
67+
end
68+
69+
it "shows notes in the expanded content" do
70+
find(".expand-toggle").click
71+
72+
expect(page).to have_content("Additional Notes")
73+
expect(page).to have_content("Important follow-up needed")
74+
end
75+
76+
it "hides the expanded content after clicking the chevron again" do
77+
find(".expand-toggle").click
78+
expect(page).to have_content("Youth is doing well in school")
3979

40-
find(".expand-toggle").click
41-
expect(page).to have_no_content("Youth is doing well in school")
80+
find(".expand-toggle").click
81+
expect(page).to have_no_content("Youth is doing well in school")
82+
end
4283
end
4384
end

0 commit comments

Comments
 (0)