feat: donate page donor tests to playwright (#54857)

This commit is contained in:
Sem Bauke 2024-05-22 13:25:53 +02:00 committed by GitHub
parent 52dfbe96dc
commit b11b17e218
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 59 additions and 27 deletions

View File

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

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