Skip to content

Commit 06edb5d

Browse files
committed
system test to verify removal of individual attached doc for partner profile
1 parent 6e5957f commit 06edb5d

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

spec/system/partners/profile_edit_system_spec.rb

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@
100100
end
101101

102102
it "preserves previously uploaded documents when adding new attachments" do
103-
# Upload the first document
103+
# Open attached documents section
104104
find("button[data-bs-target='#attached_documents']").click
105105
expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true)
106106

107+
# Upload the first document
107108
within "#attached_documents" do
108109
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true)
109110
end
@@ -137,7 +138,47 @@
137138
end
138139
end
139140

140-
it "persists file upload when there are validation errors" do
141+
it "allows removal of attached documents" do
142+
# Open attached documents section
143+
find("button[data-bs-target='#attached_documents']").click
144+
expect(page).to have_css("#attached_documents.accordion-collapse.collapse.show", visible: true)
145+
146+
# Upload two documents - needs to be done individually because Capybara doesn't have attach_files multiple support
147+
# https://github.com/teamcapybara/capybara/issues/37
148+
within "#attached_documents" do
149+
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document1.md"), make_visible: true)
150+
end
151+
all("input[type='submit'][value='Save Progress']").last.click
152+
visit edit_partners_profile_path
153+
find("button[data-bs-target='#attached_documents']").click
154+
within "#attached_documents" do
155+
attach_file("partner_profile_documents", Rails.root.join("spec/fixtures/files/document2.md"), make_visible: true)
156+
end
157+
all("input[type='submit'][value='Save Progress']").last.click
158+
159+
# Remove the first document
160+
visit edit_partners_profile_path
161+
find("button[data-bs-target='#attached_documents']").click
162+
within "#attached_documents" do
163+
document_name = "document1.md"
164+
document_li = find("li.attached-document", text: document_name)
165+
document_li.find("a.btn-danger", text: "Remove").click
166+
expect(page).not_to have_selector("li.attached-document", text: document_name)
167+
end
168+
169+
# Save Progress
170+
all("input[type='submit'][value='Save Progress']").last.click
171+
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")
172+
173+
# Verify only one document is listed
174+
visit edit_partners_profile_path
175+
find("button[data-bs-target='#attached_documents']").click
176+
within "#attached_documents" do
177+
expect(page).to have_link("document2.md")
178+
end
179+
end
180+
181+
it "persists individual file upload when there are validation errors" do
141182
# Open up Agency Information section and upload proof-of-status letter
142183
find("button[data-bs-target='#agency_information']").click
143184
within "#agency_information" do

0 commit comments

Comments
 (0)