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:
Oliver Eyton-Williams
2021-12-11 10:04:16 +01:00
committed by GitHub
parent 8fb945c5a8
commit 48f88428e8
11 changed files with 100 additions and 157 deletions

View File

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