Skip to content

Commit 9b4e7c2

Browse files
authored
Merge pull request #851 from citation-file-format/286-entity
Add support for entity author
2 parents 68165f4 + 3378314 commit 9b4e7c2

21 files changed

+1266
-190
lines changed

README.dev.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,18 @@ Here is the list of situations that can happen:
220220
- If the input is not valid YAML, raise an error and don't proceed.
221221
- If the input is not an object, raise an error and don't proceed. This includes vectors and strings.
222222
- Keys at root level that are not part of the `cff` object are passed to `extraCffFields`. A warning is printed, but proceed.
223-
- Keys at nested levels (e.g., authors) are ignored. A warning is printed, but proceed.
223+
- If an author is not a Person nor Entity, print the infringing fields and drop the author.
224+
- If an author does not have enough fields to check whether it is a Person or Entity (e.g., only orcid), then use Person.
225+
- Keys at nested identifiers levels are ignored. A warning is printed but proceed.
224226
- Radio values ('type' and 'identifiers/type') should be sanitized.
225227
- If an old `cff-version` was present, warn that a newer version will be used.
226228
- If no `cff-version` was found, no need to warn.
227229
- 'date-released' should be sanitized so it is a 'yyyy-mm-dd' string, and not a Javascript date.
228230
- Input validation is only done a posteriori, so don't check it during update.
229231
- Special situations (such as `cff-version` and `type` above) should be handled explicitly and documented.
230232
- If parsing is successful, give positive feedback.
233+
234+
Deprecated:
235+
236+
- Keys at nested levels (e.g., authors) are ignored. A warning is printed, but proceed.
237+
- Deprecated because the author can be a Person or Entity. So to check that, we have to decide based on the fields what to check.

