diff --git a/home/service/details.py b/home/service/details.py index 611c1289..87486c6e 100644 --- a/home/service/details.py +++ b/home/service/details.py @@ -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, } @@ -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 } @@ -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, } diff --git a/templates/details_chart.html b/templates/details_chart.html index 295e8ec7..49a294a8 100644 --- a/templates/details_chart.html +++ b/templates/details_chart.html @@ -18,12 +18,13 @@ {% endblock breadcrumbs %} {% block content %} -
-

{{h1_value}}

- Chart -

{{chart.name}}

+

{{h1_value}} + + Chart + +

diff --git a/templates/details_database.html b/templates/details_database.html index f4ddccad..b315ab05 100644 --- a/templates/details_database.html +++ b/templates/details_database.html @@ -20,9 +20,11 @@ {% block content %}
-

{{h1_value}}

- Database -

{{database.name}}

+

{{h1_value}} + + Database + +

diff --git a/templates/details_table.html b/templates/details_table.html index caa0bb31..ee176400 100644 --- a/templates/details_table.html +++ b/templates/details_table.html @@ -25,9 +25,11 @@ {% block content %}
-

{{h1_value}}

- Table -

{{table.name}}

+

{{h1_value}} + + Table + +

diff --git a/tests/benchmark/test_exact_matches.py b/tests/benchmark/test_exact_matches.py index 55a1e00f..0d7cfdf0 100644 --- a/tests/benchmark/test_exact_matches.py +++ b/tests/benchmark/test_exact_matches.py @@ -15,8 +15,8 @@ "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", @@ -24,7 +24,7 @@ ), ( "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 ), ], ) diff --git a/tests/conftest.py b/tests/conftest.py index 70594ecd..58de8437 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,6 +8,7 @@ from data_platform_catalogue.client.datahub_client import DataHubCatalogueClient from data_platform_catalogue.entities import ( AccessInformation, + Chart, Column, ColumnRef, CustomEntityProperties, @@ -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(), @@ -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) @@ -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() diff --git a/tests/home/service/test_details.py b/tests/home/service/test_details.py index f02ee58e..95a36fa0 100644 --- a/tests/home/service/test_details.py +++ b/tests/home/service/test_details.py @@ -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 diff --git a/tests/selenium/conftest.py b/tests/selenium/conftest.py index 0202429f..5401cf44 100644 --- a/tests/selenium/conftest.py +++ b/tests/selenium/conftest.py @@ -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") @@ -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 @@ -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] diff --git a/tests/selenium/test_interact_with_search_results.py b/tests/selenium/test_interact_with_search_results.py index 9ca2d270..c72c773c 100644 --- a/tests/selenium/test_interact_with_search_results.py +++ b/tests/selenium/test_interact_with_search_results.py @@ -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() @@ -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" ]