diff --git a/cypress/integration/back-to-top.spec.js b/cypress/integration/back-to-top.spec.js --- a/cypress/integration/back-to-top.spec.js +++ b/cypress/integration/back-to-top.spec.js @@ -27,8 +27,8 @@ .get('#back-to-top') .click() .window() - .then((window) => { - assert.equal(window.scrollY, 0); + .then(win => { + assert.equal(win.scrollY, 0); }); }); }); diff --git a/cypress/integration/code-highlighting.spec.js b/cypress/integration/code-highlighting.spec.js --- a/cypress/integration/code-highlighting.spec.js +++ b/cypress/integration/code-highlighting.spec.js @@ -24,9 +24,8 @@ it('should highlight source code and add line numbers', function() { cy.visit(url); cy.get('.hljs-ln-numbers').then(lnNumbers => { - cy.get('.hljs-ln-code').then(lnCode => { - assert.equal(lnNumbers.length, lnCode.length); - }); + cy.get('.hljs-ln-code') + .should('have.length', lnNumbers.length); }); }); diff --git a/cypress/integration/directory.spec.js b/cypress/integration/directory.spec.js --- a/cypress/integration/directory.spec.js +++ b/cypress/integration/directory.spec.js @@ -5,8 +5,6 @@ * See top-level LICENSE file for more information */ -import {httpGetJson} from '../utils'; - const $ = Cypress.$; let origin; diff --git a/cypress/integration/errors.spec.js b/cypress/integration/errors.spec.js --- a/cypress/integration/errors.spec.js +++ b/cypress/integration/errors.spec.js @@ -5,8 +5,6 @@ * See top-level LICENSE file for more information */ -import {httpGetJson} from '../utils'; - let origin; const invalidChecksum = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; diff --git a/cypress/integration/layout.spec.js b/cypress/integration/layout.spec.js --- a/cypress/integration/layout.spec.js +++ b/cypress/integration/layout.spec.js @@ -10,7 +10,7 @@ describe('Test top-bar', function() { it('should should contain all navigation links', function() { cy.visit(url); - cy.get('.swh-top-bar > ul > li > a') + cy.get('.swh-top-bar a') .should('have.length', 5) .and('be.visible') .and('have.attr', 'href'); diff --git a/cypress/integration/sidebar.spec.js b/cypress/integration/sidebar.spec.js --- a/cypress/integration/sidebar.spec.js +++ b/cypress/integration/sidebar.spec.js @@ -18,43 +18,37 @@ it('should toggle sidebar when swh-push-menu is clicked', function() { cy.get('.swh-push-menu') - .click() - .then(() => { - cy.get('body') - .should('have.class', 'sidebar-collapse') - .get('.nav-link > p') - .should('have.css', 'opacity', '0'); - }) - .get('.swh-push-menu') - .click() - .then(() => { - cy.get('body') - .should('have.class', 'sidebar-open') - .get('.nav-link > p') - .should('not.have.css', 'opacity', '0'); - }); + .click(); + cy.get('body') + .should('have.class', 'sidebar-collapse') + .get('.nav-link > p') + .should('not.be.visible'); + + cy.get('.swh-push-menu') + .click(); + cy.get('body') + .should('have.class', 'sidebar-open') + .get('.nav-link > p') + .should('be.visible'); }); it('should have less width when collapsed compared to open', function() { - let collapsedWidth, expandedWidth; + let collapseWidth; cy.get('.swh-push-menu') .click() - .wait(250) .get('.swh-sidebar') - .should('have.css', 'width') + .wait(250) + .invoke('width') .then((width) => { - collapsedWidth = parseInt(width); + collapseWidth = width; }) .get('.swh-push-menu') .click() - .wait(250) .get('.swh-sidebar') - .should('have.css', 'width') - .then((width) => { - expandedWidth = parseInt(width); - }) - .then(() => { - assert.isBelow(collapsedWidth, expandedWidth); + .wait(250) + .invoke('width') + .then(openWidth => { + assert.isBelow(collapseWidth, openWidth); }); }); }); @@ -73,12 +67,10 @@ it('should toggle sidebar when swh-push-menu is clicked', function() { cy.get('.swh-push-menu') .click() - .wait(250) .get('.swh-sidebar') .should('be.visible') .get('#sidebar-overlay') .click({force: true}) - .wait(250) .get('.swh-sidebar') .should('not.be.visible'); });