Skip to content

Commit a6f6da2

Browse files
committed
Add banner when file is deleted using delete link
Matches what we display when a file is removed using the delete link on the manage files pages.
1 parent e210ee4 commit a6f6da2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/main/views/template_email_files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask import abort, redirect, render_template, request, url_for
1+
from flask import abort, flash, redirect, render_template, request, url_for
22
from notifications_utils.field import PlainTextField
33
from notifications_utils.insensitive_dict import InsensitiveSet
44

@@ -96,6 +96,7 @@ def manage_a_template_email_file(service_id, template_id, template_email_file_id
9696
content=str(new_content).strip(),
9797
archive_email_file_ids=[template_email_file.id],
9898
)
99+
flash(f"‘{template_email_file.filename}’ has been removed", "default_with_tick")
99100
return redirect(url_for("main.view_template", service_id=current_service.id, template_id=template.id))
100101

101102
return render_template(

tests/app/main/views/test_template_email_files.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,22 @@ def test_post_delete_to_manage_a_template_email_file_updates_and_redirects(
224224
mock_update_service_template = mocker.patch(
225225
"app.notify_client.service_api_client.ServiceAPIClient.update_service_template"
226226
)
227-
client_request.post(
227+
page = client_request.post(
228228
"main.manage_a_template_email_file",
229229
service_id=service_one["id"],
230230
template_id=fake_uuid,
231231
template_email_file_id=test_data_for_a_template_email_file["id"],
232232
delete=True,
233-
_expected_redirect=url_for("main.view_template", service_id=service_one["id"], template_id=fake_uuid),
233+
_follow_redirects=True,
234234
)
235235
mock_update_service_template.assert_called_once_with(
236236
service_id=service_one["id"],
237237
template_id=fake_uuid,
238238
content="This template contains an email file",
239239
archive_email_file_ids=[test_data_for_a_template_email_file["id"]],
240240
)
241+
assert normalize_spaces(page.select_one("h1.folder-heading")) == "sample template"
242+
assert normalize_spaces(page.select_one(".banner-default-with-tick")) == "‘test_file_1.csv’ has been removed"
241243

242244

243245
def test_manage_a_template_email_file_raises_404_for_invalid_template_email_file_id(

0 commit comments

Comments
 (0)