mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-05 21:03:24 -05:00
test(e2e,playwright): ms-trophy-show.tsx (#51855)
This commit is contained in:
@@ -205,6 +205,7 @@ class MsTrophy extends Component<MsTrophyProps> {
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
data-playwright-test-label='verify-trophy-button'
|
||||
className='btn-invert'
|
||||
disabled={!msUsername || isProcessing}
|
||||
onClick={this.handleSubmit}
|
||||
@@ -214,6 +215,7 @@ class MsTrophy extends Component<MsTrophyProps> {
|
||||
<Button
|
||||
block={true}
|
||||
bsStyle='primary'
|
||||
data-playwright-test-label='ask-for-help-button'
|
||||
className='btn-invert'
|
||||
onClick={openHelpModal}
|
||||
>
|
||||
|
||||
37
e2e/ms-trophy-show.spec.ts
Normal file
37
e2e/ms-trophy-show.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
|
||||
const verifyTrophyButtonText = translations.buttons['verify-trophy'];
|
||||
const askForHelpButtonText = 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/trophy-write-your-first-code-using-c-sharp'
|
||||
);
|
||||
});
|
||||
|
||||
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# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
|
||||
);
|
||||
});
|
||||
|
||||
test('Correct Verify Trophy button', async ({ page }) => {
|
||||
const askHelpButton = page.getByRole('button', {
|
||||
name: verifyTrophyButtonText
|
||||
});
|
||||
await expect(askHelpButton).toBeVisible();
|
||||
await expect(askHelpButton).toHaveText(verifyTrophyButtonText);
|
||||
});
|
||||
|
||||
test('Correct Ask for help button', async ({ page }) => {
|
||||
const checkAnswerButton = page.getByRole('button', {
|
||||
name: askForHelpButtonText
|
||||
});
|
||||
await expect(checkAnswerButton).toBeVisible();
|
||||
await expect(checkAnswerButton).toContainText(askForHelpButtonText);
|
||||
});
|
||||
Reference in New Issue
Block a user