From 66c552390947434b3aab27f27ed9e8c1eaa26856 Mon Sep 17 00:00:00 2001 From: saeed Date: Mon, 24 May 2021 03:00:07 +0430 Subject: [PATCH] feat: render footer correctly (#42096) Co-authored-by: Ahmad Abdolsaheb --- client/utils/gatsby/layoutSelector.js | 9 +++--- .../learn/common-components/footer.js | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 cypress/integration/learn/common-components/footer.js diff --git a/client/utils/gatsby/layoutSelector.js b/client/utils/gatsby/layoutSelector.js index 1a21594b18..d8af5d1a02 100644 --- a/client/utils/gatsby/layoutSelector.js +++ b/client/utils/gatsby/layoutSelector.js @@ -26,11 +26,12 @@ export default function layoutSelector({ element, props }) { } const splitPath = pathname.split('/').filter(x => x); - const isSuperBlock = - (splitPath.length === 2 && splitPath[0]) === 'learn' || - (splitPath.length === 3 && splitPath[1]) === 'learn'; - if (/\/learn\//.test(pathname) && !isSuperBlock) { + const isChallenge = + (splitPath.length === 4 && splitPath[0]) === 'learn' || + (splitPath.length === 5 && splitPath[1]) === 'learn'; + + if (isChallenge) { return ( {element} diff --git a/cypress/integration/learn/common-components/footer.js b/cypress/integration/learn/common-components/footer.js new file mode 100644 index 0000000000..864091285b --- /dev/null +++ b/cypress/integration/learn/common-components/footer.js @@ -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'); + }); +});