diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index da18d935..00000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} \ No newline at end of file diff --git a/cypress/integration/directory.spec.js b/cypress/integration/directory.spec.js index fd1423a7..ffdc5b75 100644 --- a/cypress/integration/directory.spec.js +++ b/cypress/integration/directory.spec.js @@ -1,79 +1,79 @@ /** * 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 */ -import {httpGetJson} from './utils'; +import {httpGetJson} from '../utils'; const url = 'browse/origin/https://github.com/memononen/libtess2/directory/'; const $ = Cypress.$; let dirs, files; describe('Directory Tests', function() { before(function() { cy.visit(url); cy.window().then(async win => { const metadata = win.swh.webapp.getBrowsedSwhObjectMetadata(); const apiUrl = Cypress.config().baseUrl + '/api/1/directory/' + metadata.directory; let dirContent = await httpGetJson(apiUrl); files = []; dirs = []; for (let entry of dirContent) { if (entry.type === 'file') { files.push(entry); } else { dirs.push(entry); } } }); }); beforeEach(function() { cy.visit(url); }); it('should display all files and directories', function() { cy.get('.swh-directory') .should('have.length', dirs.length) .and('be.visible'); cy.get('.swh-content') .should('have.length', files.length) .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', url + dirs[0]['name']); cy.get('.swh-directory-table') .should('be.visible'); }); }); diff --git a/cypress/integration/utils.js b/cypress/integration/utils.js deleted file mode 100644 index 7ce558a8..00000000 --- a/cypress/integration/utils.js +++ /dev/null @@ -1,6 +0,0 @@ -import axios from 'axios'; - -export async function httpGetJson(url) { - const response = await axios.get(url); - return response.data; -} diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index fc9a0768..fd170fba 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -1,14 +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) => {}; +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config +} diff --git a/cypress/support/commands.js b/cypress/support/commands.js deleted file mode 100644 index c1f5a772..00000000 --- a/cypress/support/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add("login", (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This is will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js index 4f92074b..1d5c6baf 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -1,24 +1,10 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; - -// Alternatively you can use CommonJS syntax: -// require('./commands') +/** + * 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 + */ Cypress.Screenshot.defaults({ screenshotOnRunFailure: false }); diff --git a/cypress/utils/index.js b/cypress/utils/index.js new file mode 100644 index 00000000..7e61a532 --- /dev/null +++ b/cypress/utils/index.js @@ -0,0 +1,13 @@ +/** + * 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 + */ + +import axios from 'axios'; + +export async function httpGetJson(url) { + const response = await axios.get(url); + return response.data; +}