diff --git a/app/views/partners/profiles/step/_attached_documents_form.html.erb b/app/views/partners/profiles/step/_attached_documents_form.html.erb index 9164809733..8b4bd51eb6 100644 --- a/app/views/partners/profiles/step/_attached_documents_form.html.erb +++ b/app/views/partners/profiles/step/_attached_documents_form.html.erb @@ -4,7 +4,10 @@ Attached files: <%= pf.file_field :documents, multiple: true, class: "form-control-file" %> diff --git a/spec/fixtures/files/document1.md b/spec/fixtures/files/document1.md new file mode 100644 index 0000000000..7cb561ebc3 --- /dev/null +++ b/spec/fixtures/files/document1.md @@ -0,0 +1,13 @@ +# Food Pantry Program Overview + +Our food pantry serves families in need within the community. + +## Services Provided + +- Weekly food distribution +- Emergency food assistance + +## Contact Information + +Email: info@foodpantry.org +Phone: (555) 123-4567 diff --git a/spec/fixtures/files/document2.md b/spec/fixtures/files/document2.md new file mode 100644 index 0000000000..4c6326771c --- /dev/null +++ b/spec/fixtures/files/document2.md @@ -0,0 +1,9 @@ +# Delivery Guidelines + +Please follow these guidelines when delivering goods: + +1. Ensure all packages are labeled. +2. Deliveries must be completed by 5 PM. +3. Contact us immediately if there are delays. + +Thank you for your cooperation! diff --git a/spec/system/partners/profile_edit_system_spec.rb b/spec/system/partners/profile_edit_system_spec.rb index 8ef50faaa8..2f575490b4 100644 --- a/spec/system/partners/profile_edit_system_spec.rb +++ b/spec/system/partners/profile_edit_system_spec.rb @@ -99,6 +99,44 @@ expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true) end + it "preserves previously uploaded documents when adding new attachments" do + # Upload the first document + find("button[data-bs-target='#attached_documents']").click + expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true) + + within "#attached_documents" do + attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true) + end + + # Save Progress + all("input[type='submit'][value='Save Progress']").last.click + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") + + # Verify the document is listed + visit edit_partners_profile_path + find("button[data-bs-target='#attached_documents']").click + within "#attached_documents" do + expect(page).to have_link("document1.md") + end + + # Upload a second document + within "#attached_documents" do + attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document2.md"), make_visible: true) + end + + # Save Progress + all("input[type='submit'][value='Save Progress']").last.click + expect(page).to have_css(".alert-success", text: "Details were successfully updated.") + + # Verify both documents are listed + visit edit_partners_profile_path + find("button[data-bs-target='#attached_documents']").click + within "#attached_documents" do + expect(page).to have_link("document1.md") + expect(page).to have_link("document2.md") + end + end + it "persists file upload when there are validation errors" do # Open up Agency Information section and upload proof-of-status letter find("button[data-bs-target='#agency_information']").click