Skip to content

Commit

Permalink
Merge pull request #901 from alphagov/1893-fix-test
Browse files Browse the repository at this point in the history
1893: Check content of Report an issue page
  • Loading branch information
ahernp authored Feb 13, 2025
2 parents f451401 + 9c9b8dc commit 1ef5368
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ def test_case_sitemap(rf):
def test_page_name(url, expected_page_name, admin_client):
"""
Test that the page renders and its name is as expected.
Also that an issue on that page can be reported.
"""
case: Case = Case.objects.create()
audit: Audit = Audit.objects.create(case=case)
Expand All @@ -878,16 +877,6 @@ def test_page_name(url, expected_page_name, admin_client):

assertContains(response, expected_page_name)

issue_report_response: HttpResponse = admin_client.get(
f"/common/report-issue/?page_url={url}"
)

assert issue_report_response.status_code == 200

assertContains(response, "Report an issue")
assertContains(response, url)
assertContains(response, expected_page_name)


def test_populate_subpage_instances():
"""Test populate_subpage_instances"""
Expand Down
27 changes: 27 additions & 0 deletions accessibility_monitoring_platform/apps/common/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,3 +1271,30 @@ def test_navbar_tasks_emboldened(admin_client, admin_user):
</li>""",
html=True,
)


@pytest.mark.parametrize(
"url, expected_page_name",
[
("/", "Your cases"),
("/cases/1/edit-case-metadata/", "Case metadata"),
("/audits/1/edit-audit-metadata/", "Initial test metadata"),
],
)
def test_page_name(url, expected_page_name, admin_client):
"""
Test that the page renders and problem page's url and name are populated
as expected.
"""
case: Case = Case.objects.create()
Audit.objects.create(case=case)

response: HttpResponse = admin_client.get(
f"/common/report-issue/?page_url={url}&page_title={expected_page_name}"
)

assert response.status_code == 200

assertContains(response, "Report an issue")
assertContains(response, url)
assertContains(response, expected_page_name)

0 comments on commit 1ef5368

Please sign in to comment.