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

EES-5496 Fix inconsistent anchor IDs causing broken nav links in API data set mapping pages #5481

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

ntsim
Copy link
Collaborator

@ntsim ntsim commented Dec 20, 2024

This PR fixes inconsistent anchor IDs being used across the the public API filters and locations mapping pages. Previously, we were using hard-coded ID strings meaning that it was easy to forget to update them in all places. This would then lead to broken navigation links due to stale IDs being used.

We've not refactored both the filters and locations mappings pages to use common variables and functions to generate the necessary anchor IDs. This should hopefully keep things consistent and less bug-prone moving forward.

@ntsim ntsim changed the title EES-5496 EES-5496 Fix inconsistent anchor IDs causing broken nav links in API data set mapping pages Dec 20, 2024
import compact from 'lodash/compact';

export const sectionIds = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a neat way of keeping the nav and the links consistent. Do we do this pattern elsewhere at all?

>
New filter options ({totalNewFilterOptions}){' '}
<Tag colour="grey">No action required</Tag>
</h3>

{totalNewFilterOptions > 0 && filtersMapping ? (
<Accordion
id="new-filter-options-accordion"
testId="new-filter-options-accordion"
id={`${sectionIds.newFilterOptions}-accordion`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth having a sectionIds.newFilterOptionsAccordion variable just to avoid the risk of this too getting out of sync?

>
Auto mapped filter options ({totalAutoMappedFilterOptions}){' '}
<Tag colour="grey">No action required</Tag>
</h3>

{totalAutoMappedFilterOptions > 0 ? (
<Accordion
id="auto-mapped-filter-options-accordion"
id={`${sectionIds.autoMappedFilterOptions}-accordion`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned before, worth a variable for this? Same comments for other such changes in this PR :)

className="dfe-table--vertical-align-middl"
data-testid={`auto-mapped-table-${groupKey}`}
className="dfe-table--vertical-align-middle"
data-testid={tableId}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth giving the table's id attribute this value as well as the data-testid, like the table in ApiDataSetMappableTable.tsx? Or is it purely that the other table needs to have an id for anchor links to target it?

@@ -163,7 +163,7 @@ Validate the version task statuses inside the 'Draft version task' section
User clicks on Map locations link
user clicks link Map locations
user waits until h3 is visible Locations not found in new data set
user waits until element contains xpath://table[@data-testid='mappable-table-region']/caption//strong[1]
user waits until element contains css:[data-testid="mappable-table-region"] caption
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was looking to find Robot changes :) Nice one - looks like a good simplification too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants