feat: standardize view button text (#47525)

* feat: standardize view button text

Add new translation keys Delete unused translation keys Fix tests broken with new functionalities

* Delete View variations in translations.json
Delete buttons tittle
Modify buttons text to be "View" or translated equivalent
Modify tests to query the buttons by role and name

Co-authored-by: HDAnzo <hdanzoategui@softwarenatura.com>
pull/47676/head
Hdanzo 2022-09-30 03:39:33 -04:00 committed by GitHub
parent 85b5254c48
commit c4f7e45832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 18 deletions

View File

@ -6,9 +6,6 @@
"first-lesson": "Go to the first lesson",
"close": "Close",
"edit": "Edit",
"show-code": "Show Code",
"show-solution": "Show Solution",
"show-project": "Show Project",
"frontend": "Front End",
"backend": "Back End",
"view": "View",

View File

@ -84,8 +84,10 @@ describe('<TimeLine />', () => {
// @ts-expect-error
render(<TimeLine {...propsForOnlySolution} />, store);
const button = screen.getByText('buttons.show-code');
expect(button).toBeInTheDocument();
const viewButtons = screen.getAllByRole('button', { name: 'buttons.view' });
viewButtons.forEach(button => {
expect(button).toBeInTheDocument();
});
});
});

View File

@ -65,7 +65,7 @@ describe('<certification />', () => {
expect(
screen.getByRole('link', {
name: 'buttons.show-solution'
name: 'buttons.view'
})
).toHaveAttribute('href', 'https://github.com/freeCodeCamp/freeCodeCamp');
});
@ -88,8 +88,10 @@ describe('<certification />', () => {
it('rendering the correct button when files is present', () => {
renderWithRedux(<CertificationSettings {...propsForOnlySolution} />);
const button = screen.getByText('buttons.show-code');
expect(button).toBeInTheDocument();
const viewButtons = screen.getAllByRole('button', { name: 'buttons.view' });
viewButtons.forEach(button => {
expect(button).toBeInTheDocument();
});
});
});

View File

@ -25,11 +25,7 @@ export function SolutionDisplayWidget({
}: Props) {
const { id, solution, githubLink } = completedChallenge;
const { t } = useTranslation();
const showOrViewText =
displayContext === 'settings'
? t('buttons.show-solution')
: t('buttons.view');
const viewText = t('buttons.view');
const ShowFilesSolutionForCertification = (
<button
@ -73,7 +69,7 @@ export function SolutionDisplayWidget({
id={`btn-for-${id}`}
onClick={showUserCode}
>
{t('buttons.show-code')}
{viewText}
</Button>
);
const ShowMultifileProjectSolution = (
@ -86,10 +82,10 @@ export function SolutionDisplayWidget({
title={t('buttons.view')}
>
<MenuItem bsStyle='primary' onClick={showUserCode}>
{t('buttons.show-code')}
{viewText}
</MenuItem>
<MenuItem bsStyle='primary' onClick={showProjectPreview}>
{t('buttons.show-project')}
{viewText}
</MenuItem>
</DropdownButton>
</div>
@ -102,7 +98,7 @@ export function SolutionDisplayWidget({
bsStyle='primary'
className='btn-invert'
id={`dropdown-for-${id}`}
title={showOrViewText}
title={viewText}
>
<MenuItem
bsStyle='primary'
@ -133,7 +129,7 @@ export function SolutionDisplayWidget({
rel='noopener noreferrer'
target='_blank'
>
{showOrViewText}
{viewText}
</Button>
);
const MissingSolutionComponent =