Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/directory.spec.js
/** | /** | ||||
* Copyright (C) 2019 The Software Heritage developers | * Copyright (C) 2019 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import {httpGetJson} from '../utils'; | import {httpGetJson} from '../utils'; | ||||
const origin = 'https://github.com/memononen/libtess2'; | |||||
const $ = Cypress.$; | const $ = Cypress.$; | ||||
let url, dirs, files; | let origin; | ||||
describe('Directory Tests', function() { | let url; | ||||
let dirs = []; | |||||
let files = []; | |||||
describe('Directory Tests', function() { | |||||
before(function() { | before(function() { | ||||
url = this.Urls.browse_origin_directory(origin); | origin = this.origin[0]; | ||||
cy.visit(url).window().then(async win => { | |||||
const metadata = win.swh.webapp.getBrowsedSwhObjectMetadata(); | url = this.Urls.browse_origin_directory(origin.url); | ||||
const apiUrl = Cypress.config().baseUrl + this.Urls.api_1_directory(metadata.directory); | |||||
let dirContent = await httpGetJson(apiUrl); | for (let entry of origin.dirContent) { | ||||
files = []; | |||||
dirs = []; | |||||
for (let entry of dirContent) { | |||||
if (entry.type === 'file') { | if (entry.type === 'file') { | ||||
files.push(entry); | files.push(entry); | ||||
} else { | } else { | ||||
dirs.push(entry); | dirs.push(entry); | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
}); | |||||
beforeEach(function() { | beforeEach(function() { | ||||
cy.visit(url); | cy.visit(url); | ||||
}); | }); | ||||
it('should display all files and directories', function() { | it('should display all files and directories', function() { | ||||
cy.get('.swh-directory') | cy.get('.swh-directory') | ||||
.should('have.length', dirs.length) | .should('have.length', dirs.length) | ||||
Show All 38 Lines |