Skip to content

Commit 2a425c8

Browse files
committed
pkp/pkp-lib#7191 Adapt content creation tests for new submission wizard
1 parent fd349c4 commit 2a425c8

19 files changed

+1114
-382
lines changed

cypress.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"contextAcronyms": {
1212
"en_US": "PKP"
1313
},
14-
"defaultGenre": "Book Manuscript"
14+
"defaultGenre": "Book Manuscript",
15+
"authorUserGroupId": 13,
16+
"volumeEditorUserGroupId": 14
1517
},
1618
"integrationFolder": "cypress/tests",
1719
"pluginsFile": "lib/pkp/cypress/plugins/index.js",

cypress/support/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Cypress.Commands.add('createSubmissionWithApi', (data, csrfToken) => {
7878
cy.get('.pkpButton--isPrimary').click();
7979
cy.get('.pkpSteps__step__label--current span:contains("3")');
8080
})
81-
.addChapters(data.chapters)
82-
.addSubmissionAuthorsWithApi(api, data, csrfToken);
81+
.addSubmissionAuthorsWithApi(api, data, csrfToken)
82+
.addChapters(data.chapters);
8383
});
8484

8585

cypress/tests/data/50-CreateSeries.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ describe('Data suite tests', function() {
3535
cy.get('a[id^=component-grid-settings-series-seriesgrid-addSeries-button-]').click();
3636
cy.wait(1000); // Avoid occasional failure due to form init taking time
3737
cy.get('input[id^="title-en_US-"]').type('History');
38+
cy.get('label').contains('Daniel Barnes').click();
3839
cy.get('input[id^="path"]').type('his');
3940
cy.get('form[id=seriesForm]').contains('Save').click();
4041

4142
// Create a new "Education" series
4243
cy.get('a[id^=component-grid-settings-series-seriesgrid-addSeries-button-]').click();
4344
cy.wait(1000); // Avoid occasional failure due to form init taking time
4445
cy.get('input[id^="title-en_US-"]').type('Education');
46+
cy.get('label').contains('Daniel Barnes').click();
4547
cy.get('input[id^="path"]').type('ed');
4648
cy.get('form[id=seriesForm]').contains('Save').click();
4749

4850
// Create a new "Psychology" series
4951
cy.get('a[id^=component-grid-settings-series-seriesgrid-addSeries-button-]').click();
5052
cy.wait(1000); // Avoid occasional failure due to form init taking time
5153
cy.get('input[id^="title-en_US-"]').type('Psychology');
54+
cy.get('label').contains('Daniel Barnes').click();
5255
cy.get('input[id^="path"]').type('psy');
5356
cy.get('form[id=seriesForm]').contains('Save').click();
5457
});