cypress/e2e/errors.cy.ts

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('From a fixed app', () => {
3737
cy.dataCy('input-title')
3838
.type('A')
3939
cy.visit('/authors')
40-
cy.dataCy('btn-add-author')
40+
cy.dataCy('btn-add-person')
4141
.click()
4242
cy.visit('/finish')
4343
})
@@ -74,20 +74,20 @@ describe('From a fixed app', () => {
7474
cy.checkThatAppValidityIs(false)
7575
cy.dataCy('banner-error-messages')
7676
.should('contain.text', 'Add at least one author')
77-
cy.dataCy('btn-add-author')
77+
cy.dataCy('btn-add-person')
7878
.click()
7979
cy.checkThatAppValidityIs(true)
8080
})
8181
it('should validate duplicate authors', () => {
8282
cy.dataCy('btn-remove')
8383
.click()
84-
cy.dataCy('btn-add-author')
84+
cy.dataCy('btn-add-person')
8585
.click()
8686
cy.dataCy('input-given-names')
8787
.type('A')
8888
cy.dataCy('btn-done')
8989
.click()
90-
cy.dataCy('btn-add-author')
90+
cy.dataCy('btn-add-person')
9191
.click()
9292
cy.dataCy('input-given-names')
9393
.type('A')
@@ -104,10 +104,34 @@ describe('From a fixed app', () => {
104104
.click()
105105
cy.checkThatAppValidityIs(true)
106106
})
107-
it('should validate authors\' fields', () => {
107+
it('should validate person and entity being equal', () => {
108+
cy.dataCy('input-email')
109+
110+
cy.dataCy('input-orcid')
111+
.type('1234123412341234')
112+
cy.dataCy('btn-done')
113+
.click()
114+
cy.dataCy('btn-add-entity')
115+
.click()
116+
cy.dataCy('input-email')
117+
118+
cy.dataCy('input-orcid')
119+
.type('1234123412341234')
120+
cy.dataCy('btn-done')
121+
.click()
122+
123+
cy.dataCy('card-author0')
124+
.should('have.class', 'red-border')
125+
cy.dataCy('card-author1')
126+
.should('have.class', 'red-border')
127+
cy.checkThatAppValidityIs(false)
128+
cy.dataCy('banner-error-messages')
129+
.should('contain.text', 'There are duplicate authors')
130+
})
131+
it('should validate person\'s fields', () => {
108132
cy.dataCy('btn-remove')
109133
.click()
110-
cy.dataCy('btn-add-author')
134+
cy.dataCy('btn-add-person')
111135
.click()
112136
cy.dataCy('input-email')
113137
.type('a')
@@ -128,6 +152,65 @@ describe('From a fixed app', () => {
128152
.should('not.have.class', 'q-field--error')
129153
cy.checkThatAppValidityIs(true)
130154
})
155+
it('should validate entity\'s fields', () => {
156+
cy.dataCy('btn-remove')
157+
.click()
158+
cy.dataCy('btn-add-entity')
159+
.click()
160+
cy.dataCy('input-name')
161+
.type('Entity name')
162+
163+
const fields = [
164+
{ name: 'date-start', bad: '2021-01-0', fix: '1', checkInput: false },
165+
{ name: 'date-end', bad: '2021-01-0', fix: '1', checkInput: false },
166+
{ name: 'email', bad: 'a', fix: '@a.com', checkInput: true },
167+
{ name: 'orcid', bad: '1', fix: '234123412341234', checkInput: true }
168+
]
169+
for (const field of fields) {
170+
cy.dataCy(`input-${field.name}`)
171+
.type(field.bad)
172+
cy.checkThatInputValidityIs(false, field.name)
173+
cy.checkThatAppValidityIs(false)
174+
cy.dataCy(`input-${field.name}`)
175+
.type(field.fix)
176+
if (field.checkInput) {
177+
cy.checkThatInputValidityIs(true, field.name)
178+
} else {
179+
cy.dataCy(`input-${field.name}`)
180+
.parents('.q-field')
181+
.should('not.have.class', 'q-field--error')
182+
}
183+
cy.checkThatAppValidityIs(true)
184+
}
185+
})
186+
it('should error when it is inferrable that it is an entity without name', () => {
187+
cy.dataCy('btn-remove')
188+
.click()
189+
cy.dataCy('btn-add-entity')
190+
.click()
191+
192+
const fields = [
193+
{ name: 'date-start', value: '2021-01-01' },
194+
{ name: 'date-end', value: '2021-01-01' },
195+
{ name: 'location', value: 'Here' }
196+
]
197+
for (const field of fields) {
198+
cy.dataCy(`input-${field.name}`)
199+
.type(field.value)
200+
201+
cy.checkThatInputValidityIs(false, 'name')
202+
cy.checkThatAppValidityIs(false)
203+
cy.dataCy('input-name')
204+
.type('Fixed')
205+
cy.checkThatInputValidityIs(true, 'name')
206+
cy.checkThatAppValidityIs(true)
207+
208+
cy.dataCy('input-name')
209+
.clear()
210+
cy.dataCy(`input-${field.name}`)
211+
.clear()
212+
}
213+
})
131214
})
132215

133216
describe('On screen Identifiers', () => {

cypress/e2e/info-dialog.cy.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const infoDialogs = [
66
{
77
screen: 'authors',
88
values: ['authors', 'given-names, name-particle, family-names, name-suffix', 'email', 'affiliation', 'orcid'],
9-
before: () => { cy.dataCy('btn-add-author').click() }
9+
before: () => { cy.dataCy('btn-add-person').click() }
10+
},
11+
{
12+
screen: 'authors',
13+
values: ['authors', 'name', 'address', 'city', 'country', 'post-code', 'location', 'region', 'alias', 'email', 'date-start', 'date-end', 'tel', 'fax', 'website', 'orcid'],
14+
before: () => { cy.dataCy('btn-add-entity').click() }
1015
},
1116
{
1217
screen: 'identifiers',

cypress/e2e/navigation.cy.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('App navigation', () => {
6161
.click()
6262
cy.url()
6363
.should('include', '/authors')
64-
cy.dataCy('btn-add-author')
64+
cy.dataCy('btn-add-person')
6565
.click()
6666
cy.dataCy('btn-next')
6767
.should('not.be.disabled')
@@ -80,7 +80,7 @@ describe('App navigation', () => {
8080
cy.dataCy('input-title')
8181
.type('A')
8282
cy.visit('/authors')
83-
cy.dataCy('btn-add-author')
83+
cy.dataCy('btn-add-person')
8484
.click()
8585
cy.dataCy('btn-download')
8686
.should('not.be.disabled')
@@ -91,7 +91,7 @@ describe('App navigation', () => {
9191
cy.dataCy('input-title')
9292
.type('A')
9393
cy.visit('/authors')
94-
cy.dataCy('btn-add-author')
94+
cy.dataCy('btn-add-person')
9595
.click()
9696
cy.dataCy('btn-next')
9797
.click()
@@ -116,7 +116,7 @@ describe('App navigation', () => {
116116
cy.dataCy('input-title')
117117
.type('A')
118118
cy.visit('/authors')
119-
cy.dataCy('btn-add-author')
119+
cy.dataCy('btn-add-person')
120120
.click()
121121
})
122122
it(`should have ${stepNames.length + 1} steps on stepper`, () => {
@@ -194,7 +194,7 @@ describe('App navigation', () => {
194194
it('should be possible to move authors around', () => {
195195
cy.visit('/authors')
196196
;['A', 'B', 'C'].forEach((givenName) => {
197-
cy.dataCy('btn-add-author')
197+
cy.dataCy('btn-add-person')
198198
.click()
199199
cy.dataCy('input-given-names')
200200
.type('John')

cypress/e2e/spec.cy.ts

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ const fullValidCff = {
2020
2121
affiliation: 'UU',
2222
orcid: 'https://orcid.org/1234-1234-1234-123X'
23+
}, {
24+
address: 'Some street',
25+
alias: 'NLeSC',
26+
city: 'Amsterdam',
27+
country: 'NL',
28+
'date-end': '2022-01-01',
29+
'date-start': '2021-01-01',
30+
31+
fax: '+31 02 1234 1234',
32+
location: 'Science Park',
33+
name: 'Netherlands eScience Center',
34+
orcid: 'https://orcid.org/1234-1234-1234-1234',
35+
'post-code': '1234AM',
36+
region: 'Oost',
37+
tel: '+31 02 1234 5678',
38+
website: 'https://nlesc.org'
2339
}],
2440
identifiers: [
2541
{ type: 'doi', value: '10.1234/x', description: 'Some DOI' },
@@ -43,6 +59,8 @@ const fullValidCff = {
4359
type: 'article'
4460
}
4561
}
62+
const downloadsFolder = Cypress.config('downloadsFolder')
63+
const cfffile = `${downloadsFolder}/CITATION.cff`
4664

4765
describe('Basic usage', () => {
4866
it('is working for the minimum information', () => {
@@ -68,7 +86,7 @@ describe('Basic usage', () => {
6886

6987
// Author screen
7088
cy.url().should('include', '/authors')
71-
cy.dataCy('btn-add-author')
89+
cy.dataCy('btn-add-person')
7290
.click()
7391
cy.dataCy('btn-done')
7492
.click()
@@ -110,7 +128,7 @@ describe('Basic usage', () => {
110128

111129
// Author screen
112130
cy.url().should('include', '/authors')
113-
cy.dataCy('btn-add-author')
131+
cy.dataCy('btn-add-person')
114132
.click()
115133
cy.dataCy('input-given-names')
116134
.type('John')
@@ -128,6 +146,44 @@ describe('Basic usage', () => {
128146
.type('123412341234123X')
129147
cy.dataCy('btn-done')
130148
.click()
149+
cy.dataCy('btn-add-entity')
150+
.click()
151+
cy.dataCy('input-name')
152+
.type('Netherlands eScience Center')
153+
cy.dataCy('input-address')
154+
.type('Some street')
155+
cy.dataCy('input-city')
156+
.type('Amsterdam')
157+
158+
cy.dataCy('select-country')
159+
.first()
160+
.type('NL')
161+
.click()
162+
.get('.q-item__label')
163+
.eq(0)
164+
.click()
165+
cy.dataCy('input-post-code')
166+
.type('1234AM')
167+
cy.dataCy('input-location')
168+
.type('Science Park')
169+
cy.dataCy('input-region')
170+
.type('Oost')
171+
cy.dataCy('input-alias')
172+
.type('NLeSC')
173+
cy.dataCy('input-email')
174+
175+
cy.dataCy('input-date-start')
176+
.type('2021-01-01')
177+
cy.dataCy('input-date-end')
178+
.type('2022-01-01')
179+
cy.dataCy('input-tel')
180+
.type('+31 02 1234 5678')
181+
cy.dataCy('input-fax')
182+
.type('+31 02 1234 1234')
183+
cy.dataCy('input-website')
184+
.type('https://nlesc.org')
185+
cy.dataCy('input-orcid')
186+
.type('1234123412341234')
131187
cy.dataCy('btn-next')
132188
.click()
133189

@@ -242,9 +298,6 @@ describe('Basic usage', () => {
242298
cy.dataCy('btn-download')
243299
.click()
244300

245-
const downloadsFolder = Cypress.config('downloadsFolder')
246-
const cfffile = `${downloadsFolder}/CITATION.cff`
247-
248301
cy.readFile(cfffile, 'binary', { timeout: 400 })
249302
.then((str) => {
250303
expect(yaml.load(str)).to.deep.equal(fullValidCff)

cypress/e2e/specific.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('Issue 637 - ORCID freeze', () => {
22
it('should work when writing a full ORCID with dashes', () => {
33
cy.visit('/authors')
4-
cy.dataCy('btn-add-author')
4+
cy.dataCy('btn-add-person')
55
.click()
66
cy.dataCy('input-orcid')
77
.type('1234-1234-1234-1234')

cypress/e2e/yaml-examples/bad-authors.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ message: >-
66
type: software
77
authors:
88
- given-names: John
9-
family-name: Doe
9+
family-names: Doe
10+
- name: Bad
11+
given-names: Bad

cypress/e2e/yaml-examples/passing-full.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ authors:
1010
1111
affiliation: UU
1212
orcid: 'https://orcid.org/1234-1234-1234-123X'
13+
- address: Some street
14+
alias: NLeSC
15+
city: Amsterdam
16+
country: NL
17+
date-end: '2022-01-01'
18+
date-start: '2021-01-01'
19+
20+
fax: +31 02 1234 1234
21+
location: Science Park
22+
name: Netherlands eScience Center
23+
orcid: 'https://orcid.org/1234-1234-1234-1234'
24+
post-code: 1234AM
25+
region: Oost
26+
tel: +31 02 1234 5678
27+
website: 'https://nlesc.org'
1328
identifiers:
1429
- type: doi
1530
value: 10.1234/x
@@ -37,8 +52,8 @@ commit: '123'
3752
version: v1.2.3
3853
date-released: '2022-01-01'
3954
preferred-citation:
40-
- authors:
41-
- given-names: John
42-
family-names: Doe
43-
title: My Paper
44-
type: article
55+
authors:
56+
- given-names: John
57+
family-names: Doe
58+
title: My Paper
59+
type: article
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Property 'family-name: Doe' inside 'authors' was ignored. Check if the key is correct.
1+
Could not add author. It is not a Person due to fields name and not an Entity due to fields given-names. Skipping

0 commit comments

Comments
 (0)