|
99 | 99 | expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
|
100 | 100 | end
|
101 | 101 |
|
| 102 | + it "preserves previously uploaded documents when adding new attachments" do |
| 103 | + # Upload the first document |
| 104 | + find("button[data-bs-target='#attached_documents']").click |
| 105 | + expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true) |
| 106 | + |
| 107 | + within "#attached_documents" do |
| 108 | + attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true) |
| 109 | + end |
| 110 | + |
| 111 | + # Save Progress |
| 112 | + all("input[type='submit'][value='Save Progress']").last.click |
| 113 | + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") |
| 114 | + |
| 115 | + # Verify the document is listed |
| 116 | + visit edit_partners_profile_path |
| 117 | + find("button[data-bs-target='#attached_documents']").click |
| 118 | + within "#attached_documents" do |
| 119 | + expect(page).to have_link("document1.md") |
| 120 | + end |
| 121 | + |
| 122 | + # Upload a second document |
| 123 | + within "#attached_documents" do |
| 124 | + attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document2.md"), make_visible: true) |
| 125 | + end |
| 126 | + |
| 127 | + # Save Progress |
| 128 | + all("input[type='submit'][value='Save Progress']").last.click |
| 129 | + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") |
| 130 | + |
| 131 | + # Verify both documents are listed |
| 132 | + visit edit_partners_profile_path |
| 133 | + find("button[data-bs-target='#attached_documents']").click |
| 134 | + within "#attached_documents" do |
| 135 | + expect(page).to have_link("document1.md") |
| 136 | + expect(page).to have_link("document2.md") |
| 137 | + end |
| 138 | + end |
| 139 | + |
102 | 140 | it "persists file upload when there are validation errors" do
|
103 | 141 | # Open up Agency Information section and upload proof-of-status letter
|
104 | 142 | find("button[data-bs-target='#agency_information']").click
|
|
0 commit comments