diff --git a/cypress/integration/basics.js b/cypress/integration/basics.js index fdee230..b6cf0e6 100644 --- a/cypress/integration/basics.js +++ b/cypress/integration/basics.js @@ -1,30 +1,62 @@ /** * Copyright (C) 2020 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 */ /* * Tests the basic features of the application. */ "use strict"; describe('JSON Generation', function() { - it('works just from the software name', function() { + beforeEach(function() { + /* Clear the session storage, as it is used to restore field data; + * and we don't want a test to load data from the previous test. */ + cy.window().then((win) => { + win.sessionStorage.clear() + }) cy.visit('./index.html'); + }); + + it('works just from the software name', function() { cy.get('#name').type('My Test Software'); cy.get('#generateCodemeta').click(); + cy.get('#errorMessage').should('have.text', ''); cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) .should('deep.equal', { "@context": "https://doi.org/10.5063/schema/codemeta-2.0", "@type": "SoftwareSourceCode", "license": "https://spdx.org/licenses/undefined", "name": "My Test Software", "author": [], "contributor": [] - }) - }) -}) + }); + }); + + it('works just from all main fields', function() { + cy.get('#name').type('My Test Software'); + cy.get('#description').type('This is a\ngreat piece of software'); + cy.get('#dateCreated').type('2019-10-02'); + cy.get('#datePublished').type('2020-01-01'); + cy.get('#license').clear().type('AGPL-3.0'); + cy.get('#generateCodemeta').click(); + + cy.get('#errorMessage').should('have.text', ''); + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) + .should('deep.equal', { + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "@type": "SoftwareSourceCode", + "license": "https://spdx.org/licenses/AGPL-3.0", + "dateCreated": "2019-10-02", + "datePublished": "2020-01-01", + "name": "My Test Software", + "description": "This is a\ngreat piece of software", + "author": [], + "contributor": [] + }); + }); +});