|
1 | 1 | require "rails_helper" |
2 | 2 |
|
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 |
4 | 4 | let(:organization) { create(:casa_org) } |
5 | 5 | let(:admin) { create(:casa_admin, casa_org: organization) } |
6 | 6 | let(:casa_case) { create(:casa_case, casa_org: organization) } |
|
14 | 14 | case_contact: case_contact, |
15 | 15 | contact_topic: contact_topic, |
16 | 16 | value: "Youth is doing well in school") |
| 17 | + allow(Flipper).to receive(:enabled?).and_call_original |
17 | 18 | allow(Flipper).to receive(:enabled?).with(:new_case_contact_table).and_return(true) |
18 | | - sign_in admin |
19 | | - visit case_contacts_new_design_path |
20 | 19 | end |
21 | 20 |
|
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 |
27 | 26 | end |
28 | 27 |
|
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 |
31 | 51 |
|
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 |
34 | 57 | end |
35 | 58 |
|
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") |
39 | 79 |
|
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 |
42 | 83 | end |
43 | 84 | end |
0 commit comments