Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update details page header and title #511

Merged
merged 13 commits into from
Jul 2, 2024
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_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
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
2 changes: 1 addition & 1 deletion tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,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]
4 changes: 0 additions & 4 deletions tests/selenium/test_interact_with_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ 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
assert heading_text == self.selenium.title.split("-")[0].strip()

Expand Down Expand Up @@ -115,8 +113,6 @@ 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
assert heading_text == self.selenium.title.split("-")[0].strip()

Expand Down
Loading