From 626d286bcacf2a7367b4196c939a84100a27bce0 Mon Sep 17 00:00:00 2001 From: "Nicholas Carrigan (he/him)" Date: Fri, 7 May 2021 14:12:16 -0700 Subject: [PATCH] feat(tools): help button tests (#42051) Add tests that validate the functionality of the `Get Help` dropdown. --- .../learn/common-components/helpButton.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cypress/integration/learn/common-components/helpButton.js diff --git a/cypress/integration/learn/common-components/helpButton.js b/cypress/integration/learn/common-components/helpButton.js new file mode 100644 index 00000000000..4dff403bea8 --- /dev/null +++ b/cypress/integration/learn/common-components/helpButton.js @@ -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'); + }); + }); +});