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,59 @@
/* global cy expect */
import '@testing-library/cypress/add-commands';
describe('Settings certifications area', () => {
before(() => {
cy.exec('npm run seed');
cy.login();
cy.visit('/settings');
});
describe('initially', () => {
it('Should render 15 "Claim Certification" buttons', () => {
cy.findAllByText('Claim Certification').should($btns => {
expect($btns).to.have.length(15);
});
});
it('Should render zero "Show Certification" buttons', () => {
cy.contains('Show Certification').should('not.exist');
});
it('Should render one "Agree" button', () => {
cy.contains('Agree').should('exist');
});
describe('before isHonest', () => {
it('Should show "must agree" message when trying to claim a cert', () => {
cy.contains('Claim Certification').click();
cy.contains(
'To claim a certification, you must first accept our academic honesty policy'
).should('exist');
});
});
describe('after isHonest', () => {
beforeEach(() => {
cy.visit('/');
cy.login();
cy.visit('/settings');
});
it('Should render "You have accepted our Academic Honesty Policy." button after clicking "Agree"', () => {
cy.contains('Agree').click({ force: true });
cy.contains('You have accepted our Academic Honesty Policy.').should(
'exist'
);
});
it('Should show "incompleted projects" message when clicking "Claim Certification"', () => {
cy.contains('Claim Certification').click({ force: true });
cy.contains(
'It looks like you have not completed the necessary steps. Please complete the required projects to claim the Responsive Web Design Certification'
).should('exist');
});
});
});
});

View File

@ -0,0 +1,44 @@
/* global cy */
describe('Email input field', () => {
beforeEach(() => {
cy.exec('npm run seed');
cy.login();
cy.visit('/settings');
});
it('Should be possible to submit the new email', () => {
cy.get('[id=new-email]')
.type('bar@foo.com')
.should('have.attr', 'value', 'bar@foo.com');
cy.get('[id=confirm-email]')
.type('bar@foo.com')
.should('have.attr', 'value', 'bar@foo.com');
cy.get('[id=form-update-email]').within(() => {
cy.contains('Save').click();
});
cy.contains(
'Check your email and click the link we sent you to confirm your new email address.'
);
});
it('Displays an error message when there are problems with the submitted emails', () => {
cy.get('[id=new-email]').type('bar@foo.com');
cy.get('[id=confirm-email]').type('foo@bar.com');
cy.get('[class=help-block]').contains(
'Both new email addresses must be the same'
);
cy.get('[id=new-email]').clear().type('foo@bar.com');
cy.get('[class=help-block]').contains(
'This email is the same as your current email'
);
});
it('Should be possible to get Quincys weekly email', () => {
cy.contains('Yes please').click();
});
});

View File

@ -0,0 +1,39 @@
/* global cy */
describe('Picture input field', () => {
beforeEach(() => {
cy.login();
cy.visit('/settings');
// Setting aliases here
cy.get('input#about-picture').as('pictureInput');
});
it('Should be possible to type', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type('twaha', { force: true })
.should('have.attr', 'value', 'twaha');
});
it('Show an error message if an incorrect url was submitted', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type('https://s3.amazonaws.com/freecodecamp/camper-image', {
force: true
})
.then(() => {
cy.contains('URL must link directly to an image file');
});
});
it('Can submit a correct URL', () => {
cy.get('@pictureInput')
.clear({ force: true })
.type(
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png',
{
force: true
}
);
cy.wait(500);
cy.get('#camper-identity > .btn').should('not.be.disabled');
});
});

View File

@ -0,0 +1,15 @@
/* global cy expect */
describe('Settings', () => {
it('should be possible to reset your progress', () => {
cy.visit('/');
cy.contains("Get started (it's free)").click();
cy.visit('/settings');
cy.contains('Reset all of my progress').click();
cy.contains('Reset everything. I want to start from the beginning').click();
cy.location().should(loc => {
expect(loc.pathname).to.eq('/');
});
cy.contains('Your progress has been reset');
});
});

View File

