revert: (test, e2e) test suit for cypress (#42488)
This reverts commit 22b45761a7
.
This commit is contained in:
committed by
GitHub
parent
3fc6877bb0
commit
3130265991
31
cypress/integration/learn/common-components/footer.js
Normal file
31
cypress/integration/learn/common-components/footer.js
Normal file
@ -0,0 +1,31 @@
|
||||
/* global cy */
|
||||
|
||||
const selectors = {
|
||||
footer: '.site-footer'
|
||||
};
|
||||
|
||||
describe('Footer', () => {
|
||||
it('Should render on landing page', () => {
|
||||
cy.visit('/');
|
||||
cy.get(selectors.footer).should('be.visible');
|
||||
});
|
||||
|
||||
it('Should render on learn page', () => {
|
||||
cy.visit('/learn');
|
||||
cy.get(selectors.footer).should('be.visible');
|
||||
cy.visit('/learn/');
|
||||
cy.get(selectors.footer).should('be.visible');
|
||||
});
|
||||
|
||||
it('Should render on superblock page', () => {
|
||||
cy.visit('/learn/responsive-web-design/');
|
||||
cy.get(selectors.footer).should('be.visible');
|
||||
});
|
||||
|
||||
it('Should not render on challenge page', () => {
|
||||
cy.visit(
|
||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
|
||||
);
|
||||
cy.get(selectors.footer).should('not.exist');
|
||||
});
|
||||
});
|
36
cypress/integration/learn/common-components/helpButton.js
Normal file
36
cypress/integration/learn/common-components/helpButton.js
Normal file
@ -0,0 +1,36 @@
|
||||
/* global cy */
|
||||
|
||||
describe('Help Button', () => {
|
||||
it('should be visible', () => {
|
||||
cy.visit(
|
||||
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
|
||||
);
|
||||
cy.get('#get-help-dropdown').scrollIntoView().should('be.visible');
|
||||
});
|
||||
|
||||
it('should toggle the dropdown menu', () => {
|
||||
cy.get('#get-help-dropdown').scrollIntoView().click();
|
||||
cy.get('ul[role="menu"]').should('be.visible');
|
||||
});
|
||||
|
||||
it('should render three links when video is available', () => {
|
||||
cy.get('ul[role="menu"]').within(() => {
|
||||
cy.get('a').should('have.length', 3);
|
||||
cy.get('a').eq(0).contains('Get a Hint');
|
||||
cy.get('a').eq(1).contains('Watch a Video');
|
||||
cy.get('a').eq(2).contains('Ask for Help');
|
||||
});
|
||||
});
|
||||
|
||||
it('should render two links when video is not available', () => {
|
||||
cy.visit(
|
||||
'/learn/front-end-libraries/bootstrap/apply-the-default-bootstrap-button-style'
|
||||
);
|
||||
cy.get('#get-help-dropdown').scrollIntoView().click();
|
||||
cy.get('ul[role="menu"]').within(() => {
|
||||
cy.get('a').should('have.length', 2);
|
||||
cy.get('a').eq(0).contains('Get a Hint');
|
||||
cy.get('a').eq(1).contains('Ask for Help');
|
||||
});
|
||||
});
|
||||
});
|
109
cypress/integration/learn/common-components/navbar.js
Normal file
109
cypress/integration/learn/common-components/navbar.js
Normal file
@ -0,0 +1,109 @@
|
||||
/* global cy */
|
||||
|
||||
const selectors = {
|
||||
heading: "[data-test-label='landing-header']",
|
||||
smallCallToAction: "[data-test-label='landing-small-cta']",
|
||||
navigationLinks: '.nav-list',
|
||||
avatarContainer: '.avatar-container',
|
||||
defaultAvatar: '.avatar-container',
|
||||
menuButton: '.toggle-button-nav',
|
||||
avatarImage: '.avatar-container .avatar'
|
||||
};
|
||||
|
||||
let appHasStarted;
|
||||
function spyOnListener(win) {
|
||||
const addListener = win.EventTarget.prototype.addEventListener;
|
||||
win.EventTarget.prototype.addEventListener = function (name) {
|
||||
if (name === 'click') {
|
||||
appHasStarted = true;
|
||||
win.EventTarget.prototype.addEventListener = addListener;
|
||||
}
|
||||
return addListener.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function waitForAppStart() {
|
||||
return new Promise(resolve => {
|
||||
const isReady = () => {
|
||||
if (appHasStarted) {
|
||||
return resolve();
|
||||
}
|
||||
return setTimeout(isReady, 0);
|
||||
};
|
||||
isReady();
|
||||
});
|
||||
}
|
||||
|
||||
describe('Navbar', () => {
|
||||
beforeEach(() => {
|
||||
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');
|
||||
});
|
||||
|
||||
it(
|
||||
'Should take user to learn page when clicked on ' + 'the freeCodeCamp logo',
|
||||
() => {
|
||||
cy.get('.universal-nav-middle').within(() => {
|
||||
cy.get('svg').click();
|
||||
});
|
||||
cy.url().should('include', '/learn');
|
||||
}
|
||||
);
|
||||
|
||||
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' +
|
||||
'page when not signed in',
|
||||
() => {
|
||||
cy.get(selectors.menuButton).click();
|
||||
cy.get(selectors.navigationLinks).contains('Forum');
|
||||
cy.get(selectors.navigationLinks).contains('Curriculum').click();
|
||||
cy.url().should('include', '/learn');
|
||||
cy.get(selectors.navigationLinks).contains('Curriculum');
|
||||
cy.get(selectors.navigationLinks).contains('Forum');
|
||||
cy.get(selectors.navigationLinks).contains('Radio');
|
||||
}
|
||||
);
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
77
cypress/integration/learn/common-components/searchBar.js
Normal file
77
cypress/integration/learn/common-components/searchBar.js
Normal file
@ -0,0 +1,77 @@
|
||||
/* global cy */
|
||||
|
||||
const search = query => {
|
||||
cy.get('.ais-SearchBox').within(() => {
|
||||
cy.get('input').type(query);
|
||||
});
|
||||
|
||||
cy.wait(300);
|
||||
};
|
||||
|
||||
const clear = () => {
|
||||
cy.get('.ais-SearchBox').within(() => {
|
||||
cy.get('input').clear();
|
||||
});
|
||||
};
|
||||
|
||||
describe('Search bar', () => {
|
||||
before(() => {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
clear();
|
||||
});
|
||||
|
||||
it('Should render properly', () => {
|
||||
cy.get('.ais-SearchBox').should('be.visible');
|
||||
});
|
||||
|
||||
it('Should accept input and display hits', () => {
|
||||
search('freeCodeCamp');
|
||||
|
||||
cy.get('.ais-Hits-list').children().should('to.have.length.of.at.least', 1);
|
||||
});
|
||||
|
||||
it('Should clear hits when input is cleared', () => {
|
||||
search('freeCodeCamp');
|
||||
|
||||
cy.get('.ais-Hits-list').children().should('to.have.length.of.at.least', 1);
|
||||
|
||||
clear();
|
||||
|
||||
cy.get('div.ais-Hits').should('not.exist');
|
||||
});
|
||||
|
||||
it('Should show up to 8 hits when height >= 768px', () => {
|
||||
cy.viewport(1300, 768);
|
||||
|
||||
search('freeCodeCamp');
|
||||
|
||||
cy.get('.ais-Hits-list').children().should('to.have.length.of', 8);
|
||||
});
|
||||
|
||||
it('Should show up to 5 hits when height < 768px', () => {
|
||||
cy.viewport(1300, 767);
|
||||
|
||||
search('freeCodeCamp');
|
||||
|
||||
cy.get('.ais-Hits-list').children().should('to.have.length.of', 5);
|
||||
});
|
||||
|
||||
it('Should show no hits for queries that do not exist in the Algolia index', () => {
|
||||
search('testtttt');
|
||||
|
||||
cy.get('.ais-Hits-list').children().should('to.have.length.of', 0);
|
||||
|
||||
cy.contains('No tutorials found');
|
||||
});
|
||||
|
||||
it('Should not redirect to the News search page if there are no hits', () => {
|
||||
search('testtttt');
|
||||
|
||||
cy.get('.ais-SearchBox-form').submit();
|
||||
|
||||
cy.url('/');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user