Skip to content

Commit 4f4882d

Browse files
committed
Make it so the search help link is translatable
1 parent 2b26780 commit 4f4882d

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

packages/datagateway-search/cypress/e2e/searchBoxContainer.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('SearchBoxContainer Component', () => {
1818
cy.get('#search-entities-menu').should('exist');
1919

2020
cy.get('[aria-label="Submit search"]').should('exist');
21-
cy.get('[aria-label="Search options"]').should('exist');
21+
cy.findByRole('button', { name: 'search options' }).should('exist');
2222

2323
cy.get('#search-entities-menu').click();
2424
cy.get('[aria-label="Investigation checkbox"]').should('exist');
@@ -79,7 +79,7 @@ describe('SearchBoxContainer Component', () => {
7979
});
8080

8181
it('should display advanced help dialogue when advanced button is clicked', () => {
82-
cy.get('[aria-label="Search options"]').click();
82+
cy.findByRole('button', { name: 'search options' }).click();
8383

8484
cy.get('[aria-labelledby="advanced-search-dialog-title"')
8585
.contains('Advanced Search Tips')
@@ -92,7 +92,7 @@ describe('SearchBoxContainer Component', () => {
9292
);
9393

9494
//Should be able to click on one of the links
95-
cy.get('[aria-label="Search options"]').click();
95+
cy.findByRole('button', { name: 'search options' }).click();
9696

9797
cy.get('[aria-labelledby="advanced-search-dialog-title"').contains(
9898
'Advanced Search Tips'

packages/datagateway-search/public/res/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
"show_less": "Show less"
300300
},
301301
"advanced_search_help": {
302-
"search_options_arialabel": "Search options",
302+
"search_help_label": "See all <2>search options</2>.",
303303
"close_button_arialabel": "Close",
304304
"title": "Advanced Search Tips",
305305
"description": "Searching the metadata catalogue using one or more words should be intuitive, with the most relevant matches appearing first. However, there is a powerful syntax that supports more advanced use cases, which are described below.",

packages/datagateway-search/src/search/advancedHelpDialogue.component.test.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ describe('Advanced help dialogue', () => {
6969

7070
renderComponent({ initialState: state });
7171

72-
await user.click(
73-
screen.getByRole('button', {
74-
name: 'advanced_search_help.search_options_arialabel',
75-
})
76-
);
72+
await user.click(screen.getByTestId('advanced-search-help-link'));
7773

7874
expect(
7975
screen.getByRole('dialog', { name: 'advanced_search_help.title' })
@@ -108,11 +104,7 @@ describe('Advanced help dialogue', () => {
108104

109105
renderComponent({ initialState: state });
110106

111-
await user.click(
112-
screen.getByRole('button', {
113-
name: 'advanced_search_help.search_options_arialabel',
114-
})
115-
);
107+
await user.click(screen.getByTestId('advanced-search-help-link'));
116108

117109
expect(
118110
screen.getByRole('dialog', { name: 'advanced_search_help.title' })

packages/datagateway-search/src/search/advancedHelpDialogue.component.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,22 @@ const AdvancedHelpDialogue = (): React.ReactElement => {
5858

5959
return (
6060
<React.Fragment>
61-
See all{' '}
62-
<Link
63-
component="button"
64-
sx={{
65-
fontSize: '14px',
66-
fontWeight: 'bold',
67-
verticalAlign: 'baseline',
68-
}}
69-
aria-label={t('advanced_search_help.search_options_arialabel')}
70-
onClick={handleClickOpen}
71-
>
72-
search options
73-
</Link>
74-
.
61+
<Trans t={t} i18nKey="advanced_search_help.search_help_label">
62+
See all{' '}
63+
<Link
64+
component="button"
65+
sx={{
66+
fontSize: '14px',
67+
fontWeight: 'bold',
68+
verticalAlign: 'baseline',
69+
}}
70+
data-testid="advanced-search-help-link"
71+
onClick={handleClickOpen}
72+
>
73+
search options
74+
</Link>
75+
.
76+
</Trans>
7577
<Dialog
7678
onClose={handleClose}
7779
aria-labelledby="advanced-search-dialog-title"
@@ -156,7 +158,6 @@ const AdvancedHelpDialogue = (): React.ReactElement => {
156158
</TableContainer>
157159
</Section>
158160
)}
159-
160161
<Section>
161162
<SectionTitle>{t('advanced_search_help.terms.title')}</SectionTitle>
162163
<SectionText>

0 commit comments

Comments
 (0)