From 29f932f9e589757dc7285861c8af0325748f5f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9l=C3=A8ne=20MJ?= <20780121+hjonin@users.noreply.github.com> Date: Mon, 13 May 2024 17:03:38 +0200 Subject: [PATCH] Add contributor test (#49) --- cypress/integration/persons.js | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/cypress/integration/persons.js b/cypress/integration/persons.js index daad8ca..d5a4b41 100644 --- a/cypress/integration/persons.js +++ b/cypress/integration/persons.js @@ -890,3 +890,98 @@ describe('Multiple authors', function () { cy.get('#author_2_givenName').should('have.value', 'Joe'); }); }); + +describe('Contributors', function () { + it('are exported as an object when unique', function () { + cy.get('#name').type('My Test Software'); + + cy.get('#contributor_add').click(); + cy.get('#contributor_1_givenName').type('Jane'); + + cy.get('#generateCodemetaV3').click(); + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) + .should('deep.equal', { + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "contributor": { + "id": "_:contributor_1", + "type": "Person", + "givenName": "Jane" + } + }); + }); + + it('are exported as an array when multiple', function () { + cy.get('#name').type('My Test Software'); + + cy.get('#contributor_add').click(); + cy.get('#contributor_1_givenName').type('Jane'); + + cy.get('#contributor_add').click(); + cy.get('#contributor_2_givenName').type('Joe'); + + cy.get('#generateCodemetaV3').click(); + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) + .should('deep.equal', { + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "contributor": [ + { + "id": "_:contributor_1", + "type": "Person", + "givenName": "Jane" + }, + { + "id": "_:contributor_2", + "type": "Person", + "givenName": "Joe" + } + ] + }); + }); + + it('can be imported when unique', function () { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "contributor": { + "type": "Person", + "givenName": "Jane" + } + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contributor_nb').should('have.value', '1'); + cy.get('#contributor_1_givenName').should('have.value', 'Jane'); + }); + + it('can be imported when multiple', function () { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "contributor": [ + { + "type": "Person", + "givenName": "Jane" + }, + { + "type": "Person", + "givenName": "Joe" + } + ] + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contributor_nb').should('have.value', '2'); + cy.get('#contributor_1_givenName').should('have.value', 'Jane'); + cy.get('#contributor_2_givenName').should('have.value', 'Joe'); + }); +});