revert: (test, e2e) test suit for cypress (#42488)

This reverts commit 22b45761a7.
This commit is contained in:
Mrugesh Mohapatra
2021-06-14 23:44:43 +05:30
committed by GitHub
parent 3fc6877bb0
commit 3130265991
35 changed files with 55 additions and 367 deletions

View File

@ -0,0 +1,65 @@
/* global cy */
const selectors = {
donateSupport: {
firstTitle: '.donate-support h4:first-of-type b',
secondTitle: '.donate-support h4:last-of-type b',
firstText: '.donate-support p:first-of-type',
secondText: '.donate-support p:last-of-type',
link: '.donate-support a'
}
};
describe('Donate page', () => {
before(() => {
cy.clearCookies();
cy.exec('npm run seed');
cy.login();
cy.visit('/donate');
});
it('Should render', () => {
cy.title().should('eq', 'Support our nonprofit | freeCodeCamp.org');
});
it('Should display default amount and duration', () => {
cy.contains('Confirm your donation of $5 / month:').should('be.visible');
});
it('Should have support section', () => {
cy.contains(
'Want to make a bigger one-time donation, mail us a check, or give in other ways?'
).should('be.visible');
});
it('Support section should have support text', () => {
cy.contains(
selectors.donateSupport.firstTitle,
'Want to make a bigger one-time donation, mail us a check, or give in other ways?'
);
cy.contains(
selectors.donateSupport.secondTitle,
'Need help with your current or past donations?'
);
cy.contains(
selectors.donateSupport.firstText,
"Here are many other ways you can support our non-profit's mission."
);
cy.contains(
selectors.donateSupport.secondText,
'Forward a copy of your donation receipt to donors@freecodecamp.org and tell us how we can help.'
);
});
it('Support section should have donation link', () => {
cy.get(selectors.donateSupport.link).should(
'have.attr',
'href',
'https://www.freecodecamp.org/news/how-to-donate-to-free-code-camp'
);
});
it('Donor alert should not be visible for non-donor', () => {
cy.get('.alert-info').should('not.exist');
});
});

View File

@ -0,0 +1,45 @@
/* global cy */
const selectors = {
donateAlert: {
firstText: '.alert-info p:first-child',
secondText: '.alert-info p:last-child',
link: '.alert-info a'
}
};
describe('Donate page', () => {
before(() => {
cy.clearCookies();
cy.exec('npm run seed -- --donor');
cy.login();
cy.visit('/donate');
});
after(() => {
cy.exec('npm run seed');
});
it('Donor alert should be visible for donor', () => {
cy.get('.alert-info').should('be.visible');
});
it('Donor should see alert message', () => {
cy.contains(
selectors.donateAlert.firstText,
'Thank you for being a supporter of freeCodeCamp. You currently have a recurring donation.'
);
cy.contains(
selectors.donateAlert.lastText,
"Want to make a bigger one-time donation, mail us a check, or give in other ways? Here are many other ways you can support our non-profit's mission."
);
});
it('Donor alert section should have donation link', () => {
cy.get(selectors.donateAlert.link).should(
'have.attr',
'href',
'https://www.freecodecamp.org/news/how-to-donate-to-free-code-camp'
);
});
});

View File

@ -0,0 +1,45 @@
/* global cy */
describe('Donate page', () => {
before(() => {
cy.clearCookies();
cy.exec('npm run seed');
cy.login();
});
after(() => {
cy.exec('npm run seed');
});
const projects = [
'tribute-page',
'survey-form',
'product-landing-page',
'technical-documentation-page',
'personal-portfolio-webpage'
];
it('Should be able to submit projects', () => {
const submitProject = str => {
cy.visit(
`/learn/responsive-web-design/responsive-web-design-projects/build-a-${str}`
);
cy.get('#dynamic-front-end-form')
.get('#solution')
.type('https://codepen.io/camperbot/full/oNvPqqo', {
force: true
});
cy.contains("I've completed this challenge").click();
cy.contains('Submit and go to next challenge').click();
};
projects.forEach(project => submitProject(project));
});
it('Should have a pop up modal', () => {
cy.contains(
'Nicely done. You just completed Responsive Web Design Projects.'
);
});
});