test: login more directly (#44467)
* test: login more directly * test: separate login from other visits In a single test, Cypress can only visit within a single domain, hence the separation. * chore: fail slowly for all strategies * test: user certified user for showing cert * test: fix and cleanup certifications
This commit is contained in:
committed by
GitHub
parent
8fb945c5a8
commit
48f88428e8
@ -1,57 +1,40 @@
|
||||
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', () => {
|
||||
before(() => {
|
||||
cy.exec('npm run seed');
|
||||
cy.login();
|
||||
});
|
||||
|
||||
it('Should render the default settings page', () => {
|
||||
cy.visit('/settings/');
|
||||
cy.findAllByText('Claim Certification').should($btns => {
|
||||
expect($btns).to.have.length(15);
|
||||
});
|
||||
cy.findByText('Show Certification').should('not.exist');
|
||||
cy.contains('Agree');
|
||||
cy.contains('Claim Certification').click();
|
||||
cy.contains(
|
||||
'To claim a certification, you must first accept our academic honesty policy'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('after isHonest', () => {
|
||||
before(() => {
|
||||
cy.exec('npm run seed');
|
||||
cy.login();
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
it('Should update the user as they try to claim their certifications', () => {
|
||||
cy.visit('/settings');
|
||||
cy.contains('Agree').click();
|
||||
cy.contains('You have accepted our Academic Honesty Policy.');
|
||||
cy.contains('Claim Certification').click();
|
||||
cy.contains(
|
||||
'It looks like you have not completed the necessary steps. Please complete the required projects to claim the Responsive Web Design Certification'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,8 @@
|
||||
describe('Settings', () => {
|
||||
it('should be possible to reset your progress', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
});
|
||||
it('should be possible to reset your progress', () => {
|
||||
cy.visit('/settings');
|
||||
cy.contains('Reset all of my progress').click();
|
||||
cy.contains('Reset everything. I want to start from the beginning').click();
|
||||
|
@ -1,14 +1,18 @@
|
||||
describe('Username input field', () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
});
|
||||
|
||||
function goToSettings() {
|
||||
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', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('twaha', { force: true })
|
||||
@ -16,6 +20,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should show message when validating name', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('twaha', { force: true });
|
||||
@ -28,6 +33,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should show username is available if it is', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('brad', { force: true });
|
||||
@ -41,6 +47,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should info message if username is available', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('mrugesh', { force: true });
|
||||
@ -58,6 +65,7 @@ describe('Username input field', () => {
|
||||
|
||||
// eslint-disable-next-line
|
||||
it('Should be able to click the `Save` button if username is avalable', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('oliver', { force: true });
|
||||
@ -68,6 +76,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should show username is unavailable if it is', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('twaha', { force: true });
|
||||
@ -82,6 +91,7 @@ describe('Username input field', () => {
|
||||
|
||||
// eslint-disable-next-line
|
||||
it('Should not be possible to click the `Save` button if username is unavailable', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('twaha', { force: true });
|
||||
@ -97,6 +107,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should not show anything if user types their current name', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('developmentuser', { force: true });
|
||||
@ -106,6 +117,7 @@ describe('Username input field', () => {
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
it('Should not be possible to click the `Save` button if user types their current name', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('developmentuser', { force: true });
|
||||
@ -114,6 +126,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should show warning if username includes invalid character', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('Quincy Larson', { force: true });
|
||||
@ -128,6 +141,7 @@ describe('Username input field', () => {
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
it('Should not be able to click the `Save` button if username includes invalid character', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('Quincy Larson', { force: true });
|
||||
@ -136,6 +150,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should change username if `Save` button is clicked', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('quincy', { force: true });
|
||||
@ -149,6 +164,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should change username with uppercase characters if `Save` button is clicked', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('Quincy', { force: true });
|
||||
@ -162,6 +178,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should show flash message showing username has been updated', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('nhcarrigan', { force: true });
|
||||
@ -181,6 +198,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should be able to close the shown flash message', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('bjorno', { force: true });
|
||||
@ -197,6 +215,7 @@ describe('Username input field', () => {
|
||||
});
|
||||
|
||||
it('Should change username if enter is pressed', () => {
|
||||
goToSettings();
|
||||
cy.get('@usernameInput')
|
||||
.clear({ force: true })
|
||||
.type('symbol', { force: true });
|
||||
|
Reference in New Issue
Block a user