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

@ -32,7 +32,7 @@ function waitForAppStart() {
});
}
describe('Navbar', () => {
describe('Navbar when logged out', () => {
beforeEach(() => {
appHasStarted = false;
cy.visit('/', {
@ -41,6 +41,32 @@ describe('Navbar', () => {
cy.viewport(1300, 660);
});
it('Should have a "Sign in" button', () => {
cy.contains("[data-test-label='landing-small-cta']", 'Sign in');
});
it(
'Should have `Sign in` link on landing and learn pages' +
' when not signed in',
() => {
cy.contains(selectors.smallCallToAction, 'Sign in');
cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks).contains('Curriculum').click();
cy.contains(selectors.smallCallToAction, 'Sign in');
}
);
});
describe('Navbar Logged in', () => {
beforeEach(() => {
cy.login();
appHasStarted = false;
cy.visit('/', {
onBeforeLoad: spyOnListener
}).then(waitForAppStart);
cy.viewport(1300, 660);
});
it('Should render properly', () => {
cy.get('#universal-nav').should('be.visible');
cy.get('#universal-nav').should('have.class', 'universal-nav');
@ -56,10 +82,6 @@ describe('Navbar', () => {
}
);
it('Should have a "Sign in" button', () => {
cy.contains("[data-test-label='landing-small-cta']", 'Sign in');
});
// have the curriculum and CTA on landing and /learn pages.
it(
'Should have `Radio`, `Forum`, and `Curriculum` links on landing and learn pages' +
@ -75,32 +97,18 @@ describe('Navbar', () => {
}
);
it(
'Should have `Sign in` link on landing and learn pages' +
' when not signed in',
() => {
cy.contains(selectors.smallCallToAction, 'Sign in');
cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks).contains('Curriculum').click();
cy.contains(selectors.smallCallToAction, 'Sign in');
}
);
it('Should have `Profile` link when user is signed in', () => {
cy.login();
cy.get(selectors.menuButton).click();
cy.get(selectors.navigationLinks).contains('Profile').click();
cy.url().should('include', '/developmentuser');
});
it('Should have a profile image with class `default-border`', () => {
cy.login();
cy.get(selectors.avatarContainer).should('have.class', 'default-border');
cy.get(selectors.defaultAvatar).should('exist');
});
it('Should have a profile image with dimensions that are <= 31px', () => {
cy.login();
cy.get(selectors.avatarImage).invoke('width').should('lte', 31);
cy.get(selectors.avatarImage).invoke('height').should('lte', 31);
});