|
1 | 1 | /**
|
2 |
| - * Copyright (C) 2020 The Software Heritage developers |
| 2 | + * Copyright (C) 2020-2024 The Software Heritage developers |
3 | 3 | * See the AUTHORS file at the top-level directory of this distribution
|
4 | 4 | * License: GNU Affero General Public License version 3, or any later version
|
5 | 5 | * See top-level LICENSE file for more information
|
|
10 | 10 | */
|
11 | 11 |
|
12 | 12 | "use strict";
|
| 13 | + |
13 | 14 | describe('Funder id', function() {
|
14 | 15 | it('can be exported', function() {
|
15 | 16 | cy.get('#name').type('My Test Software');
|
@@ -88,3 +89,91 @@ describe('Funder name', function() {
|
88 | 89 | });
|
89 | 90 | });
|
90 | 91 |
|
| 92 | +describe('Software requirements', function() { |
| 93 | + it('can be exported as multiple values', function() { |
| 94 | + cy.get('#name').type('My Test Software'); |
| 95 | + |
| 96 | + cy.get('#softwareRequirements').type('https://www.gtk.org\nhttps://github.com/anholt/libepoxy\nhttps://github.com/GNOME/libxml2'); |
| 97 | + |
| 98 | + cy.get('#generateCodemetaV2').click(); |
| 99 | + |
| 100 | + cy.get('#errorMessage').should('have.text', ''); |
| 101 | + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) |
| 102 | + .should('deep.equal', { |
| 103 | + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", |
| 104 | + "type": "SoftwareSourceCode", |
| 105 | + "name": "My Test Software", |
| 106 | + "softwareRequirements": [ |
| 107 | + "https://www.gtk.org", |
| 108 | + "https://github.com/anholt/libepoxy", |
| 109 | + "https://github.com/GNOME/libxml2", |
| 110 | + ] |
| 111 | + }); |
| 112 | + }); |
| 113 | + |
| 114 | + it('can be imported from multiple values', function() { |
| 115 | + cy.get('#codemetaText').then((elem) => |
| 116 | + elem.text(JSON.stringify({ |
| 117 | + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", |
| 118 | + "@type": "SoftwareSourceCode", |
| 119 | + "name": "My Test Software", |
| 120 | + "softwareRequirements": [ |
| 121 | + "https://www.gtk.org", |
| 122 | + "https://github.com/anholt/libepoxy", |
| 123 | + "https://github.com/GNOME/libxml2", |
| 124 | + ] |
| 125 | + })) |
| 126 | + ); |
| 127 | + cy.get('#importCodemeta').click(); |
| 128 | + |
| 129 | + cy.get('#softwareRequirements').should('have.value', 'https://www.gtk.org\nhttps://github.com/anholt/libepoxy\nhttps://github.com/GNOME/libxml2'); |
| 130 | + }); |
| 131 | + |
| 132 | + it('can be exported to a single URI', function() { |
| 133 | + cy.get('#name').type('My Test Software'); |
| 134 | + |
| 135 | + cy.get('#softwareRequirements').type('https://github.com/GNOME/libxml2'); |
| 136 | + |
| 137 | + cy.get('#generateCodemetaV2').click(); |
| 138 | + |
| 139 | + cy.get('#errorMessage').should('have.text', ''); |
| 140 | + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) |
| 141 | + .should('deep.equal', { |
| 142 | + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", |
| 143 | + "type": "SoftwareSourceCode", |
| 144 | + "name": "My Test Software", |
| 145 | + "softwareRequirements": "https://github.com/GNOME/libxml2", |
| 146 | + }); |
| 147 | + }); |
| 148 | + |
| 149 | + it('can be imported from a single URI', function() { |
| 150 | + cy.get('#codemetaText').then((elem) => |
| 151 | + elem.text(JSON.stringify({ |
| 152 | + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", |
| 153 | + "@type": "SoftwareSourceCode", |
| 154 | + "name": "My Test Software", |
| 155 | + "softwareRequirements": "https://github.com/GNOME/libxml2", |
| 156 | + })) |
| 157 | + ); |
| 158 | + cy.get('#importCodemeta').click(); |
| 159 | + |
| 160 | + cy.get('#softwareRequirements').should('have.value', 'https://github.com/GNOME/libxml2'); |
| 161 | + }); |
| 162 | + |
| 163 | + it('cannot be exported as text', function() { |
| 164 | + cy.get('#name').type('My Test Software'); |
| 165 | + |
| 166 | + cy.get('#softwareRequirements').type('libxml2'); |
| 167 | + |
| 168 | + cy.get('#generateCodemetaV2').click(); |
| 169 | + |
| 170 | + cy.get('#errorMessage').should('have.text', 'Invalid URL in field "softwareRequirements": "libxml2"'); |
| 171 | + cy.get('#codemetaText').then((elem) => JSON.parse(elem.text())) |
| 172 | + .should('deep.equal', { |
| 173 | + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", |
| 174 | + "type": "SoftwareSourceCode", |
| 175 | + "name": "My Test Software", |
| 176 | + "softwareRequirements": [], |
| 177 | + }); |
| 178 | + }); |
| 179 | +}); |
0 commit comments