diff --git a/changeLog.md b/changeLog.md index 90883d3c..06949af1 100644 --- a/changeLog.md +++ b/changeLog.md @@ -29,8 +29,9 @@ ## 10-10-2023 ### What's new - Added an acceptance test that tests navigation to a dataset page +- Added an acceptance test that tests loading the swagger editor with the correct openAPI json ### Why was this change made? -- because this user journey was documented as part of a recent group session we did +- because these user journeys were documented as part of a recent group session we did ## 09-10-2023 ### What's new diff --git a/tests/acceptance/test_documentation.py b/tests/acceptance/test_documentation.py index c7c6de89..05708b15 100644 --- a/tests/acceptance/test_documentation.py +++ b/tests/acceptance/test_documentation.py @@ -1,3 +1,6 @@ +import json + + def test_docs_page_loads_ok(server_process, BASE_URL, page): response = page.goto(BASE_URL + "/docs/") assert response.ok @@ -6,3 +9,31 @@ def test_docs_page_loads_ok(server_process, BASE_URL, page): name="Documentation", ) assert heading.is_visible() + + +def test_accessing_the_openAPI_file_and_the_swagger_editor( + server_process, BASE_URL, page +): + page.goto(BASE_URL) + page.get_by_role("link", name="Documentation", exact=True).click() + + with page.expect_navigation() as navigation_info: + page.get_by_role( + "link", name="https://www.planning.data.gov.uk/openapi.json" + ).click() + + assert navigation_info.value.ok + + try: + json.loads(navigation_info.value.body()) + except ValueError: + assert False, "The openapi.json file is not valid JSON." + + page.go_back() + + linkHref = page.get_by_role("link", name="Swagger Editor").get_attribute("href") + + assert "swagger" in linkHref, "Link didn't contain 'swagger'" + assert ( + "https://www.planning.data.gov.uk/openapi.json" in linkHref + ), "Link didn't contain 'https://www.planning.data.gov.uk/openapi.json'"