test(e2e,playwright): challenge-description.tsx (#51914)

pull/51947/head^2
Ann-Cherian 2023-10-13 13:21:00 +05:30 committed by GitHub
parent ddd034f8b4
commit 1c77a3bb04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -15,7 +15,10 @@ function ChallengeDescription(challenge: Challenge): JSX.Element {
const bClass = challenge.block ? challenge.block : '';
return (
<div className={`challenge-instructions ${sbClass} ${bClass}`}>
<div
className={`challenge-instructions ${sbClass} ${bClass}`}
data-playwright-test-label='challenge-description'
>
{challenge.description && <PrismFormatted text={challenge.description} />}
{challenge.instructions && (
<>

View File

@ -0,0 +1,23 @@
import { test, expect } from '@playwright/test';
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.describe('Challenge Description Component Tests', () => {
test('should be visible', async ({ page }) => {
const challengeDescription = page.getByTestId('challenge-description');
await expect(challengeDescription).toBeVisible();
});
test('should contain text', async ({ page }) => {
const challengeDescription = page.getByTestId('challenge-description');
await expect(challengeDescription).toHaveText(/ */);
});
});