test(e2e,playwright): ms-trophy-show.tsx (#51855)

This commit is contained in:
HARSH ANAND
2023-10-11 23:37:31 +05:30
committed by GitHub
parent 16930ff73f
commit b31c57776b
2 changed files with 39 additions and 0 deletions

View File

@@ -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}
>

View 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);
});