diff --git a/cypress/integration/sidebar.spec.js b/cypress/integration/sidebar.spec.js index d4c0741f..8cb39fc7 100644 --- a/cypress/integration/sidebar.spec.js +++ b/cypress/integration/sidebar.spec.js @@ -1,81 +1,85 @@ /** * Copyright (C) 2019 The Software Heritage developers * See the AUTHORS file at the top-level directory of this distribution * License: GNU Affero General Public License version 3, or any later version * See top-level LICENSE file for more information */ const url = '/'; describe('Sidebar tests On Large Screen', function() { beforeEach(function() { - cy.visit(url); + cy.visit(url, { + onBeforeLoad: (win) => { + win.localStorage.clear(); + } + }); }); 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'); }); }); it('should have less width when collapsed compared to open', function() { let collapsedWidth, expandedWidth; cy.get('.swh-push-menu') .click() .wait(250) .get('.swh-sidebar') .should('have.css', 'width') .then((width) => { collapsedWidth = parseInt(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); }); }); }); describe('Sidebar Tests on small screens', function() { beforeEach(function() { cy.viewport('iphone-6'); cy.visit(url); }); it('should be collapsed by default', function() { cy.get('.swh-sidebar') .should('not.be.visible'); }); 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'); }); }); diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index fd170fba..dffed253 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -1,17 +1,17 @@ // *********************************************************** // This example plugins/index.js can be used to load plugins // // You can change the location of this file or turn off loading // the plugins file with the 'pluginsFile' configuration option. // // You can read more here: // https://on.cypress.io/plugins-guide // *********************************************************** // This function is called when a project is opened or re-opened (e.g. due to // the project's config changing) module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config -} +};