Files
freeCodeCamp/e2e/ms-trophy-show.spec.ts
2023-10-14 10:36:15 +00:00

34 lines
1.2 KiB
TypeScript

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('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);
});