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

@ -34,6 +34,7 @@ const pythonProjects = {
describe('project submission', () => {
beforeEach(() => {
cy.exec('npm run seed');
cy.login();
});
// NOTE: this will fail once challenge tests are added.
it('Should be possible to submit Python projects', () => {
@ -46,7 +47,7 @@ describe('project submission', () => {
.type('https://replit.com/@camperbot/python-project#main.py');
cy.contains("I've completed this challenge").click();
cy.contains('Go to next challenge');
cy.contains('go to next challenge');
// clicking on 'Go to next challenge' seems to have caused flakiness, so
// it's commented out until we figure out why.
// cy.contains('Go to next challenge').click();
@ -61,7 +62,6 @@ describe('project submission', () => {
'JavaScript projects can be submitted and then viewed in /settings and on the certifications',
{ browser: 'electron' },
() => {
cy.login();
cy.fixture('../../config/curriculum.json').then(curriculum => {
const { challenges, meta } =
curriculum[SuperBlocks.JsAlgoDataStruct].blocks[

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