Skip to content

Commit

Permalink
fix(client): OS specific submit button text (freeCodeCamp#55631)
Browse files Browse the repository at this point in the history
Co-authored-by: Lasse Jørgensen <[email protected]>
  • Loading branch information
gagan-bhullar-tech and lasjorg authored Jul 28, 2024
1 parent f5404dd commit 2b8169d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client/src/templates/Challenges/classic/lower-jaw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,14 @@ const LowerJaw = ({
: t('buttons.check-code')
: t('buttons.check-code-2');

const submitButtonText = isDesktop
? isMacOS
? t('buttons.submit-and-go-3')
: t('buttons.submit-and-go-2')
: t('buttons.submit-and-go');

const showSignInButton = !isSignedIn && challengeIsCompleted;

return (
<div className='action-row-container'>
{showSignInButton && (
Expand All @@ -319,7 +326,7 @@ const LowerJaw = ({
{...(!challengeIsCompleted && { 'aria-hidden': true })}
ref={submitButtonRef}
>
{t('buttons.submit-and-go')}
{submitButtonText}
</Button>
<div
className={
Expand Down
39 changes: 39 additions & 0 deletions e2e/lower-jaw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,42 @@ test('Should display the text of the check code button accordingly based on devi
).toBeVisible();
}
});

test('should display the text of submit and go to next challenge button accordingly based on device type', async ({
page,
isMobile,
browserName
}) => {
const editor = getEditors(page);
const checkButton = page.getByRole('button', { name: 'Check Your Code' });

await focusEditor({ page, isMobile });
await clearEditor({ page, browserName });

await editor.fill(
'<h2>Cat Photos</h2>\n<p>See more cat photos in our gallery.</p>'
);

await checkButton.click();

if (isMobile) {
await expect(
page.getByRole('button', {
name: 'Submit and go to next challenge',
exact: true
})
).toBeVisible();
} else if (browserName === 'webkit') {
await expect(
page.getByRole('button', {
name: 'Submit and go to next challenge (Command + Enter)'
})
).toBeVisible();
} else {
await expect(
page.getByRole('button', {
name: 'Submit and go to next challenge (Ctrl + Enter)'
})
).toBeVisible();
}
});

0 comments on commit 2b8169d

Please sign in to comment.