Skip to content

Commit

Permalink
Merge pull request #208 from digital-land/test/accessingTheOpenApi
Browse files Browse the repository at this point in the history
Test/accessing swagger and the openapi.json
  • Loading branch information
GeorgeGoodall authored Oct 12, 2023
2 parents 208e6d3 + 28c578d commit ba17910
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion changeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions tests/acceptance/test_documentation.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'"

0 comments on commit ba17910

Please sign in to comment.