-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
418ed3d
commit 909b66e
Showing
8 changed files
with
139 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,69 @@ | ||
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 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#'); | ||
test.describe('MS Trophy page if the user is signed in', () => { | ||
test('should render the content correctly', async ({ page }) => { | ||
await expect(page).toHaveTitle( | ||
'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org' | ||
); | ||
await expect( | ||
page.getByRole('heading', { | ||
level: 1, | ||
name: 'Trophy - Write Your First Code Using C#' | ||
}) | ||
).toBeVisible(); | ||
|
||
const description = page.getByTestId('challenge-description'); | ||
await expect(description).toBeVisible(); | ||
}); | ||
await expect( | ||
page.getByText( | ||
'Now that you\'ve completed all of the "Write Your First Code Using C#" challenges, you should have earned the trophy for it on the Microsoft Learn platform.' | ||
) | ||
).toBeVisible(); | ||
|
||
test('Correct Verify Trophy button', async ({ page }) => { | ||
const askHelpButton = page.getByRole('button', { | ||
name: verifyTrophyButtonText | ||
await expect(page.getByRole('button', { name: 'Unlink' })).toBeVisible(); | ||
await expect( | ||
page.getByRole('button', { name: 'Verify Trophy' }) | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole('button', { name: 'Ask for Help' }) | ||
).toBeVisible(); | ||
}); | ||
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 | ||
test.describe('MS Trophy page if the user is not signed in', () => { | ||
test.use({ storageState: { cookies: [], origins: [] } }); | ||
|
||
test('should render the content correctly', async ({ page }) => { | ||
await expect(page).toHaveTitle( | ||
'Write Your First Code Using C# - Trophy - Write Your First Code Using C# | Learn | freeCodeCamp.org' | ||
); | ||
await expect( | ||
page.getByRole('heading', { | ||
level: 1, | ||
name: 'Trophy - Write Your First Code Using C#' | ||
}) | ||
).toBeVisible(); | ||
|
||
await expect( | ||
page.getByText( | ||
'Now that you\'ve completed all of the "Write Your First Code Using C#" challenges, you should have earned the trophy for it on the Microsoft Learn platform.' | ||
) | ||
).toBeVisible(); | ||
|
||
// There are two "Sign in" buttons on the page: one in the nav, and one in the page body | ||
await expect(page.getByRole('link', { name: 'Sign in' })).toHaveCount(2); | ||
await expect( | ||
page.getByRole('button', { name: 'Verify Trophy' }) | ||
).toBeVisible(); | ||
await expect( | ||
page.getByRole('button', { name: 'Verify Trophy' }) | ||
).toBeDisabled(); | ||
await expect( | ||
page.getByRole('button', { name: 'Ask for Help' }) | ||
).toBeVisible(); | ||
}); | ||
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters