Skip to content

Commit

Permalink
pkp/pkp-lib#8592 Fixes for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Feb 15, 2023
1 parent eedff4c commit 16307cf
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 65 deletions.
6 changes: 3 additions & 3 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ const { defineConfig } = require('cypress')
module.exports = defineConfig({
env: {
contextTitles: {
en_US: 'Public Knowledge Preprint Server',
en: 'Public Knowledge Preprint Server',
fr_CA: 'Serveur de prépublication de la connaissance du public',
},
contextDescriptions: {
en_US:
en:
'The Public Knowledge Preprint Server is a preprint service on the subject of public access to science.',
fr_CA:
"Le Serveur de prépublication de la connaissance du public est une service trimestrielle évaluée par les pairs sur le thème de l'accès du public à la science.",
},
contextAcronyms: {
en_US: 'PKP',
en: 'PKP',
},
defaultGenre: 'Preprint Text',
authorUserGroupId: 4,
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import '../../lib/pkp/cypress/support/commands';
Cypress.Commands.add('addCategory', (categoryName, categoryPath) => {
cy.get('div.pkp_grid_category a[id^=component-grid-settings-category-categorycategorygrid-addCategory-button-]').click();
cy.wait(1000); // Avoid occasional failure due to form init taking time
cy.get('input[id^="name-en_US-"]').type(categoryName, {delay: 0});
cy.get('input[id^="name-en-"]').type(categoryName, {delay: 0});
cy.get('input[id^="path-"]').type(categoryPath, {delay: 0});
cy.get('form[id=categoryForm]').contains('OK').click();
cy.wait(2000); // Avoid occasional failure due to form save taking time
Expand Down
28 changes: 14 additions & 14 deletions cypress/tests/data/10-ApplicationSetup/20-CreateContext.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ describe('Data suite tests', function() {
cy.get('div[id=editContext]').find('button').contains(/French/).click();
cy.get('input[name="name-fr_CA"]').type(Cypress.env('contextTitles')['fr_CA'], {delay: 0});
cy.get('button').contains('Save').click()
cy.get('div[id=context-name-error-en_US]').find('span').contains('This field is required.');
cy.get('div[id=context-acronym-error-en_US]').find('span').contains('This field is required.');
cy.get('div[id=context-name-error-en]').find('span').contains('This field is required.');
cy.get('div[id=context-acronym-error-en]').find('span').contains('This field is required.');
cy.get('div[id=context-contactName-error]').find('span').contains('This field is required.');
cy.get('div[id=context-contactEmail-error]').find('span').contains('This field is required.');
cy.get('div[id=context-urlPath-error]').find('span').contains('This field is required.');
cy.get('div[id=context-primaryLocale-error]').find('span').contains('This field is required.');
cy.get('input[name="name-en_US"]').type(Cypress.env('contextTitles')['en_US'], {delay: 0});
cy.get('input[name=acronym-en_US]').type('JPK', {delay: 0});
cy.get('input[name="name-en"]').type(Cypress.env('contextTitles')['en'], {delay: 0});
cy.get('input[name=acronym-en]').type('JPK', {delay: 0});
cy.get('span').contains('Enable this preprint server').siblings('input').check();
cy.get('input[name="supportedLocales"][value="en_US').check();
cy.get('input[name="supportedLocales"][value="en').check();
cy.get('input[name="supportedLocales"][value="fr_CA').check();
cy.get('input[name="primaryLocale"][value="en_US').check();
cy.get('input[name="primaryLocale"][value="en').check();
cy.get('select[id=context-country-control]').select('Iceland');
cy.get('input[name=contactName]').type('Ramiro Vaca', {delay: 0});

Expand All @@ -48,7 +48,7 @@ describe('Data suite tests', function() {
cy.get('input[name=contactEmail').clear().type('rvaca@mailinator.com', {delay: 0});

// Context descriptions
cy.setTinyMceContent('context-description-control-en_US', Cypress.env('contextDescriptions')['en_US']);
cy.setTinyMceContent('context-description-control-en', Cypress.env('contextDescriptions')['en']);
cy.setTinyMceContent('context-description-control-fr_CA', Cypress.env('contextDescriptions')['fr_CA']);
cy.get('button').contains('Save').click();

Expand All @@ -74,18 +74,18 @@ describe('Data suite tests', function() {
cy.contains('Locale settings saved.');

cy.get('button[id="indexing-button"]').click();
cy.get('input[name="searchDescription-en_US"]').type(Cypress.env('contextDescriptions')['en_US'], {delay: 0});
cy.get('textarea[name="customHeaders-en_US"]').type('<meta name="pkp" content="Test metatag.">', {delay: 0});
cy.get('input[name="searchDescription-en"]').type(Cypress.env('contextDescriptions')['en'], {delay: 0});
cy.get('textarea[name="customHeaders-en"]').type('<meta name="pkp" content="Test metatag.">', {delay: 0});
cy.get('div[id=indexing]').find('button').contains('Save').click();
cy.get('#indexing [role="status"]').contains('Saved');

cy.get('label[for="searchIndexing-searchDescription-control-en_US"] ~ button.tooltipButton').click();
cy.get('label[for="searchIndexing-searchDescription-control-en"] ~ button.tooltipButton').click();
cy.get('div').contains('Provide a brief description');
cy.get('label[for="searchIndexing-searchDescription-control-en_US"] ~ button.tooltipButton').click();
cy.get('label[for="searchIndexing-searchDescription-control-en"] ~ button.tooltipButton').click();

// OPS-specific tasks
cy.get('button[id="context-button"]').click();
cy.get('input[name="abbreviation-en_US"]').type('publicknowledge', {delay: 0});
cy.get('input[name="abbreviation-en"]').type('publicknowledge', {delay: 0});
cy.get('div[id=context]').find('button').contains('Save').click();
cy.get('#context [role="status"]').contains('Saved');
});
Expand All @@ -96,8 +96,8 @@ describe('Data suite tests', function() {
cy.get('a').contains('Dashboard').click();
cy.get('.app__nav a').contains('Server').click();

cy.get('input[name="abbreviation-en_US"]').type('Pub Know Pre', {delay: 0});
cy.get('input[name="acronym-en_US"]').type(Cypress.env('contextAcronyms')['en_US'], {delay: 0});
cy.get('input[name="abbreviation-en"]').type('Pub Know Pre', {delay: 0});
cy.get('input[name="acronym-en"]').type(Cypress.env('contextAcronyms')['en'], {delay: 0});

cy.get('div[id=masthead]').find('button').contains('Save').click();
cy.get('#masthead [role="status"]').contains('Saved');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Data suite tests', function() {
// Create a Cultural History subcategory
cy.get('a[id^=component-grid-settings-category-categorycategorygrid-addCategory-button-]').click();
cy.wait(1000); // Avoid occasional failure due to form init taking time
cy.get('input[id^="name-en_US-"]').type('Cultural History', {delay: 0});
cy.get('input[id^="name-en-"]').type('Cultural History', {delay: 0});
cy.get('select[id="parentId"],select[id="parentId"]').select('History');
cy.get('input[id^="path-"]').type('cultural-history', {delay: 0});
cy.get('form[id=categoryForm]').contains('OK').click();
Expand Down
26 changes: 13 additions & 13 deletions cypress/tests/data/60-content/CkwantesSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@ describe('Data suite: Ckwantes', function() {

// Enter details
cy.get('h2').contains('Submission Details');
cy.get('#titleAbstract-keywords-control-en_US').type('employees');
cy.get('#titleAbstract-keywords-control-en').type('employees');
cy.wait(500);
cy.get('#titleAbstract-keywords-control-en_US').type('{enter}');
cy.get('#titleAbstract-keywords-selected-en_US .pkpBadge:contains(\'employees\')');
cy.get('#titleAbstract-keywords-control-en').type('{enter}');
cy.get('#titleAbstract-keywords-selected-en .pkpBadge:contains(\'employees\')');

cy.get('#titleAbstract-keywords-control-en_US').type('survey');
cy.get('#titleAbstract-keywords-control-en').type('survey');
cy.wait(500);
cy.get('#titleAbstract-keywords-control-en_US').type('{enter}');
cy.get('#titleAbstract-keywords-selected-en_US .pkpBadge:contains(\'survey\')');
cy.setTinyMceContent('titleAbstract-abstract-control-en_US', submission.abstract);
cy.get('#titleAbstract-title-control-en_US').click(); // Ensure blur event is fired
cy.get('#titleAbstract-keywords-control-en').type('{enter}');
cy.get('#titleAbstract-keywords-selected-en .pkpBadge:contains(\'survey\')');
cy.setTinyMceContent('titleAbstract-abstract-control-en', submission.abstract);
cy.get('#titleAbstract-title-control-en').click(); // Ensure blur event is fired

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

Expand All @@ -114,11 +114,11 @@ describe('Data suite: Ckwantes', function() {
cy.get('.listPanel__item:contains("Catherine Kwantes")');
cy.get('button').contains('Add Contributor').click();
cy.get('.modal__panel:contains("Add Contributor")').find('button').contains('Save').click();
cy.get('#contributor-givenName-error-en_US').contains('This field is required.');
cy.get('#contributor-givenName-error-en').contains('This field is required.');
cy.get('#contributor-email-error').contains('This field is required.');
cy.get('#contributor-country-error').contains('This field is required.');
cy.get('.pkpFormField:contains("Given Name")').find('input[name*="en_US"]').type(submission.authors[0].givenName);
cy.get('.pkpFormField:contains("Family Name")').find('input[name*="en_US"]').type(submission.authors[0].familyName);
cy.get('.pkpFormField:contains("Given Name")').find('input[name*="en"]').type(submission.authors[0].givenName);
cy.get('.pkpFormField:contains("Family Name")').find('input[name*="en"]').type(submission.authors[0].familyName);
cy.get('.pkpFormField:contains("Country")').find('select').select(submission.authors[0].country)
cy.get('.pkpFormField:contains("Email")').find('input').type('notanemail');
cy.get('.modal__panel:contains("Add Contributor")').find('button').contains('Save').click();
Expand All @@ -144,7 +144,7 @@ describe('Data suite: Ckwantes', function() {

// Delete a contributor
cy.get('.listPanel:contains("Contributors")').find('button').contains('Add Contributor').click();
cy.get('.pkpFormField:contains("Given Name")').find('input[name*="en_US"]').type('Fake Author Name');
cy.get('.pkpFormField:contains("Given Name")').find('input[name*="en"]').type('Fake Author Name');
cy.get('.pkpFormField:contains("Email")').find('input').type('delete@mailinator.com');
cy.get('.pkpFormField:contains("Country")').find('select').select('Barbados');
cy.get('.modal__panel:contains("Add Contributor")').find('button').contains('Save').click();
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('Data suite: Ckwantes', function() {
// Submit
cy.contains('Make a Submission: Review');
cy.get('button:contains("Submit")').click();
const message = 'Are you sure you want to submit ' + submission.title + ' to ' + Cypress.env('contextTitles').en_US + '? Once you submit, a moderator will review the preprint before posting it online.';
const message = 'Are you sure you want to submit ' + submission.title + ' to ' + Cypress.env('contextTitles').en + '? Once you submit, a moderator will review the preprint before posting it online.';
cy.get('.modal__panel:contains("' + message + '")').find('button').contains('Submit').click();
cy.contains('Submission complete');
cy.get('a').contains('Create a new submission');
Expand Down
16 changes: 8 additions & 8 deletions cypress/tests/data/60-content/CmontgomerieSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('Data suite: Cmontgomerie', function() {
assignedAuthorNames: ['Craig Montgomerie'],
additionalAuthors: [
{
givenName: {en_US: 'Mark'},
familyName: {en_US: 'Irvine'},
givenName: {en: 'Mark'},
familyName: {en: 'Irvine'},
country: 'CA',
affiliation: {en_US: 'University of Victoria'},
affiliation: {en: 'University of Victoria'},
email: 'mirvine@mailinator.com',
userGroupId: Cypress.env('authorUserGroupId')
}
Expand Down Expand Up @@ -90,12 +90,12 @@ describe('Data suite: Cmontgomerie', function() {

// Edit metadata in 1st version
cy.get('#metadata-button').click();
cy.get('#metadata-keywords-control-en_US').type('employees{enter}', {delay: 0});
cy.get('#metadata-keywords-control-en').type('employees{enter}', {delay: 0});
cy.wait(500);
cy.get('#metadata-keywords-control-en_US').type('{enter}', {delay: 0});
cy.get('#metadata-keywords-control-en').type('{enter}', {delay: 0});
cy.get('#metadata button').contains('Save').click();
cy.get('#metadata [role="status"]').contains('Saved');
cy.get('#metadata-keywords-selected-en_US').contains('employees');
cy.get('#metadata-keywords-selected-en').contains('employees');
cy.wait(1500);

// Publish 1st version again
Expand All @@ -108,8 +108,8 @@ describe('Data suite: Cmontgomerie', function() {
cy.get('div:contains("Are you sure you want to create a new version?")');
cy.get('.modal__footer button').contains('Yes').click();
cy.get('#license-button').click();
cy.get('input[id^="publicationLicense-copyrightHolder-control-en_US"').clear()
cy.get('input[id^="publicationLicense-copyrightHolder-control-en_US"').type('Craig Montgomerie', {delay: 0});
cy.get('input[id^="publicationLicense-copyrightHolder-control-en"').clear()
cy.get('input[id^="publicationLicense-copyrightHolder-control-en"').type('Craig Montgomerie', {delay: 0});
cy.get('#license button').contains('Save').click();
cy.get('#license [role="status"]').contains('Saved');
cy.wait(1500);
Expand Down
6 changes: 3 additions & 3 deletions cypress/tests/data/60-content/EostromSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ describe('Data suite: Eostrom', function() {
assignedAuthorNames: ['Elinor Ostrom'],
additionalAuthors: [
{
givenName: {en_US: 'Frank'},
familyName: {en_US: 'van Laerhoven'},
givenName: {en: 'Frank'},
familyName: {en: 'van Laerhoven'},
country: 'US',
affiliation: {en_US: 'Indiana University'},
affiliation: {en: 'Indiana University'},
email: 'fvanlaerhoven@mailinator.com',
userGroupId: Cypress.env('authorUserGroupId')
}
Expand Down
6 changes: 3 additions & 3 deletions cypress/tests/data/60-content/KalkhafajiSubmission.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ describe('Data suite: Kalkhafaji', function() {
assignedAuthorNames: ['Karim Al-Khafaji'],
additionalAuthors: [
{
givenName: {en_US: 'Margaret'},
familyName: {en_US: 'Morse'},
givenName: {en: 'Margaret'},
familyName: {en: 'Morse'},
country: 'US',
affiliation: {en_US: 'Stanford University'},
affiliation: {en: 'Stanford University'},
email: 'mmorse@mailinator.com',
userGroupId: Cypress.env('authorUserGroupId')
}
Expand Down
6 changes: 3 additions & 3 deletions cypress/tests/integration/plugins/generic/WebFeed.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Web Feed plugin tests', () => {
const id = $entry.find('id').text().match(/\d+$/).pop();
getSubmission(id).then(response => {
const publication = response.body.publications.pop();
expect($entry.find('title').text()).to.contain(publication.title.en_US);
expect($entry.find('title').text()).to.contain(publication.title.en);
$entry.find('author name').each((index, name) => expect(publication.authorsString).to.contain(cy.$$(name).text()));
});
});
Expand All @@ -80,7 +80,7 @@ describe('Web Feed plugin tests', () => {
const id = $entry.find('link').text().match(/\d+$/).pop();
getSubmission(id).then(response => {
const publication = response.body.publications.pop();
expect($entry.find('title').text()).to.contain(publication.title.en_US);
expect($entry.find('title').text()).to.contain(publication.title.en);
$entry.find('dc:creator').each((index, name) => expect(publication.authorsString).to.contain(cy.$$(name).text()));
});
});
Expand All @@ -98,7 +98,7 @@ describe('Web Feed plugin tests', () => {
const id = $entry.find('link').text().match(/\d+$/).pop();
getSubmission(id).then(response => {
const publication = response.body.publications.pop();
expect($entry.find('title').text()).to.contain(publication.title.en_US);
expect($entry.find('title').text()).to.contain(publication.title.en);
$entry.find('dc:creator').each((index, name) => expect(publication.authorsString).to.contain(cy.$$(name).text()));
});
});
Expand Down
31 changes: 16 additions & 15 deletions plugins/oaiMetadataFormats/dc/tests/OAIMetadataFormat_DCTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class OAIMetadataFormat_DCTest
*
* @ingroup plugins_oaiMetadataFormats_dc_tests
*
* @see OAIMetadataFormat_DC
Expand Down Expand Up @@ -83,24 +84,24 @@ public function testToXml()

// Author
$author = new Author();
$author->setGivenName('author-firstname', 'en_US');
$author->setFamilyName('author-lastname', 'en_US');
$author->setAffiliation('author-affiliation', 'en_US');
$author->setGivenName('author-firstname', 'en');
$author->setFamilyName('author-lastname', 'en');
$author->setAffiliation('author-affiliation', 'en');
$author->setEmail('someone@example.com');

/** @var Publication|MockObject */
$publication = $this->getMockBuilder(Publication::class)
->onlyMethods([])
->getMock();
$publication->setData('pages', 15);
$publication->setData('type', 'art-type', 'en_US');
$publication->setData('title', 'preprint-title-en', 'en_US');
$publication->setData('title', 'preprint-title-de', 'de_DE');
$publication->setData('coverage', ['en_US' => ['preprint-coverage-geo', 'preprint-coverage-chron', 'preprint-coverage-sample']]);
$publication->setData('abstract', 'preprint-abstract', 'en_US');
$publication->setData('sponsor', 'preprint-sponsor', 'en_US');
$publication->setData('type', 'art-type', 'en');
$publication->setData('title', 'preprint-title-en', 'en');
$publication->setData('title', 'preprint-title-de', 'de');
$publication->setData('coverage', ['en' => ['preprint-coverage-geo', 'preprint-coverage-chron', 'preprint-coverage-sample']]);
$publication->setData('abstract', 'preprint-abstract', 'en');
$publication->setData('sponsor', 'preprint-sponsor', 'en');
$publication->setData('doiObject', $publicationDoiObject);
$publication->setData('languages', 'en_US');
$publication->setData('languages', 'en');
$publication->setData('copyrightHolder', 'preprint-copyright');
$publication->setData('copyrightYear', 'year');
$publication->setData('datePublished', '2010-11-05');
Expand Down Expand Up @@ -154,9 +155,9 @@ public function testToXml()
->method('getSetting')
->with('publishingMode')
->will($this->returnValue(\APP\server\Server::PUBLISHING_MODE_OPEN));
$server->setName('server-title', 'en_US');
$server->setName('server-title', 'en');
$server->setData('publisherInstitution', 'server-publisher');
$server->setPrimaryLocale('en_US');
$server->setPrimaryLocale('en');
$server->setPath('server-path');
$server->setData('onlineIssn', 'onlineIssn');
$server->setData('printIssn', null);
Expand All @@ -165,7 +166,7 @@ public function testToXml()

// Section
$section = new Section();
$section->setIdentifyType('section-identify-type', 'en_US');
$section->setIdentifyType('section-identify-type', 'en');

//
// Create infrastructural support objects
Expand Down Expand Up @@ -224,7 +225,7 @@ public function testToXml()
->getMock();
$submissionSubjectDao->expects($this->any())
->method('getSubjects')
->will($this->returnValue(['en_US' => ['preprint-subject', 'preprint-subject-class']]));
->will($this->returnValue(['en' => ['preprint-subject', 'preprint-subject-class']]));
DAORegistry::registerDAO('SubmissionSubjectDAO', $submissionSubjectDao);

// Mocked DAO to return the keywords
Expand All @@ -233,7 +234,7 @@ public function testToXml()
->getMock();
$submissionKeywordDao->expects($this->any())
->method('getKeywords')
->will($this->returnValue(['en_US' => ['preprint-keyword']]));
->will($this->returnValue(['en' => ['preprint-keyword']]));
DAORegistry::registerDAO('SubmissionKeywordDAO', $submissionKeywordDao);

//
Expand Down
2 changes: 1 addition & 1 deletion plugins/oaiMetadataFormats/dc/tests/expectedResult.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dc:format>galley-filetype</dc:format>
<dc:identifier>preprint-view-9</dc:identifier>
<dc:identifier>preprint-doi</dc:identifier>
<dc:language>en_US</dc:language>
<dc:language>en</dc:language>
<dc:relation>preprint-view-9-98</dc:relation>
<dc:relation>galley-doi</dc:relation>
<dc:coverage xml:lang="en-US">preprint-coverage-geo</dc:coverage>
Expand Down

0 comments on commit 16307cf

Please sign in to comment.