cypress/tests/data/60-content/AclarkSubmission.spec.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ describe('Data suite tests', function() {
2525
authorNames: ['Arthur Clark'],
2626
sectionId: 1,
2727
assignedAuthorNames: ['Arthur Clark'],
28-
authors: [
29-
{
30-
givenName: 'Arthur',
31-
familyName: 'Clark',
32-
33-
country: 'Canada',
34-
affiliation: 'University of Calgary'
35-
}
36-
],
3728
files: [
3829
{
3930
'file': 'dummy.pdf',
@@ -84,19 +75,13 @@ describe('Data suite tests', function() {
8475
'country': 'Canada'
8576
});
8677

87-
// Go to page where CSRF token is available
88-
cy.visit('/index.php/publicknowledge/user/profile');
89-
90-
let csrfToken = '';
78+
cy.getCsrfToken();
9179
cy.window()
92-
.then((win) => {
93-
csrfToken = win.pkp.currentUser.csrfToken;
94-
})
9580
.then(() => {
96-
return cy.createSubmissionWithApi(submission, csrfToken);
81+
return cy.createSubmissionWithApi(submission, this.csrfToken);
9782
})
9883
.then(xhr => {
99-
return cy.submitSubmissionWithApi(submission.id, csrfToken);
84+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
10085
});
10186
cy.logout();
10287

cypress/tests/data/60-content/BbarnetsonSubmission.spec.js

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,46 +11,100 @@
1111
*/
1212

1313
describe('Data suite tests', function() {
14-
it('Create a submission', function() {
15-
cy.register({
16-
'username': 'bbarnetson',
17-
'givenName': 'Bob',
18-
'familyName': 'Barnetson',
19-
'affiliation': 'Athabasca University',
20-
'country': 'Canada'
21-
});
2214

23-
cy.createSubmission({
24-
'type': 'monograph',
25-
'title': 'The Political Economy of Workplace Injury in Canada',
15+
let submission;
16+
before(function() {
17+
const title = 'The Political Economy of Workplace Injury in Canada';
18+
submission = {
19+
id: 0,
20+
prefix: '',
21+
title: title,
22+
subtitle: '',
2623
'abstract': 'Workplace injuries are common, avoidable, and unacceptable. The Political Economy of Workplace Injury in Canada reveals how employers and governments engage in ineffective injury prevention efforts, intervening only when necessary to maintain the standard legitimacy. Dr. Bob Barnetson sheds light on this faulty system, highlighting the way in which employers create dangerous work environments yet pour billions of dollars into compensation and treatment. Examining this dynamic clarifies the way in which production costs are passed on to workers in the form of workplace injuries.',
2724
'keywords': [
2825
'Business & Economics',
2926
'Political & International Studies',
3027
],
28+
'type': 'monograph',
3129
'submitterRole': 'Author',
3230
'chapters': [
3331
{
3432
'title': 'Introduction',
3533
'contributors': ['Bob Barnetson'],
34+
files: ['chapter1.pdf']
3635
},
3736
{
3837
'title': 'Part One. Employment Relationships in Canada',
3938
'contributors': ['Bob Barnetson'],
39+
files: ['chapter2.pdf']
4040
},
4141
{
4242
'title': 'Part Two. Preventing Workplace Injury',
4343
'contributors': ['Bob Barnetson'],
44+
files: ['chapter3.pdf']
4445
},
4546
{
4647
'title': 'Part Three. Critique of OHS in Canada',
4748
'contributors': ['Bob Barnetson'],
49+
files: ['chapter4.pdf']
4850
},
4951
{
5052
'title': 'Part Four. Political Economy of Preventing Workplace Injury',
5153
'contributors': ['Bob Barnetson'],
54+
files: ['chapter5.pdf']
55+
},
56+
],
57+
files: [
58+
{
59+
'file': 'dummy.pdf',
60+
'fileName': 'chapter1.pdf',
61+
'mimeType': 'application/pdf',
62+
'genre': Cypress.env('defaultGenre')
63+
},
64+
{
65+
'file': 'dummy.pdf',
66+
'fileName': 'chapter2.pdf',
67+
'mimeType': 'application/pdf',
68+
'genre': Cypress.env('defaultGenre')
5269
},
70+
{
71+
'file': 'dummy.pdf',
72+
'fileName': 'chapter3.pdf',
73+
'mimeType': 'application/pdf',
74+
'genre': Cypress.env('defaultGenre')
75+
},
76+
{
77+
'file': 'dummy.pdf',
78+
'fileName': 'chapter4.pdf',
79+
'mimeType': 'application/pdf',
80+
'genre': Cypress.env('defaultGenre')
81+
},
82+
{
83+
'file': 'dummy.pdf',
84+
'fileName': 'chapter5.pdf',
85+
'mimeType': 'application/pdf',
86+
'genre': Cypress.env('defaultGenre')
87+
}
5388
],
89+
}
90+
});
91+
92+
it('Create a submission', function() {
93+
cy.register({
94+
'username': 'bbarnetson',
95+
'givenName': 'Bob',
96+
'familyName': 'Barnetson',
97+
'affiliation': 'Athabasca University',
98+
'country': 'Canada'
5499
});
100+
101+
cy.getCsrfToken();
102+
cy.window()
103+
.then(() => {
104+
return cy.createSubmissionWithApi(submission, this.csrfToken);
105+
})
106+
.then(xhr => {
107+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
108+
});
55109
});
56110
});

cypress/tests/data/60-content/BbeatySubmission.spec.js

Lines changed: 75 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@
1111
*/
1212

1313
describe('Data suite tests', function() {
14-
it('Create a submission', function() {
15-
cy.register({
16-
'username': 'bbeaty',
17-
'givenName': 'Bart',
18-
'familyName': 'Beaty',
19-
'affiliation': 'University of British Columbia',
20-
'country': 'Canada'
21-
});
2214

23-
var submission = {
15+
let submission;
16+
before(function() {
17+
const title = 'How Canadians Communicate: Contexts of Canadian Popular Culture';
18+
submission = {
19+
id: 0,
20+
prefix: '',
21+
title: title,
22+
subtitle: '',
2423
'type': 'editedVolume',
2524
'series': 'History',
26-
'title': 'How Canadians Communicate: Contexts of Canadian Popular Culture',
2725
'abstract': 'What does Canadian popular culture say about the construction and negotiation of Canadian national identity? This third volume of How Canadians Communicate describes the negotiation of popular culture across terrains where national identity is built by producers and audiences, government and industry, history and geography, ethnicities and citizenships.',
2826
'keywords': [
2927
'Canadian Studies',
@@ -32,55 +30,103 @@ describe('Data suite tests', function() {
3230
'submitterRole': 'Volume editor',
3331
'additionalAuthors': [
3432
{
35-
'givenName': 'Toby',
36-
'familyName': 'Miller',
37-
'country': 'Canada',
38-
'affiliation': 'University of Alberta',
33+
'givenName': {en_US: 'Toby'},
34+
'familyName': {en_US: 'Miller'},
35+
'country': 'CA',
36+
'affiliation': {en_US: 'University of Alberta'},
3937
'email': '[email protected]',
40-
'role': 'Author',
38+
userGroupId: Cypress.env('authorUserGroupId')
4139
},
4240
{
43-
'givenName': 'Ira',
44-
'familyName': 'Wagman',
45-
'country': 'Canada',
46-
'affiliation': 'Athabasca University',
41+
'givenName': {en_US: 'Ira'},
42+
'familyName': {en_US: 'Wagman'},
43+
'country': 'CA',
44+
'affiliation': {en_US: 'Athabasca University'},
4745
'email': '[email protected]',
48-
'role': 'Author',
46+
userGroupId: Cypress.env('authorUserGroupId')
4947
},
5048
{
51-
'givenName': 'Will',
52-
'familyName': 'Straw',
53-
'country': 'Canada',
54-
'affiliation': 'University of Calgary',
49+
'givenName': {en_US: 'Will'},
50+
'familyName': {en_US: 'Straw'},
51+
'country': 'CA',
52+
'affiliation': {en_US: 'University of Calgary'},
5553
'email': '[email protected]',
56-
'role': 'Author',
54+
userGroupId: Cypress.env('authorUserGroupId')
5755
},
5856
],
5957
'chapters': [
6058
{
6159
'title': 'Introduction: Contexts of Popular Culture',
6260
'contributors': ['Bart Beaty'],
61+
files: ['intro.pdf']
6362
},
6463
{
6564
'title': 'Chapter 1. A Future for Media Studies: Cultural Labour, Cultural Relations, Cultural Politics',
6665
'contributors': ['Toby Miller'],
66+
files: ['chapter1.pdf']
6767
},
6868
{
6969
'title': 'Chapter 2. Log On, Goof Off, and Look Up: Facebook and the Rhythms of Canadian Internet Use',
7070
'contributors': ['Ira Wagman'],
71+
files: ['chapter2.pdf']
7172
},
7273
{
7374
'title': 'Chapter 3. Hawkers and Public Space: Free Commuter Newspapers in Canada',
7475
'contributors': ['Will Straw'],
76+
files: ['chapter3.pdf']
77+
},
78+
],
79+
files: [
80+
{
81+
'file': 'dummy.pdf',
82+
'fileName': 'chapter1.pdf',
83+
'mimeType': 'application/pdf',
84+
'genre': Cypress.env('defaultGenre')
85+
},
86+
{
87+
'file': 'dummy.pdf',
88+
'fileName': 'chapter2.pdf',
89+
'mimeType': 'application/pdf',
90+
'genre': Cypress.env('defaultGenre')
91+
},
92+
{
93+
'file': 'dummy.pdf',
94+
'fileName': 'chapter3.pdf',
95+
'mimeType': 'application/pdf',
96+
'genre': Cypress.env('defaultGenre')
7597
},
76-
]
77-
};
78-
cy.createSubmission(submission);
98+
{
99+
'file': 'dummy.pdf',
100+
'fileName': 'intro.pdf',
101+
'mimeType': 'application/pdf',
102+
'genre': Cypress.env('defaultGenre')
103+
}
104+
],
105+
}
106+
});
107+
108+
it('Create a submission', function() {
109+
cy.register({
110+
'username': 'bbeaty',
111+
'givenName': 'Bart',
112+
'familyName': 'Beaty',
113+
'affiliation': 'University of British Columbia',
114+
'country': 'Canada'
115+
});
116+
117+
cy.getCsrfToken();
118+
cy.window()
119+
.then(() => {
120+
return cy.createSubmissionWithApi(submission, this.csrfToken);
121+
})
122+
.then(xhr => {
123+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
124+
});
79125
cy.logout();
80126

81127
cy.findSubmissionAsEditor('dbarnes', null, 'Beaty');
82128
cy.clickDecision('Send to Internal Review');
83-
cy.recordDecisionSendToReview('Send to Internal Review', ['Bart Beaty'], submission.chapters.map(chapter => chapter.title.substring(0, 35)));
129+
cy.recordDecisionSendToReview('Send to Internal Review', ['Bart Beaty'], submission.files.map(file => file.fileName));
84130
cy.isActiveStageTab('Internal Review');
85131
cy.assignReviewer('Aisla McCrae');
86132
cy.clickDecision('Send to External Review');

0 commit comments

Comments
 (0)