forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathms-trophy-show.spec.ts
50 lines (44 loc) · 1.76 KB
/
ms-trophy-show.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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.use({ storageState: { cookies: [], origins: [] } });
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 and description', async ({
page
}) => {
await expect(page).toHaveTitle(
'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org'
);
const title = page.getByTestId('challenge-title');
await expect(title).toBeVisible();
await expect(title).toContainText('Trophy - Write Your First Code Using C#');
const description = page.getByTestId('challenge-description');
await expect(description).toBeVisible();
});
test('Correct Verify Trophy button', async ({ page }) => {
const askHelpButton = page.getByRole('button', {
name: verifyTrophyButtonText
});
await expect(askHelpButton).toBeVisible();
await expect(askHelpButton).toHaveText(verifyTrophyButtonText);
await expect(askHelpButton).toBeDisabled();
});
test('Correct Ask for help button', async ({ page }) => {
const checkAnswerButton = page.getByRole('button', {
name: askForHelpButtonText
});
await expect(checkAnswerButton).toBeVisible();
await expect(checkAnswerButton).toContainText(askForHelpButtonText);
await checkAnswerButton.click();
await expect(
page.getByRole('heading', {
name: translations.buttons['ask-for-help'],
exact: true
})
).toBeVisible();
});