mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-24 11:03:17 -04:00
test(e2e,playwright): show.tsx (#51947)
This commit is contained in:
@@ -353,6 +353,7 @@ class ShowOdin extends Component<ShowOdinProps, ShowOdinState> {
|
||||
block={true}
|
||||
bsSize='large'
|
||||
bsStyle='primary'
|
||||
data-playwright-test-label='check-answer-button'
|
||||
onClick={() =>
|
||||
this.handleSubmit(
|
||||
solution,
|
||||
@@ -368,6 +369,7 @@ class ShowOdin extends Component<ShowOdinProps, ShowOdinState> {
|
||||
bsSize='large'
|
||||
bsStyle='primary'
|
||||
className='btn-invert'
|
||||
data-playwright-test-label='ask-for-help-button'
|
||||
onClick={openHelpModal}
|
||||
>
|
||||
{t('buttons.ask-for-help')}
|
||||
|
||||
33
e2e/show.spec.ts
Normal file
33
e2e/show.spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
|
||||
const checkAnswerButton = translations.buttons['check-answer'];
|
||||
const askForHelpButton = translations.buttons['ask-for-help'];
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto(
|
||||
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/write-your-first-c-sharp-code'
|
||||
);
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
await page.close();
|
||||
});
|
||||
|
||||
test('the page should render with correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle(
|
||||
'Write Your First Code Using C# - Write Your First C# Code | Learn | freeCodeCamp.org'
|
||||
);
|
||||
});
|
||||
|
||||
test('correct check answer button', async ({ page }) => {
|
||||
const checkAnswer = page.getByTestId('check-answer-button');
|
||||
await expect(checkAnswer).toBeVisible();
|
||||
await expect(checkAnswer).toContainText(checkAnswerButton);
|
||||
});
|
||||
|
||||
test('correct ask for help button', async ({ page }) => {
|
||||
const askHelp = page.getByTestId('ask-for-help-button');
|
||||
await expect(askHelp).toBeVisible();
|
||||
await expect(askHelp).toContainText(askForHelpButton);
|
||||
});
|
||||
Reference in New Issue
Block a user