diff --git a/README.md b/README.md index 8093a47..45d1857 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ a codemeta.json file This tool was initially prepared for the [FORCE19 Hackathon](https://github.com/force11/force11-rda-scidwg/tree/master/hackathon/FORCE2019). +**NB:** codemeta v2.0 is generated by default, but v3.0 (v2.0 compatible) can be generated via a dedicated button. ## Code contributions. @@ -61,8 +62,7 @@ Chromium/Google Chrome, Edge, Safari). Check [Caniuse](https://caniuse.com/) for availability of features for these browsers. To keep the architecture simple, we serve javascript files directly to -browsers, without a compiler or transpiler; and do not use third-party -dependencies for now. +browsers, without a compiler or transpiler. ### Running local changes diff --git a/cypress/integration/basics.js b/cypress/integration/basics.js index 4e1e575..2cfd994 100644 --- a/cypress/integration/basics.js +++ b/cypress/integration/basics.js @@ -264,4 +264,101 @@ describe('JSON Import', function() { cy.get('#name').should('have.value', 'My Test Software'); }); + it('imports properties introduced in codemeta v3.0', function() { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "continuousIntegration": "https://test-ci.org/my-software", + "isSourceCodeOf": "Bigger Application", + "review": { + "type": "Review", + "reviewAspect": "Some software aspect", + "reviewBody": "Some review" + } + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contIntegration').should('have.value', 'https://test-ci.org/my-software'); + cy.get('#isSourceCodeOf').should('have.value', 'Bigger Application'); + cy.get('#reviewAspect').should('have.value', 'Some software aspect'); + cy.get('#reviewBody').should('have.value', 'Some review'); + }); + + it('imports codemeta v2.0 properties from document with v3.0 context', function() { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "codemeta:contIntegration": { + "id": "https://test-ci.org/my-software" + } + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contIntegration').should('have.value', 'https://test-ci.org/my-software'); + }); + + it('imports codemeta v3.0 properties from document with v2.0 context', function() { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "codemeta:continuousIntegration": { + "id": "https://test-ci.org/my-software" + }, + "codemeta:isSourceCodeOf": { + "id": "Bigger Application" + }, + "schema:review": { + "type": "schema:Review", + "schema:reviewAspect": "Some software aspect", + "schema:reviewBody": "Some review" + } + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contIntegration').should('have.value', 'https://test-ci.org/my-software'); + cy.get('#isSourceCodeOf').should('have.value', 'Bigger Application'); + cy.get('#reviewAspect').should('have.value', 'Some software aspect'); + cy.get('#reviewBody').should('have.value', 'Some review'); + }); + + it('imports newest version property when it is duplicate in multiple version context', function() { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "contIntegration": "https://test-ci1.org/my-software", + "codemeta:continuousIntegration": { + "id": "https://test-ci2.org/my-software" + }, + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contIntegration').should('have.value', 'https://test-ci2.org/my-software'); + + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://doi.org/10.5063/schema/codemeta-3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "continuousIntegration": "https://test-ci1.org/my-software", + "codemeta:contIntegration": { + "id": "https://test-ci2.org/my-software" + }, + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#contIntegration').should('have.value', 'https://test-ci1.org/my-software'); + }); }); diff --git a/cypress/integration/persons.js b/cypress/integration/persons.js index 7516167..b3b68ce 100644 --- a/cypress/integration/persons.js +++ b/cypress/integration/persons.js @@ -108,7 +108,7 @@ describe('One full author', function() { }); }); - it('can be imported', function() { + it('can be imported even if there is also a role-less author', function() { cy.get('#codemetaText').then((elem) => elem.text(JSON.stringify({ "@context": "https://doi.org/10.5063/schema/codemeta-2.0", @@ -578,7 +578,82 @@ describe('One author with a role', function () { }); it('can be imported', function () { - // TODO + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "author": [ + { + "type": "Person", + "givenName": "Jane" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Jane" + }, + "roleName": "Developer", + "startDate": "2024-03-04", + "endDate": "2024-04-03" + } + ] + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#author_nb').should('have.value', '1'); + cy.get('#author_1_givenName').should('have.value', 'Jane'); + cy.get('#author_1_roleName_0').should('have.value', 'Developer'); + cy.get('#author_1_startDate_0').should('have.value', '2024-03-04'); + cy.get('#author_1_endDate_0').should('have.value', '2024-04-03'); + }); + + it('can be imported when there is a second one, and they are merged', function () { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "author": [ + { + "type": "Person", + "givenName": "Jane" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Jane" + }, + "roleName": "Maintainer", + "startDate": "2024-04-04", + "endDate": "2024-05-05" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Jane" + }, + "roleName": "Developer", + "startDate": "2024-03-04", + "endDate": "2024-04-03" + } + ] + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#author_nb').should('have.value', '1'); + cy.get('#author_1_givenName').should('have.value', 'Jane'); + cy.get('#author_1_roleName_0').should('have.value', 'Maintainer'); + cy.get('#author_1_startDate_0').should('have.value', '2024-04-04'); + cy.get('#author_1_endDate_0').should('have.value', '2024-05-05'); + cy.get('#author_1_roleName_1').should('have.value', 'Developer'); + cy.get('#author_1_startDate_1').should('have.value', '2024-03-04'); + cy.get('#author_1_endDate_1').should('have.value', '2024-04-03'); }); }); @@ -683,4 +758,93 @@ describe('Multiple authors', function () { ] }); }); + + it('who both have roles can be imported', function () { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "author": [ + { + "type": "Person", + "givenName": "Jane" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Jane" + }, + "roleName": "Developer", + "startDate": "2024-03-04", + "endDate": "2024-04-03" + }, + { + "type": "Person", + "givenName": "Joe" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Joe" + }, + "roleName": "Maintainer", + "startDate": "2024-04-04", + "endDate": "2024-05-05" + } + ] + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#author_nb').should('have.value', '2'); + cy.get('#author_1_givenName').should('have.value', 'Jane'); + cy.get('#author_1_roleName_0').should('have.value', 'Developer'); + cy.get('#author_1_startDate_0').should('have.value', '2024-03-04'); + cy.get('#author_1_endDate_0').should('have.value', '2024-04-03'); + cy.get('#author_2_givenName').should('have.value', 'Joe'); + cy.get('#author_2_roleName_0').should('have.value', 'Maintainer'); + cy.get('#author_2_startDate_0').should('have.value', '2024-04-04'); + cy.get('#author_2_endDate_0').should('have.value', '2024-05-05'); + }); + + it('whose one has a role and the other not can be imported', function () { + cy.get('#codemetaText').then((elem) => + elem.text(JSON.stringify({ + "@context": "https://w3id.org/codemeta/3.0", + "type": "SoftwareSourceCode", + "name": "My Test Software", + "author": [ + { + "type": "Person", + "givenName": "Jane" + }, + { + "type": "Role", + "schema:author": { + "type": "Person", + "givenName": "Jane" + }, + "roleName": "Developer", + "startDate": "2024-03-04", + "endDate": "2024-04-03" + }, + { + "type": "Person", + "givenName": "Joe" + } + ] + })) + ); + cy.get('#importCodemeta').click(); + + cy.get('#author_nb').should('have.value', '2'); + cy.get('#author_1_givenName').should('have.value', 'Jane'); + cy.get('#author_1_roleName_0').should('have.value', 'Developer'); + cy.get('#author_1_startDate_0').should('have.value', '2024-03-04'); + cy.get('#author_1_endDate_0').should('have.value', '2024-04-03'); + cy.get('#author_2_givenName').should('have.value', 'Joe'); + }); }); diff --git a/index.html b/index.html index 3af9815..cda6dc8 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@