Skip to content

Commit

Permalink
test(e2e, playwright): add test for link properties in challenge-desc…
Browse files Browse the repository at this point in the history
…ription (freeCodeCamp#52401)

Co-authored-by: Huyen Nguyen <[email protected]>
  • Loading branch information
weilirs and huyenltnguyen authored Nov 28, 2023
1 parent 02e1dee commit dc105a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions e2e/challenge-description.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ test.beforeEach(async ({ page }) => {
});

test.describe('Challenge Description Component Tests', () => {
test('should be visible', async ({ page }) => {
test('should display the content correctly', 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(/ */);

const link = page.getByRole('link', { name: 'your achievements page' });
await expect(link).toHaveAttribute(
'href',
'https://learn.microsoft.com/users/me/achievements#trophies-section'
);
await expect(link).toHaveAttribute('target', '_blank');
await expect(link).toHaveAttribute('rel', 'noreferrer');
});
});

0 comments on commit dc105a8

Please sign in to comment.