mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-30 16:01:14 -04:00
feat: convert c-sharp test to playwright (#54749)
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
const cSharpLocations = {
|
||||
challenge:
|
||||
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/write-your-first-c-sharp-code',
|
||||
trophy:
|
||||
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp'
|
||||
};
|
||||
|
||||
describe('C Sharp', () => {
|
||||
before(() => {
|
||||
cy.task('seed');
|
||||
});
|
||||
describe('Challenges', () => {
|
||||
before(() => {
|
||||
cy.visit(cSharpLocations.challenge);
|
||||
});
|
||||
|
||||
it('renders the correct buttons', () => {
|
||||
cy.contains('Check your answer').should('be.visible');
|
||||
cy.contains('Ask for Help').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Trophy Challenges', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit(cSharpLocations.trophy);
|
||||
});
|
||||
|
||||
it('renders the correct buttons', () => {
|
||||
cy.contains('Link Account').should('be.visible');
|
||||
cy.contains('Verify Trophy').should('be.visible');
|
||||
cy.contains('Ask for Help').should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
46
e2e/c-sharp.spec.ts
Normal file
46
e2e/c-sharp.spec.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import translations from '../client/i18n/locales/english/translations.json';
|
||||
test.use({ storageState: 'playwright/.auth/certified-user.json' });
|
||||
const checkAnswerButtonText = translations.buttons['check-answer'];
|
||||
const askForHelpButtonText = translations.buttons['ask-for-help'];
|
||||
const trophyButtonText = translations.buttons['verify-trophy'];
|
||||
const unlinkAccountButtonText = translations.buttons['unlink-account'];
|
||||
|
||||
const challenge =
|
||||
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/write-your-first-c-sharp-code';
|
||||
|
||||
const trophy =
|
||||
'/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp';
|
||||
|
||||
test('renders buttons on challenge page', async ({ page }) => {
|
||||
await page.goto(challenge);
|
||||
await expect(
|
||||
page.getByRole('button', { name: checkAnswerButtonText })
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: askForHelpButtonText
|
||||
})
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('renders buttons on trophy page', async ({ page }) => {
|
||||
await page.goto(trophy);
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', { name: unlinkAccountButtonText })
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: trophyButtonText
|
||||
})
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByRole('button', {
|
||||
name: askForHelpButtonText
|
||||
})
|
||||
).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user