Skip to content

Commit

Permalink
Add template link to delivery report (#2026)
Browse files Browse the repository at this point in the history
* switch to table, add template link to delivery report

* skip a letter test

* add missing translation, remove :

---------

Co-authored-by: Philippe Caron <[email protected]>
  • Loading branch information
smcmurtry and amazingphilippe authored Jan 8, 2025
1 parent b4096b8 commit 4819c2a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 42 deletions.
80 changes: 49 additions & 31 deletions app/templates/partials/jobs/status.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
{% from "components/table.html" import mapping_table, row, row_heading, text_field, link_field, with context %}

<div class="ajax-block-container">
<p class='mb-12 clear-both contain-floats'>

<div data-test-id="dr_header">
<div class="pb-4">
{{ _('Sent by:') }}
{% if job.api_key %}
{{ _("API key '<a href='{}'>{}</a>'").format(url_for('.api_keys', service_id=current_service.id), job.api_key.name) }}
{% else %}
{{ job.created_by.name }}
{% endif %}
</div>
<div class="pb-4">
{{ _('Started:') }}
<time class="local-datetime-short">{{ job.created_at }}</time>
</div>
<div class="pb-4">
{% if job.api_key %}
{{ _('API request name:')}}
{% else %}
{{ _('Spreadsheet:') }}
{% endif %}
{{ job.original_file_name }}
</div>
</div>


{% if template_type == "letter" %}
<p id="printing-info">
{{ letter_print_day }}
</p>
<div class="flex flex-wrap mb-8">
{% set caption = _("Scheduled messages") %}

{% call mapping_table(
caption=caption,
field_headings_visible=False,
caption_visible=False,
font_size='table-font-small',
) %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Sent by') }}
{% endcall %}
{% if job.api_key %}
{{ text_field(_("API key '<a href='{}'>{}</a>'").format(url_for('.api_keys', service_id=current_service.id), job.api_key.name)) }}
{% else %}
{{ text_field(job.created_by.name) }}
{% endif %}
</p>
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Started') }}
{% endcall %}
{{ text_field(text=job.created_at, date_format="local-datetime-short") }}
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{% if job.api_key %}
{{ _('API request name')}}
{% else %}
{{ _('Spreadsheet') }}
{% endif %}
{% endcall %}
{{ text_field(job.original_file_name) }}
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Template') }}
{% endcall %}
{{ link_field(template.name, url_for('.view_template', service_id=job.service, template_id=template.id)) }}
{% endcall %}
{% endcall %}

</div>
</div>
1 change: 1 addition & 0 deletions app/translations/csv/fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@
"Try creating {} in a different application","Essayez de créer {} dans une application différente."
"Sent by:","Envoyé par&nbsp;:"
"Started:","Début&nbsp;:"
"Started","Début"
"Spreadsheet:","Feuille de calcul&nbsp;:"
"API request name:","Nom de la requête API&nbsp;:"
"GC Notify disposed of the information in this report on <time class='local-datetime-short'>{}</time>","Notification GC a supprimé les renseignements de ce rapport le <time class='local-datetime-short'>{}</time>"
Expand Down
24 changes: 13 additions & 11 deletions tests/app/main/views/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ def test_should_show_page_for_one_job(
)

assert page.h1.text.strip() == "Delivery report"
assert " ".join(page.find("tbody").find("tr").text.split()) == ("6502532222 template content No Delivered 11:10:00.061258")
dashboard_table = page.find_all("table")[1]
assert " ".join(dashboard_table.find("tbody").find("tr").text.split()) == (
"6502532222 template content No Delivered 11:10:00.061258"
)
assert page.find("div", {"data-key": "notifications"})["data-resource"] == url_for(
"main.view_job_updates",
service_id=SERVICE_ONE_ID,
Expand All @@ -204,10 +207,10 @@ def test_should_show_page_for_one_job(
assert csv_link.text == "Download this report"
assert page.find("time", {"id": "time-left"}).text.split(" ")[0] == "2016-01-09"

assert normalize_spaces(page.select_one("tbody tr").text) == normalize_spaces(
assert normalize_spaces(dashboard_table.select_one("tbody tr").text) == normalize_spaces(
"6502532222 " "template content " "No " "Delivered 11:10:00.061258"
)
assert page.select_one("tbody tr a")["href"] == url_for(
assert dashboard_table.select_one("tbody tr a")["href"] == url_for(
"main.view_notification",
service_id=SERVICE_ONE_ID,
notification_id=sample_uuid(),
Expand Down Expand Up @@ -434,15 +437,13 @@ def test_should_show_job_from_api(
service_id=SERVICE_ONE_ID,
job_id=fake_uuid,
)
job_info_table = page.find_all("table")[0]

assert (
normalize_spaces(page.select("div[data-test-id='dr_header'] >div:nth-child(1)")[0].text)
== f"Sent by: API key '{JOB_API_KEY_NAME}'"
)
assert (
normalize_spaces(page.select("div[data-test-id='dr_header'] >div:nth-child(2)")[0].text)
== "Started: 2016-01-01T00:00:00.061258+0000"
)
assert normalize_spaces(job_info_table.select("th")[0].text) == "Sent by"
assert normalize_spaces(job_info_table.select("td")[0].text) == f"API key '{JOB_API_KEY_NAME}'"

assert normalize_spaces(job_info_table.select("th")[1].text) == "Started"
assert normalize_spaces(job_info_table.select("td")[1].text) == "2016-01-01T00:00:00.061258+0000"


# TODO: This test could be migrated to Cypress instead
Expand Down Expand Up @@ -579,6 +580,7 @@ def test_should_not_show_cancel_link_for_letter_job_if_too_late(


@freeze_time("2019-06-20 15:32:00.000001")
@pytest.mark.skip(reason="feature not in use")
@pytest.mark.parametrize(" job_status", ["finished", "in progress"])
def test_should_show_cancel_link_for_letter_job(
client_request,
Expand Down

0 comments on commit 4819c2a

Please sign in to comment.