Skip to content

Commit

Permalink
Update details page header and title (#511)
Browse files Browse the repository at this point in the history
* update h1_values

* update tests

* add chart tag

* add table tag

* add database tag

* replace query for missing bold data

* remove secondary heading method

* remove caption method

* update the database details page tests

* update the table details page tests
  • Loading branch information
mitchdawson1982 authored Jul 2, 2024
1 parent 11d4498 commit f0f55e7
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 34 deletions.
6 changes: 3 additions & 3 deletions home/service/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_context(self):
"database": self.database_metadata,
"result_type": "Database",
"tables": self.entities_in_database,
"h1_value": "Details",
"h1_value": self.database_metadata.name,
"is_esda": self.is_esda,
}

Expand Down Expand Up @@ -91,7 +91,7 @@ def _get_context(self):
"table": self.table_metadata,
"parent_entity": self.parent_entity,
"dataset_parent_type": self.dataset_parent_type,
"h1_value": "Details",
"h1_value": self.table_metadata.name,
"has_lineage": self.has_lineage(),
"lineage_url": f"{split_datahub_url.scheme}://{split_datahub_url.netloc}/dataset/{self.table_metadata.urn}/Lineage?is_lineage_mode=true&", # noqa: E501
}
Expand Down Expand Up @@ -119,5 +119,5 @@ def __init__(self, urn: str):
def _get_context(self):
return {
"chart": self.chart_metadata,
"h1_value": "Details",
"h1_value": self.chart_metadata.name,
}
9 changes: 5 additions & 4 deletions templates/details_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
{% endblock breadcrumbs %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">{{h1_value}}</h1>
<span class="govuk-caption-m">Chart</span>
<h2 class="govuk-heading-m">{{chart.name}}</h2>
<h1 class="govuk-heading-l">{{h1_value}}
<strong class="govuk-tag govuk-!-margin-left-2">
Chart
</strong>
</h1>
</div>
</div>
<div class="govuk-grid-row">
Expand Down
8 changes: 5 additions & 3 deletions templates/details_database.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">{{h1_value}}</h1>
<span class="govuk-caption-m">Database</span>
<h2 class="govuk-heading-m">{{database.name}}</h2>
<h1 class="govuk-heading-l">{{h1_value}}
<strong class="govuk-tag govuk-!-margin-left-2">
Database
</strong>
</h1>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
Expand Down
8 changes: 5 additions & 3 deletions templates/details_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h1 class="govuk-heading-l">{{h1_value}}</h1>
<span class="govuk-caption-m">Table</span>
<h2 class="govuk-heading-m">{{table.name}}</h2>
<h1 class="govuk-heading-l">{{h1_value}}
<strong class="govuk-tag govuk-!-margin-left-2">
Table
</strong>
</h1>
</div>
</div>
<div class="govuk-grid-row">
Expand Down
6 changes: 3 additions & 3 deletions tests/benchmark/test_exact_matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"query,expected_urn",
[
(
"bold_common_platform_linked_tables.all_offence",
"urn:li:dataset:(urn:li:dataPlatform:dbt,cadet.awsdatacatalog.bold_common_platform_linked_tables.all_offence,PROD)",
"dummy_pnc_ids_to_send",
"urn:li:dataset:(urn:li:dataPlatform:dbt,cadet.awsdatacatalog.bold_rr_pnc_ids.dummy_pnc_ids_to_send,PROD)", # noqa E501
),
(
"Accommodation on the first night following release",
"urn:li:chart:(justice-data,accommodation-on-release)",
),
(
"ns_postcode_lookup_latest_2011census",
"urn:li:dataset:(urn:li:dataPlatform:dbt,cadet.awsdatacatalog.common_lookup.ns_postcode_lookup_latest_2011census,PROD)",
"urn:li:dataset:(urn:li:dataPlatform:dbt,cadet.awsdatacatalog.common_lookup.ns_postcode_lookup_latest_2011census,PROD)", # noqa E501
),
],
)
Expand Down
47 changes: 47 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from data_platform_catalogue.client.datahub_client import DataHubCatalogueClient
from data_platform_catalogue.entities import (
AccessInformation,
Chart,
Column,
ColumnRef,
CustomEntityProperties,
Expand Down Expand Up @@ -161,6 +162,47 @@ def generate_table_metadata(
)


def generate_chart_metadata(
name: str = fake.unique.name(),
description: str = fake.unique.paragraph(),
relations=None,
custom_properties=None,
) -> Chart:
"""
Generate a fake database metadata object
"""
return Chart(
urn="urn:li:container:fake",
external_url="https://data.justice.gov.uk/prisons/public-protection/absconds",
display_name=f"Foo.{name}",
name=name,
fully_qualified_name=f"Foo.{name}",
description=description,
relationships=relations or {RelationshipType.PARENT: []},
domain=DomainRef(display_name="LAA", urn="LAA"),
governance=Governance(
data_owner=OwnerRef(
display_name="", email="Contact email for the user", urn=""
),
data_stewards=[
OwnerRef(display_name="", email="Contact email for the user", urn="")
],
),
tags=[TagRef(display_name="some-tag", urn="urn:li:tag:Entity")],
glossary_terms=[
GlossaryTermRef(
display_name="some-term",
urn="urn:li:glossaryTerm:Entity",
description="some description",
)
],
last_modified=datetime(2024, 3, 5, 6, 16, 47, 814000, tzinfo=timezone.utc),
created=None,
platform=EntityRef(urn="urn:li:dataPlatform:athena", display_name="athena"),
custom_properties=custom_properties or CustomEntityProperties(),
)


def generate_database_metadata(
name: str = fake.unique.name(),
description: str = fake.unique.paragraph(),
Expand Down Expand Up @@ -268,6 +310,7 @@ def mock_catalogue(request, example_database):
],
)
mock_get_glossary_terms_response(mock_catalogue)
mock_get_chart_details_response(mock_catalogue)
mock_get_table_details_response(mock_catalogue)
mock_get_database_details_response(mock_catalogue, example_database)
mock_get_tags_response(mock_catalogue)
Expand All @@ -284,6 +327,10 @@ def mock_list_database_tables_response(mock_catalogue, total_results, page_resul
mock_catalogue.list_database_tables.return_value = search_response


def mock_get_chart_details_response(mock_catalogue):
mock_catalogue.get_chart_details.return_value = generate_chart_metadata()


def mock_get_table_details_response(mock_catalogue):
mock_catalogue.get_table_details.return_value = generate_table_metadata()

Expand Down
2 changes: 1 addition & 1 deletion tests/home/service/test_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ def test_get_context(self, mock_catalogue):
mock_catalogue.get_chart_details.return_value = chart_metadata

context = ChartDetailsService("urn").context
expected = {"chart": chart_metadata, "h1_value": "Details"}
expected = {"chart": chart_metadata, "h1_value": "test"}

assert context == expected
8 changes: 1 addition & 7 deletions tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ class DatabaseDetailsPage(Page):
def primary_heading(self):
return self.selenium.find_element(By.TAG_NAME, "h1")

def secondary_heading(self):
return self.selenium.find_element(By.TAG_NAME, "h2")

def database_details(self):
return self.selenium.find_element(By.ID, "metadata-property-list")

Expand All @@ -89,9 +86,6 @@ def table_link(self):


class TableDetailsPage(Page):
def caption(self):
return self.selenium.find_element(By.CSS_SELECTOR, ".govuk-caption-m").text

def column_descriptions(self):
return [
c.text
Expand Down Expand Up @@ -271,5 +265,5 @@ def glossary_page(selenium) -> GlossaryPage:

@pytest.fixture
def page_titles():
pages = ["Home", "Search", "Details", "Glossary"]
pages = ["Home", "Search", "Glossary"]
return [f"{page} - Find MOJ data - GOV.UK" for page in pages]
17 changes: 7 additions & 10 deletions tests/selenium/test_interact_with_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,11 @@ def click_on_the_first_result(self):
return item_name

def verify_i_am_on_the_database_details_page(self, item_name):
assert self.selenium.title in self.page_titles

heading_text = self.details_database_page.primary_heading().text
heading_text = self.details_database_page.primary_heading().text.replace(
" Database", ""
)
assert heading_text == self.selenium.title.split("-")[0].strip()

subheading_text = self.details_database_page.secondary_heading().text
assert subheading_text and item_name.endswith(subheading_text)
assert item_name.endswith(heading_text)

def enter_a_query_and_submit(self, query):
search_bar = self.search_page.search_bar()
Expand All @@ -115,12 +113,11 @@ def click_on_table(self):
self.details_database_page.table_link().click()

def verify_i_am_on_the_table_details_page(self):
assert self.selenium.title in self.page_titles

heading_text = self.details_database_page.primary_heading().text
heading_text = self.details_database_page.primary_heading().text.replace(
" Table", ""
)
assert heading_text == self.selenium.title.split("-")[0].strip()

assert self.table_details_page.caption() == "Table"
assert self.table_details_page.column_descriptions() == [
"description with markdown"
]

0 comments on commit f0f55e7

Please sign in to comment.