forked from pkp/ojs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp/pkp-lib#10745 Add tests for email access feature
- Loading branch information
1 parent
9c0733a
commit b6abf45
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
cypress/tests/integration/emailTemplates/emailTemplates.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* @file cypress/tests/integration/Orcid.cy.js | ||
* | ||
* Copyright (c) 2014-2024 Simon Fraser University | ||
* Copyright (c) 2000-2024 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
*/ | ||
|
||
describe('Email Template Access Tests', function () { | ||
it('Checks that user cannot access restricted template not assigned to their group', () => { | ||
cy.login('admin', 'admin', 'publicknowledge'); | ||
cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); | ||
|
||
cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); | ||
// Remove all existing access | ||
cy.setEmailTemplateUnrestrictedTo(false) | ||
cy.get('input[name="assignedUserGroupIds"]') | ||
.as('checkboxes') | ||
.uncheck({ force: true }) | ||
|
||
cy.contains('button', 'Save').click(); | ||
cy.logout(); | ||
|
||
// Login as user without access - copyedit | ||
cy.login('svogt') | ||
cy.visit( | ||
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' | ||
); | ||
cy.contains('button', 'View').first().click(); | ||
cy.contains('a', 'Copyediting').click(); | ||
cy.contains('a', 'Add discussion').click(); | ||
|
||
cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('not.exist'); | ||
}) | ||
|
||
it('Checks that user can access unrestricted template not specifically assigned to their group', () => { | ||
cy.login('admin', 'admin', 'publicknowledge'); | ||
cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); | ||
|
||
cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); | ||
cy.setEmailTemplateUnrestrictedTo(true); | ||
|
||
cy.get('input[name="assignedUserGroupIds"]') | ||
.as('checkboxes') | ||
.uncheck({ force: true }) | ||
|
||
cy.contains('button', 'Save').click(); | ||
cy.logout(); | ||
|
||
// Login as user with access - copyedit | ||
cy.login('svogt') | ||
cy.visit( | ||
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' | ||
); | ||
cy.contains('button', 'View').first().click(); | ||
cy.contains('a', 'Copyediting').click(); | ||
cy.contains('a', 'Add discussion').click(); | ||
|
||
cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('to.exist'); | ||
}) | ||
|
||
it('Checks that user can access template assigned to their group', () => { | ||
cy.login('admin', 'admin', 'publicknowledge'); | ||
cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); | ||
|
||
cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); | ||
cy.setEmailTemplateUnrestrictedTo(false) | ||
cy.contains('label', 'Copyeditor').find('input[type="checkbox"]').check({ force: true }); | ||
cy.contains('button', 'Save').click(); | ||
cy.logout(); | ||
|
||
// Login as user with access - copyedit | ||
cy.login('svogt') | ||
cy.visit( | ||
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' | ||
); | ||
cy.contains('button', 'View').first().click(); | ||
cy.contains('a', 'Copyediting').click(); | ||
cy.contains('a', 'Add discussion').click(); | ||
|
||
cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('to.exist'); | ||
}) | ||
}); |