Skip to content

Commit 3e94f22

Browse files
authored
Merge pull request #3 from asmecher/i7191_submission_wizard2
pkp/pkp-lib#7191 Split submission creation commands into pieces
2 parents 28fa590 + f87dcb5 commit 3e94f22

22 files changed

+738
-198
lines changed

controllers/grid/preprintGalleys/PreprintGalleyGridHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
use PKP\security\Role;
3838
use PKP\submission\GenreDAO;
3939
use PKP\submission\PKPSubmission;
40+
use APP\publication\Publication;
41+
use APP\submission\Submission;
4042

4143
class PreprintGalleyGridHandler extends GridHandler
4244
{

cypress/support/commands.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
*/
99

10+
import Api from '../../lib/pkp/cypress/support/api.js';
1011
import '../../lib/pkp/cypress/support/commands';
1112

1213
Cypress.Commands.add('addCategory', (categoryName, categoryPath) => {
@@ -24,3 +25,51 @@ Cypress.Commands.add('isInIssue', (submissionTitle, issueTitle) => {
2425
cy.get('a:contains("' + issueTitle + '")').click();
2526
cy.get('a:contains("' + submissionTitle + '")');
2627
});
28+
29+
Cypress.Commands.add('addSubmissionGalleys', (files) => {
30+
files.forEach(file => {
31+
cy.get('a:contains("Add File")').click();
32+
cy.wait(2000); // Avoid occasional failure due to form init taking time
33+
cy.get('div.pkp_modal_panel').then($modalDiv => {
34+
cy.wait(3000);
35+
$modalDiv.find('div.header:contains("Add File")');
36+
cy.get('div.pkp_modal_panel input[id^="label-"]').type('PDF', {delay: 0});
37+
cy.get('div.pkp_modal_panel button:contains("Save")').click();
38+
cy.wait(2000); // Avoid occasional failure due to form init taking time
39+
});
40+
cy.get('select[id=genreId]').select(file.genre);
41+
cy.fixture(file.file, 'base64').then(fileContent => {
42+
cy.get('input[type=file]').attachFile(
43+
{fileContent, 'filePath': file.fileName, 'mimeType': 'application/pdf', 'encoding': 'base64'}
44+
);
45+
});
46+
cy.get('#continueButton').click();
47+
cy.wait(2000);
48+
for (const field in file.metadata) {
49+
cy.get('input[id^="' + Cypress.$.escapeSelector(field) + '"]:visible,textarea[id^="' + Cypress.$.escapeSelector(field) + '"]').type(file.metadata[field], {delay: 0});
50+
cy.get('input[id^="language"').click({force: true}); // Close multilingual and datepicker pop-overs
51+
}
52+
cy.get('#continueButton').click();
53+
cy.get('#continueButton').click();
54+
});
55+
});
56+
57+
Cypress.Commands.add('createSubmissionWithApi', (data, csrfToken) => {
58+
const api = new Api(Cypress.env('baseUrl') + '/index.php/publicknowledge/api/v1');
59+
60+
return cy.beginSubmissionWithApi(api, data, csrfToken)
61+
.putMetadataWithApi(data, csrfToken)
62+
.get('@submissionId').then((submissionId) => {
63+
if (typeof data.files === 'undefined' || !data.files.length) {
64+
return;
65+
}
66+
cy.visit('/index.php/publicknowledge/submission?id=' + submissionId);
67+
68+
// Must use the UI to upload files until we upgrade Cypress
69+
// to 7.4.0 or higher.
70+
// @see https://github.com/cypress-io/cypress/issues/1647
71+
cy.addSubmissionGalleys(data.files);
72+
})
73+
.addSubmissionAuthorsWithApi(api, data, csrfToken);
74+
});
75+

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ describe('Data suite: Ccorino', function() {
2323
authorNames: ['Carla Corino'],
2424
sectionId: 1,
2525
assignedAuthorNames: ['Carla Corino'],
26-
authors: [
27-
{
28-
givenName: 'Carla',
29-
familyName: 'Corino',
30-
31-
country: 'Italy',
32-
affiliation: 'University of Bologna'
33-
}
34-
],
3526
files: [
3627
{
3728
'file': 'dummy.pdf',
@@ -52,19 +43,13 @@ describe('Data suite: Ccorino', function() {
5243
'country': 'Italy'
5344
});
5445

55-
// Go to page where CSRF token is available
56-
cy.visit('/index.php/publicknowledge/user/profile');
57-
58-
let csrfToken = '';
46+
cy.getCsrfToken();
5947
cy.window()
60-
.then((win) => {
61-
csrfToken = win.pkp.currentUser.csrfToken;
62-
})
6348
.then(() => {
64-
return cy.createSubmissionWithApi(submission, csrfToken);
49+
return cy.createSubmissionWithApi(submission, this.csrfToken);
6550
})
66-
.then(xhr => {
67-
return cy.submitSubmissionWithApi(submission.id, csrfToken);
51+
.then(() => {
52+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
6853
});
6954
});
7055
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('Data suite: Ckwantes', function() {
8686
// Upload files and set file genres
8787
cy.get('h2').contains('Upload Files');
8888
cy.get('h2').contains('Files');
89-
cy.uploadSubmissionFiles(submission.files);
89+
cy.addSubmissionGalleys(submission.files);
9090

9191
cy.get('.submissionWizard__footer button').contains('Continue').click();
9292

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

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,72 @@
77
*
88
*/
99

10-
describe('Data suite tests', function() {
11-
it('Create a submission', function() {
12-
var title = 'Computer Skill Requirements for New and Existing Teachers: Implications for Policy and Practice';
13-
cy.register({
14-
'username': 'cmontgomerie',
15-
'givenName': 'Craig',
16-
'familyName': 'Montgomerie',
17-
'affiliation': 'University of Alberta',
18-
'country': 'Canada'
19-
});
10+
describe('Data suite: Cmontgomerie', function() {
11+
12+
let submission;
2013

21-
cy.createSubmission({
22-
title,
23-
'abstract': 'The integration of technology into the classroom is a major issue in education today. Many national and provincial initiatives specify the technology skills that students must demonstrate at each grade level. The Government of the Province of Alberta in Canada, has mandated the implementation of a new curriculum which began in September of 2000, called Information and Communication Technology. This curriculum is infused within core courses and specifies what students are “expected to know, be able to do, and be like with respect to technology” (Alberta Learning, 2000). Since teachers are required to implement this new curriculum, school jurisdictions are turning to professional development strategies and hiring standards to upgrade teachers’ computer skills to meet this goal. This paper summarizes the results of a telephone survey administered to all public school jurisdictions in the Province of Alberta with a 100% response rate. We examined the computer skills that school jurisdictions require of newly hired teachers, and the support strategies employed for currently employed teachers.',
24-
'keywords': [
14+
before(function() {
15+
const title = 'Computer Skill Requirements for New and Existing Teachers: Implications for Policy and Practice';
16+
submission = {
17+
id: 0,
18+
section: 'Preprints',
19+
prefix: '',
20+
title: title,
21+
subtitle: '',
22+
abstract: 'The integration of technology into the classroom is a major issue in education today. Many national and provincial initiatives specify the technology skills that students must demonstrate at each grade level. The Government of the Province of Alberta in Canada, has mandated the implementation of a new curriculum which began in September of 2000, called Information and Communication Technology. This curriculum is infused within core courses and specifies what students are “expected to know, be able to do, and be like with respect to technology” (Alberta Learning, 2000). Since teachers are required to implement this new curriculum, school jurisdictions are turning to professional development strategies and hiring standards to upgrade teachers’ computer skills to meet this goal. This paper summarizes the results of a telephone survey administered to all public school jurisdictions in the Province of Alberta with a 100% response rate. We examined the computer skills that school jurisdictions require of newly hired teachers, and the support strategies employed for currently employed teachers.',
23+
shortAuthorString: 'Montgomerie et al.',
24+
authorNames: ['Craig Montgomerie', 'Mark Irvine'],
25+
sectionId: 1,
26+
assignedAuthorNames: ['Craig Montgomerie'],
27+
additionalAuthors: [
28+
{
29+
givenName: {en_US: 'Mark'},
30+
familyName: {en_US: 'Irvine'},
31+
country: 'CA',
32+
affiliation: {en_US: 'University of Victoria'},
33+
34+
userGroupId: Cypress.env('authorUserGroupId')
35+
}
36+
],
37+
files: [
38+
{
39+
'file': 'dummy.pdf',
40+
'fileName': title + '.pdf',
41+
'mimeType': 'application/pdf',
42+
'genre': Cypress.env('defaultGenre')
43+
},
44+
],
45+
keywords: [
2546
'Integrating Technology',
2647
'Computer Skills',
2748
'Survey',
2849
'Alberta',
2950
'National',
3051
'Provincial',
3152
'Professional Development'
32-
],
33-
'additionalAuthors': [
34-
{
35-
'givenName': 'Mark',
36-
'familyName': 'Irvine',
37-
'country': 'Canada',
38-
'affiliation': 'University of Victoria',
39-
'email': '[email protected]'
40-
}
4153
]
54+
};
55+
});
56+
57+
it('Create a submission', function() {
58+
59+
cy.register({
60+
'username': 'cmontgomerie',
61+
'givenName': 'Craig',
62+
'familyName': 'Montgomerie',
63+
'affiliation': 'University of Alberta',
64+
'country': 'Canada'
4265
});
4366

67+
cy.getCsrfToken();
68+
cy.window()
69+
.then(() => {
70+
return cy.createSubmissionWithApi(submission, this.csrfToken);
71+
})
72+
.then(xhr => {
73+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
74+
});
75+
4476
cy.logout();
4577
cy.findSubmissionAsEditor('dbarnes', null, 'Montgomerie');
4678
cy.get('.pkp_workflow_decisions button:contains("Post the preprint")').click();

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,34 @@
77
*
88
*/
99

10-
describe('Data suite tests', function() {
10+
describe('Data suite: Ddiouf', function() {
11+
let submission;
12+
13+
before(function() {
14+
const title = 'Genetic transformation of forest trees';
15+
submission = {
16+
id: 0,
17+
section: 'Preprints',
18+
prefix: '',
19+
title: title,
20+
subtitle: '',
21+
abstract: 'In this review, the recent progress on genetic transformation of forest trees were discussed. Its described also, different applications of genetic engineering for improving forest trees or understanding the mechanisms governing genes expression in woody plants.',
22+
shortAuthorString: 'Diouf',
23+
authorNames: ['Diaga Diouf'],
24+
sectionId: 1,
25+
assignedAuthorNames: ['Diaga Diouf'],
26+
files: [
27+
{
28+
'file': 'dummy.pdf',
29+
'fileName': title + '.pdf',
30+
'mimeType': 'application/pdf',
31+
'genre': Cypress.env('defaultGenre')
32+
},
33+
]
34+
};
35+
});
36+
1137
it('Create a submission', function() {
12-
var title = 'Genetic transformation of forest trees';
1338
cy.register({
1439
'username': 'ddiouf',
1540
'givenName': 'Diaga',
@@ -18,10 +43,14 @@ describe('Data suite tests', function() {
1843
'country': 'Egypt',
1944
});
2045

21-
cy.createSubmission({
22-
title,
23-
'abstract': 'In this review, the recent progress on genetic transformation of forest trees were discussed. Its described also, different applications of genetic engineering for improving forest trees or understanding the mechanisms governing genes expression in woody plants.',
24-
});
46+
cy.getCsrfToken();
47+
cy.window()
48+
.then(() => {
49+
return cy.createSubmissionWithApi(submission, this.csrfToken);
50+
})
51+
.then(xhr => {
52+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
53+
});
2554
});
2655

2756
it('Declines the submission, reverts the decline, and declines it again', function() {

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,34 @@
77
*
88
*/
99

10-
describe('Data suite tests', function() {
10+
describe('Data suite: Dphillips', function() {
11+
let submission;
12+
13+
before(function() {
14+
const title = 'Investigating the Shared Background Required for Argument: A Critique of Fogelin\'s Thesis on Deep Disagreement';
15+
submission = {
16+
id: 0,
17+
section: 'Preprints',
18+
prefix: '',
19+
title: title,
20+
subtitle: '',
21+
abstract: 'Robert Fogelin claims that interlocutors must share a framework of background beliefs and commitments in order to fruitfully pursue argument. I refute Fogelin’s claim by investigating more thoroughly the shared background required for productive argument. I find that this background consists not in any common beliefs regarding the topic at hand, but rather in certain shared pro-cedural commitments and competencies. I suggest that Fogelin and his supporters mistakenly view shared beliefs as part of the required background for productive argument because these procedural com-mitments become more difficult to uphold when people’s beliefs diverge widely regarding the topic at hand.',
22+
shortAuthorString: 'Phillips',
23+
authorNames: ['Dana Phillips'],
24+
sectionId: 1,
25+
assignedAuthorNames: ['Dana Phillips'],
26+
files: [
27+
{
28+
'file': 'dummy.pdf',
29+
'fileName': title + '.pdf',
30+
'mimeType': 'application/pdf',
31+
'genre': Cypress.env('defaultGenre')
32+
},
33+
]
34+
};
35+
});
36+
1137
it('Create a submission', function() {
12-
var title = 'Investigating the Shared Background Required for Argument: A Critique of Fogelin\'s Thesis on Deep Disagreement';
1338
cy.register({
1439
'username': 'dphillips',
1540
'givenName': 'Dana',
@@ -18,10 +43,14 @@ describe('Data suite tests', function() {
1843
'country': 'Canada',
1944
});
2045

21-
cy.createSubmission({
22-
title,
23-
'abstract': 'Robert Fogelin claims that interlocutors must share a framework of background beliefs and commitments in order to fruitfully pursue argument. I refute Fogelin’s claim by investigating more thoroughly the shared background required for productive argument. I find that this background consists not in any common beliefs regarding the topic at hand, but rather in certain shared pro-cedural commitments and competencies. I suggest that Fogelin and his supporters mistakenly view shared beliefs as part of the required background for productive argument because these procedural com-mitments become more difficult to uphold when people’s beliefs diverge widely regarding the topic at hand.',
24-
});
46+
cy.getCsrfToken();
47+
cy.window()
48+
.then(() => {
49+
return cy.createSubmissionWithApi(submission, this.csrfToken);
50+
})
51+
.then(xhr => {
52+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
53+
});
2554

2655
cy.logout();
2756
cy.findSubmissionAsEditor('dbarnes', null, 'Phillips');

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

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,37 @@
77
*
88
*/
99

10-
describe('Data suite tests', function() {
10+
describe('Data suite: Dsokoloff', function() {
11+
let submission;
12+
13+
before(function() {
14+
const title = 'Developing efficacy beliefs in the classroom';
15+
submission = {
16+
id: 0,
17+
section: 'Preprints',
18+
prefix: '',
19+
title: title,
20+
subtitle: '',
21+
abstract: 'A major goal of education is to equip children with the knowledge, skills and self-belief to be confident and informed citizens - citizens who continue to see themselves as learners beyond graduation. This paper looks at the key role of nurturing efficacy beliefs in order to learn and participate in school and society. Research findings conducted within a social studies context are presented, showing how strategy instruction can enhance self-efficacy for learning. As part of this research, Creative Problem Solving (CPS) was taught to children as a means to motivate and support learning. It is shown that the use of CPS can have positive effects on self-efficacy for learning, and be a valuable framework to involve children in decision-making that leads to social action. Implications for enhancing self-efficacy and motivation to learn in the classroom are discussed.',
22+
shortAuthorString: 'Sokoloff',
23+
authorNames: ['Domatilia Sokoloff'],
24+
sectionId: 1,
25+
assignedAuthorNames: ['Domatilia Sokoloff'],
26+
files: [
27+
{
28+
'file': 'dummy.pdf',
29+
'fileName': title + '.pdf',
30+
'mimeType': 'application/pdf',
31+
'genre': Cypress.env('defaultGenre')
32+
},
33+
],
34+
keywords: [
35+
'education',
36+
'citizenship'
37+
]
38+
};
39+
});
40+
1141
it('Create a submission', function() {
1242
var title = 'Developing efficacy beliefs in the classroom';
1343
cy.register({
@@ -18,14 +48,14 @@ describe('Data suite tests', function() {
1848
'country': 'Ireland',
1949
});
2050

21-
cy.createSubmission({
22-
title,
23-
'abstract': 'A major goal of education is to equip children with the knowledge, skills and self-belief to be confident and informed citizens - citizens who continue to see themselves as learners beyond graduation. This paper looks at the key role of nurturing efficacy beliefs in order to learn and participate in school and society. Research findings conducted within a social studies context are presented, showing how strategy instruction can enhance self-efficacy for learning. As part of this research, Creative Problem Solving (CPS) was taught to children as a means to motivate and support learning. It is shown that the use of CPS can have positive effects on self-efficacy for learning, and be a valuable framework to involve children in decision-making that leads to social action. Implications for enhancing self-efficacy and motivation to learn in the classroom are discussed.',
24-
'keywords': [
25-
'education',
26-
'citizenship',
27-
],
28-
});
51+
cy.getCsrfToken();
52+
cy.window()
53+
.then(() => {
54+
return cy.createSubmissionWithApi(submission, this.csrfToken);
55+
})
56+
.then(xhr => {
57+
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
58+
});
2959

3060
cy.logout();
3161
cy.findSubmissionAsEditor('dbarnes', null, 'Sokoloff');

0 commit comments

Comments
 (0)