Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codemeta v3.0 - import #40

Merged
merged 8 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down
68 changes: 68 additions & 0 deletions cypress/integration/basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ describe('JSON Import', function() {
it('works with expanded document version', function () {
cy.get('#codemetaText').then((elem) =>
elem.text(JSON.stringify({
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
hjonin marked this conversation as resolved.
Show resolved Hide resolved
"http://schema.org/name": [
{
"@value": "My Test Software"
Expand Down Expand Up @@ -264,4 +265,71 @@ 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",
"continuousIntegration": "https://test-ci.org/my-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');
});
hjonin marked this conversation as resolved.
Show resolved Hide resolved

it('works for codemeta v3.0 terms in v2.0 version, and does not work for new terms', 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-ci.org/my-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', '');
cy.get('#reviewAspect').should('have.value', '');
cy.get('#reviewBody').should('have.value', '');
});
hjonin marked this conversation as resolved.
Show resolved Hide resolved
});
166 changes: 165 additions & 1 deletion cypress/integration/persons.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,82 @@ describe('One author with a role', function () {
});

it('can be imported', function () {
hjonin marked this conversation as resolved.
Show resolved Hide resolved
// 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('and second one for the same author can be imported (and they are merged)', function () {
hjonin marked this conversation as resolved.
Show resolved Hide resolved
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');
Comment on lines +649 to +656
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat

});
});

Expand Down Expand Up @@ -683,4 +758,93 @@ describe('Multiple authors', function () {
]
});
});

it('who both have roles can be imported', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('who both have roles can be imported', function () {
it('can be imported', function () {

ditto (or probably move it to a new describe('One author with a role', function () { block)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand about this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nevermind, it makes sense to me now

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');
});
});
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</head>
<body>
<header>
<h1>CodeMeta generator v3.0</h1><!-- Generate codemeta v2.0 by default for now, allow v3.0 generation by clicking -->
<h1>CodeMeta generator v3.0</h1>
</header>

<main>
Expand Down
Loading