Skip to content

Commit

Permalink
pkp/pkp-lib#7191 Adapt content creation tests for new submission wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Nov 23, 2022
1 parent fe3682b commit 553e8bc
Show file tree
Hide file tree
Showing 19 changed files with 1,125 additions and 387 deletions.
4 changes: 3 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"contextAcronyms": {
"en_US": "PKP"
},
"defaultGenre": "Book Manuscript"
"defaultGenre": "Book Manuscript",
"authorUserGroupId": 13,
"volumeEditorUserGroupId": 14
},
"integrationFolder": "cypress/tests",
"pluginsFile": "lib/pkp/cypress/plugins/index.js",
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Cypress.Commands.add('createSubmissionWithApi', (data, csrfToken) => {
cy.get('.pkpButton--isPrimary').click();
cy.get('.pkpSteps__step__label--current span:contains("3")');
})
.addChapters(data.chapters)
.addSubmissionAuthorsWithApi(api, data, csrfToken);
.addSubmissionAuthorsWithApi(api, data, csrfToken)
.addChapters(data.chapters);
});


3 changes: 3 additions & 0 deletions cypress/tests/data/50-CreateSeries.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ describe('Data suite tests', function() {
cy.get('a[id^=component-grid-settings-series-seriesgrid-addSeries-button-]').click();
cy.wait(1000); // Avoid occasional failure due to form init taking time
cy.get('input[id^="title-en_US-"]').type('History');
cy.get('label').contains('Daniel Barnes').click();
cy.get('input[id^="path"]').type('his');
cy.get('form[id=seriesForm]').contains('Save').click();

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

// Create a new "Psychology" series
cy.get('a[id^=component-grid-settings-series-seriesgrid-addSeries-button-]').click();
cy.wait(1000); // Avoid occasional failure due to form init taking time
cy.get('input[id^="title-en_US-"]').type('Psychology');
cy.get('label').contains('Daniel Barnes').click();
cy.get('input[id^="path"]').type('psy');
cy.get('form[id=seriesForm]').contains('Save').click();
});
Expand Down
21 changes: 3 additions & 18 deletions cypress/tests/data/60-content/AclarkSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ describe('Data suite tests', function() {
authorNames: ['Arthur Clark'],
sectionId: 1,
assignedAuthorNames: ['Arthur Clark'],
authors: [
{
givenName: 'Arthur',
familyName: 'Clark',
email: '[email protected]',
country: 'Canada',
affiliation: 'University of Calgary'
}
],
files: [
{
'file': 'dummy.pdf',
Expand Down Expand Up @@ -84,19 +75,13 @@ describe('Data suite tests', function() {
'country': 'Canada'
});

// Go to page where CSRF token is available
cy.visit('/index.php/publicknowledge/user/profile');

let csrfToken = '';
cy.getCsrfToken();
cy.window()
.then((win) => {
csrfToken = win.pkp.currentUser.csrfToken;
})
.then(() => {
return cy.createSubmissionWithApi(submission, csrfToken);
return cy.createSubmissionWithApi(submission, this.csrfToken);
})
.then(xhr => {
return cy.submitSubmissionWithApi(submission.id, csrfToken);
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
});
cy.logout();

Expand Down
76 changes: 65 additions & 11 deletions cypress/tests/data/60-content/BbarnetsonSubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,100 @@
*/

describe('Data suite tests', function() {
it('Create a submission', function() {
cy.register({
'username': 'bbarnetson',
'givenName': 'Bob',
'familyName': 'Barnetson',
'affiliation': 'Athabasca University',
'country': 'Canada'
});

cy.createSubmission({
'type': 'monograph',
'title': 'The Political Economy of Workplace Injury in Canada',
let submission;
before(function() {
const title = 'The Political Economy of Workplace Injury in Canada';
submission = {
id: 0,
prefix: '',
title: title,
subtitle: '',
'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.',
'keywords': [
'Business & Economics',
'Political & International Studies',
],
'type': 'monograph',
'submitterRole': 'Author',
'chapters': [
{
'title': 'Introduction',
'contributors': ['Bob Barnetson'],
files: ['chapter1.pdf']
},
{
'title': 'Part One. Employment Relationships in Canada',
'contributors': ['Bob Barnetson'],
files: ['chapter2.pdf']
},
{
'title': 'Part Two. Preventing Workplace Injury',
'contributors': ['Bob Barnetson'],
files: ['chapter3.pdf']
},
{
'title': 'Part Three. Critique of OHS in Canada',
'contributors': ['Bob Barnetson'],
files: ['chapter4.pdf']
},
{
'title': 'Part Four. Political Economy of Preventing Workplace Injury',
'contributors': ['Bob Barnetson'],
files: ['chapter5.pdf']
},
],
files: [
{
'file': 'dummy.pdf',
'fileName': 'chapter1.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter2.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter3.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter4.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter5.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
}
],
}
});

it('Create a submission', function() {
cy.register({
'username': 'bbarnetson',
'givenName': 'Bob',
'familyName': 'Barnetson',
'affiliation': 'Athabasca University',
'country': 'Canada'
});

cy.getCsrfToken();
cy.window()
.then(() => {
return cy.createSubmissionWithApi(submission, this.csrfToken);
})
.then(xhr => {
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
});
});
});
104 changes: 75 additions & 29 deletions cypress/tests/data/60-content/BbeatySubmission.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
*/

describe('Data suite tests', function() {
it('Create a submission', function() {
cy.register({
'username': 'bbeaty',
'givenName': 'Bart',
'familyName': 'Beaty',
'affiliation': 'University of British Columbia',
'country': 'Canada'
});

var submission = {
let submission;
before(function() {
const title = 'How Canadians Communicate: Contexts of Canadian Popular Culture';
submission = {
id: 0,
prefix: '',
title: title,
subtitle: '',
'type': 'editedVolume',
'series': 'History',
'title': 'How Canadians Communicate: Contexts of Canadian Popular Culture',
'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.',
'keywords': [
'Canadian Studies',
Expand All @@ -32,55 +30,103 @@ describe('Data suite tests', function() {
'submitterRole': 'Volume editor',
'additionalAuthors': [
{
'givenName': 'Toby',
'familyName': 'Miller',
'country': 'Canada',
'affiliation': 'University of Alberta',
'givenName': {en_US: 'Toby'},
'familyName': {en_US: 'Miller'},
'country': 'CA',
'affiliation': {en_US: 'University of Alberta'},
'email': '[email protected]',
'role': 'Author',
userGroupId: Cypress.env('authorUserGroupId')
},
{
'givenName': 'Ira',
'familyName': 'Wagman',
'country': 'Canada',
'affiliation': 'Athabasca University',
'givenName': {en_US: 'Ira'},
'familyName': {en_US: 'Wagman'},
'country': 'CA',
'affiliation': {en_US: 'Athabasca University'},
'email': '[email protected]',
'role': 'Author',
userGroupId: Cypress.env('authorUserGroupId')
},
{
'givenName': 'Will',
'familyName': 'Straw',
'country': 'Canada',
'affiliation': 'University of Calgary',
'givenName': {en_US: 'Will'},
'familyName': {en_US: 'Straw'},
'country': 'CA',
'affiliation': {en_US: 'University of Calgary'},
'email': '[email protected]',
'role': 'Author',
userGroupId: Cypress.env('authorUserGroupId')
},
],
'chapters': [
{
'title': 'Introduction: Contexts of Popular Culture',
'contributors': ['Bart Beaty'],
files: ['intro.pdf']
},
{
'title': 'Chapter 1. A Future for Media Studies: Cultural Labour, Cultural Relations, Cultural Politics',
'contributors': ['Toby Miller'],
files: ['chapter1.pdf']
},
{
'title': 'Chapter 2. Log On, Goof Off, and Look Up: Facebook and the Rhythms of Canadian Internet Use',
'contributors': ['Ira Wagman'],
files: ['chapter2.pdf']
},
{
'title': 'Chapter 3. Hawkers and Public Space: Free Commuter Newspapers in Canada',
'contributors': ['Will Straw'],
files: ['chapter3.pdf']
},
],
files: [
{
'file': 'dummy.pdf',
'fileName': 'chapter1.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter2.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
{
'file': 'dummy.pdf',
'fileName': 'chapter3.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
},
]
};
cy.createSubmission(submission);
{
'file': 'dummy.pdf',
'fileName': 'intro.pdf',
'mimeType': 'application/pdf',
'genre': Cypress.env('defaultGenre')
}
],
}
});

it('Create a submission', function() {
cy.register({
'username': 'bbeaty',
'givenName': 'Bart',
'familyName': 'Beaty',
'affiliation': 'University of British Columbia',
'country': 'Canada'
});

cy.getCsrfToken();
cy.window()
.then(() => {
return cy.createSubmissionWithApi(submission, this.csrfToken);
})
.then(xhr => {
return cy.submitSubmissionWithApi(submission.id, this.csrfToken);
});
cy.logout();

cy.findSubmissionAsEditor('dbarnes', null, 'Beaty');
cy.clickDecision('Send to Internal Review');
cy.recordDecisionSendToReview('Send to Internal Review', ['Bart Beaty'], submission.chapters.map(chapter => chapter.title.substring(0, 35)));
cy.recordDecisionSendToReview('Send to Internal Review', ['Bart Beaty'], submission.files.map(file => file.fileName));
cy.isActiveStageTab('Internal Review');
cy.assignReviewer('Aisla McCrae');
cy.clickDecision('Send to External Review');
Expand Down
Loading

0 comments on commit 553e8bc

Please sign in to comment.