mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-13 21:02:08 +08:00
feat: donate page donor tests to playwright (#54857)
This commit is contained in:
parent
52dfbe96dc
commit
b11b17e218
@ -1,27 +0,0 @@
|
||||
describe('Donate page', () => {
|
||||
beforeEach(() => {
|
||||
cy.task('seed', ['--donor']);
|
||||
cy.login();
|
||||
});
|
||||
|
||||
it('Donor CTA should be visible for donor', () => {
|
||||
cy.visit('/donate');
|
||||
cy.get('[data-cy="donate.thank-you"]').should(
|
||||
'have.text',
|
||||
'Thank You for Being a Supporter'
|
||||
);
|
||||
cy.get('[data-cy="donate.crucial-contribution"]').should(
|
||||
'have.text',
|
||||
'Your contribution will be crucial in creating resources that empower millions of people to learn new skills and support their families.'
|
||||
);
|
||||
cy.get('[data-cy="donate.if-support-further"]').should(
|
||||
'have.text',
|
||||
'If you want to support our charity further, please consider making a one-time donation, sending us a check, or learning about other ways you could support our charity.'
|
||||
);
|
||||
cy.get('[data-cy="donate-link"]').should(
|
||||
'contain.attr',
|
||||
'href',
|
||||
'https://www.freecodecamp.org/news/how-to-donate-to-free-code-camp'
|
||||
);
|
||||
});
|
||||
});
|
||||
59
e2e/donate-page-donor.spec.ts
Normal file
59
e2e/donate-page-donor.spec.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Donate page', () => {
|
||||
test.use({ storageState: 'playwright/.auth/development-user.json' });
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
execSync('node ./tools/scripts/seed/seed-demo-user --donor');
|
||||
await page.goto('/donate');
|
||||
});
|
||||
|
||||
test.afterAll(() => {
|
||||
execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
|
||||
});
|
||||
|
||||
test('should render the donate page correctly', async ({ page }) => {
|
||||
await expect(
|
||||
page.getByText('Thank You for Being a Supporter')
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByText(
|
||||
'Your contribution will be crucial in creating resources that empower millions of people to learn new skills and support their families.'
|
||||
)
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByText(
|
||||
'If you want to support our charity further, please consider making a one-time donation, sending us a check, or learning about other ways you could support our charity.'
|
||||
)
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'making a one-time donation' })
|
||||
).toHaveAttribute(
|
||||
'href',
|
||||
'https://www.freecodecamp.org/news/how-to-donate-to-free-code-camp/#how-can-i-make-a-one-time-donation'
|
||||
);
|
||||
});
|
||||
|
||||
test('The menu should have a supporters link', async ({ page }) => {
|
||||
const menuButton = page.getByTestId('header-menu-button');
|
||||
const menu = page.getByTestId('header-menu');
|
||||
|
||||
await expect(menuButton).toBeVisible();
|
||||
await menuButton.click();
|
||||
|
||||
await expect(menu).toBeVisible();
|
||||
|
||||
await expect(page.getByRole('link', { name: 'Supporters' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('The Avatar should have a special border for donors', async ({
|
||||
page
|
||||
}) => {
|
||||
const container = page.locator('.avatar-container');
|
||||
await expect(container).toHaveClass('avatar-container gold-border');
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user