Skip to content

Commit

Permalink
Add draft
Browse files Browse the repository at this point in the history
  • Loading branch information
depsiatwal committed Jan 31, 2025
1 parent aa9fe70 commit 0e5981c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 10 deletions.
1 change: 0 additions & 1 deletion exporter/applications/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def dispatch(self, request, *args, **kwargs):

def get(self, request, **kwargs):
status_props, _ = get_status_properties(request, self.application["status"]["key"])

context = {
"case_id": self.application_id,
"application": self.application,
Expand Down
19 changes: 14 additions & 5 deletions exporter/templates/applications/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ <h2 class="govuk-heading-m">Application History</h2>
<tbody class="govuk-table__body">
{% for prev_application in application_history.amendment_history %}
<tr class="govuk-table__row">
{% if prev_application.status.status == "draft" %}
<td class="govuk-table__cell">
<a href="{% url 'applications:task_list' prev_application.id %}" >{{ prev_application.status.status_display|capfirst }}</a>
</td>
<td class="govuk-table__cell"/>
<td class="govuk-table__cell" id="label-application-status-{{ forloop.counter }}"> <div class="govuk-tag govuk-tag--grey govuk-!-margin-0">{{ prev_application.status.status_display }}</div></td>
<td class="govuk-table__cell"/>
{% else %}
<td class="govuk-table__cell">
{% if prev_application.id == application.id %}
{{ prev_application.reference_code }}
{% else %}
{% else %}
<a href="{% url 'applications:application' prev_application.id %}">{{ prev_application.reference_code }}</a>
{% endif %}
</td>
<td class="govuk-table__cell">{{ prev_application.submitted_at|str_date }}</td>
<td class="govuk-table__cell"> <div class="govuk-tag govuk-tag--grey govuk-!-margin-0">{{ prev_application.status.status_display }}</div></td>
<td class="govuk-table__cell" id="label-application-status-{{ forloop.counter }}"> <div class="govuk-tag govuk-tag--grey govuk-!-margin-0">{{ prev_application.status.status_display }}</div></td>
<td class="govuk-table__cell">
{% if prev_application.ecju_query_count > 0 %}
<a href="{% url 'applications:application' prev_application.id 'ecju-queries' %}">{{ prev_application.ecju_query_count }}</a>
{% endif %}
{% if prev_application.ecju_query_count > 0 %}
<a href="{% url 'applications:application' prev_application.id 'ecju-queries' %}">{{ prev_application.ecju_query_count }}</a>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Feature: I want to submit SIEL applications and be able to make major amendments
And I click the "Archived" tab
And I click on the application previously submitted
Then the application cannot be opened for editing
And the application status is "Superseded by exporter edit"
And the application history status is "DRAFT" for row 1
And the application history status is "SUPERSEDED BY EXPORTER EDIT" for row 2
When I go to my list of applications
Then I see new application ready for amendments under drafts
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ def cannot_edit_application(driver, context):
assert edit_url not in [item.get_property("href") for item in all_links]


@then(parsers.parse('the application status is "{status}"'))
def confirm_editing_application(driver, status):
assert driver.find_element(by=By.ID, value="label-application-status").text == status
@then(parsers.parse('the application history status is "{status}" for row {row}'))
def confirm_editing_application(driver, status, row):
assert driver.find_element(by=By.ID, value=f"label-application-status-{row}").text == status


@then("I see new application ready for amendments under drafts")
Expand Down
45 changes: 45 additions & 0 deletions unit_tests/exporter/applications/views/test_application_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
from bs4 import BeautifulSoup
from django.urls import reverse

from core import client


@pytest.fixture
def mock_application_history_with_draft(requests_mock, application_history):
application_history["amendment_history"][0]["status"] = {"status": "draft", "status_display": "draft"}
application_history["amendment_history"][0]["submitted_at"] = None
application_history["amendment_history"][0]["reference_code"] = None
url = client._build_absolute_uri(f'/exporter/applications/{application_history["id"]}/history')
return requests_mock.get(url=url, json=application_history)


@pytest.mark.parametrize(
"can_invoke_major_editable",
Expand Down Expand Up @@ -131,3 +142,37 @@ def test_application_history_details(
assert hist_application_2[2].text.strip() == "Superseded by exporter edit"
assert hist_application_2[3].a["href"] == "/applications/caba228c-b4c8-41ea-804a-c1bc6ba816c7/ecju-queries/"
assert hist_application_2[3].a.text.strip() == "3"


def test_application_history_detail_with_draft(
authorized_client,
data_standard_case,
mock_application_get,
mock_application_history_with_draft,
mock_exporter_user,
beautiful_soup,
):
pk = data_standard_case["case"]["id"]
application_url = reverse("applications:application", kwargs={"pk": pk})
response = authorized_client.get(application_url)
soup = beautiful_soup(response.content)

application_history_table = soup.find("table", attrs={"id": "table-application-history"})
body = application_history_table.find("tbody")

hist_application_1 = body.find_all("tr")[0].find_all("td")
hist_application_2 = body.find_all("tr")[1].find_all("td")

assert hist_application_1[0].a.text == "Draft"
assert hist_application_1[0].a["href"] == "/applications/8fb76bed-fd45-4293-95b8-eda9468aa254/task-list/"
assert hist_application_1[1].text == ""
assert hist_application_1[2].text.strip() == "draft"
assert hist_application_1[3].text.strip() == ""

assert hist_application_2[0].a["href"] == "/applications/caba228c-b4c8-41ea-804a-c1bc6ba816c7/"
assert hist_application_2[0].a.text.strip() == "GBSIEL/2025/0000333/T"

assert hist_application_2[1].text.strip() == "4:36pm 27 January 2025"
assert hist_application_2[2].text.strip() == "Superseded by exporter edit"
assert hist_application_2[3].a["href"] == "/applications/caba228c-b4c8-41ea-804a-c1bc6ba816c7/ecju-queries/"
assert hist_application_2[3].a.text.strip() == "3"

0 comments on commit 0e5981c

Please sign in to comment.