diff --git a/cypress/integration/directory.spec.js b/cypress/integration/directory.spec.js new file mode 100644 --- /dev/null +++ b/cypress/integration/directory.spec.js @@ -0,0 +1,60 @@ +/** + * 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 = 'browse/origin/https://github.com/memononen/libtess2/directory/'; +const numContent = 5; +const numDirectory = 5; +const firstSubDirectory = 'browse/origin/https://github.com/memononen/libtess2/directory/Bin/'; + +const $ = Cypress.$; + +describe('Directory Tests', function() { + beforeEach(function () { + cy.visit(url); + }) + + it('should display all files and directories', function() { + cy.get('.swh-directory') + .should('have.length', numDirectory) + .and('be.visible'); + cy.get('.swh-content') + .should('have.length', numContent) + .and('be.visible'); + }) + + it('should display sizes for files', function() { + cy.get('.swh-content') + .parent('tr') + .then((rows) => { + for(let row of rows) { + let text = $(row).children('td').eq(2).text(); + expect(text.trim()).to.not.be.empty; + } + }) + }) + + it('should display readme when it is present', function() { + cy.get('#readme-panel > .card-body') + .should('be.visible') + .and('have.class', 'swh-showdown') + .and('not.be.empty') + .and('not.contain', 'Readme bytes are not available'); + }) + + it('should open subdirectory when clicked', function() { + cy.get('.swh-directory') + .first() + .children('a') + .click(); + + cy.url() + .should('include', firstSubDirectory); + + cy.get('.swh-directory-table') + .should('exist'); + }) +}) \ No newline at end of file