@ -0,0 +1,219 @@
/* global cy */
describe('Username input field', () => {
beforeEach(() => {
cy.visit('/');
cy.contains("Get started (it's free)").click({ force: true });
cy.visit('/settings');
// Setting aliases here
cy.get('input[name=username-settings]').as('usernameInput');
cy.get('form#usernameSettings').as('usernameForm');
});
it('Should be possible to type', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('twaha', { force: true })
.should('have.attr', 'value', 'twaha');
});
it('Should show message when validating name', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('twaha', { force: true });
cy.contains('Validating username...')
.should('have.attr', 'role', 'alert')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should('have.class', 'alert alert-info');
});
it('Should show username is available if it is', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('brad', { force: true });
cy.contains('Username is available')
.should('be.visible')
.should('have.attr', 'role', 'alert')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should('have.class', 'alert alert-success');
});
it('Should info message if username is available', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('mrugesh', { force: true });
cy.contains(
'Please note, changing your username will also change ' +
'the URL to your profile and your certifications.'
)
.should('be.visible')
.should('have.attr', 'role', 'alert')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should('have.class', 'alert alert-info');
});
// eslint-disable-next-line
it('Should be able to click the `Save` button if username is avalable', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('oliver', { force: true });
cy.get('@usernameForm').within(() => {
cy.contains('Save').should('not.be.disabled');
});
});
it('Should show username is unavailable if it is', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('twaha', { force: true });
cy.contains('Username not available')
.should('be.visible')
.should('have.attr', 'role', 'alert')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should('have.class', 'alert alert-warning');
});
// eslint-disable-next-line
it('Should not be possible to click the `Save` button if username is unavailable', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('twaha', { force: true });
cy.contains('Username is available').should('not.exist');
cy.contains('Username not available').should('not.exist');
cy.contains(
'Please note, changing your username will also change ' +
'the URL to your profile and your certifications.'
).should('not.exist');
cy.get('@usernameForm').contains('Save').should('be.disabled');
});
it('Should not show anything if user types their current name', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('developmentuser', { force: true });
cy.get('@usernameForm').contains('Save').should('be.disabled');
});
// eslint-disable-next-line max-len
it('Should not be possible to click the `Save` button if user types their current name', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('developmentuser', { force: true });
cy.get('@usernameForm').contains('Save').should('be.disabled');
});
it('Should show warning if username includes invalid character', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('Quincy Larson', { force: true });
cy.contains('Username "Quincy Larson" contains invalid characters')
.should('be.visible')
.should('have.attr', 'role', 'alert')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should('have.class', 'alert alert-danger');
});
// eslint-disable-next-line max-len
it('Should not be able to click the `Save` button if username includes invalid character', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('Quincy Larson', { force: true });
cy.get('@usernameForm').contains('Save').should('be.disabled');
});
it('Should change username if `Save` button is clicked', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('quincy', { force: true });
cy.contains('Username is available');
cy.get('@usernameForm').contains('Save').click({ force: true });
cy.contains('Account Settings for quincy').should('be.visible');
cy.resetUsername();
});
it('Should show flash message showing username has been updated', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('nhcarrigan', { force: true });
cy.contains('Username is available');
cy.get('@usernameInput').type('{enter}', { force: true, release: false });
cy.contains('We have updated your username to nhcarrigan')
.should('be.visible')
// We are checking for classes here to check for proper styling
// This will be replaced with Percy in the future
.should(
'have.class',
'flash-message alert alert-success alert-dismissable'
);
cy.resetUsername();
});
it('Should be able to close the shown flash message', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('bjorno', { force: true });
cy.contains('Username is available');
cy.get('@usernameInput').type('{enter}', { force: true, release: false });
cy.contains('We have updated your username to bjorno').within(() => {
cy.get('button').click();
});
cy.contains('We have updated your username to bjorno').should('not.exist');
cy.resetUsername();
});
it('Should change username if enter is pressed', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('symbol', { force: true });
cy.contains('Username is available');
cy.get('@usernameInput').type('{enter}', { force: true, release: false });
cy.contains('Account Settings for symbol').should('be.visible');
cy.resetUsername();
});
it('Should show warning if username includes uppercase characters', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('QuincyLarson', { force: true });
cy.contains('Username "QuincyLarson" must be lowercase')
.should('be.visible')
.should('have.attr', 'role', 'alert')
.should('have.class', 'alert alert-danger');
});
it('Should not be able to click the `Save` button if username includes uppercase characters', () => {
cy.get('@usernameInput')
.clear({ force: true })
.type('QuincyLarson', { force: true });
cy.get('@usernameForm').contains('Save').should('be.disabled');
});
});