|
| 1 | +/** |
| 2 | + * @file cypress/tests/integration/Orcid.cy.js |
| 3 | + * |
| 4 | + * Copyright (c) 2014-2025 Simon Fraser University |
| 5 | + * Copyright (c) 2000-2025 John Willinsky |
| 6 | + * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. |
| 7 | + * |
| 8 | + */ |
| 9 | + |
| 10 | +describe('Email Template Access Tests', function() { |
| 11 | + it('Checks that user cannot access restricted template not assigned to their group', () => { |
| 12 | + cy.login('admin', 'admin', 'publicknowledge'); |
| 13 | + cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); |
| 14 | + |
| 15 | + cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); |
| 16 | + // Remove all existing access |
| 17 | + cy.setEmailTemplateUnrestrictedTo(false); |
| 18 | + cy.get('input[name="assignedUserGroupIds"]') |
| 19 | + .as('checkboxes') |
| 20 | + .uncheck({force: true}); |
| 21 | + |
| 22 | + cy.contains('button', 'Save').click(); |
| 23 | + cy.logout(); |
| 24 | + |
| 25 | + // Login as user without access - copyeditor |
| 26 | + cy.login('svogt'); |
| 27 | + cy.visit( |
| 28 | + 'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' |
| 29 | + ); |
| 30 | + cy.contains('button', 'View').first().click(); |
| 31 | + cy.contains('a', 'Copyediting').click(); |
| 32 | + cy.contains('a', 'Add discussion').click(); |
| 33 | + |
| 34 | + cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('not.exist'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('Checks that user can access unrestricted template not specifically assigned to their group', () => { |
| 38 | + cy.login('admin', 'admin', 'publicknowledge'); |
| 39 | + cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); |
| 40 | + |
| 41 | + cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); |
| 42 | + |
| 43 | + cy.get('input[name="assignedUserGroupIds"]') |
| 44 | + .as('checkboxes') |
| 45 | + .uncheck({force: true}); |
| 46 | + |
| 47 | + cy.contains('button', 'Save').click(); |
| 48 | + cy.reload(); |
| 49 | + |
| 50 | + cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); |
| 51 | + |
| 52 | + cy.setEmailTemplateUnrestrictedTo(true); |
| 53 | + |
| 54 | + cy.contains('button', 'Save').click(); |
| 55 | + cy.logout(); |
| 56 | + |
| 57 | + // Login as user with access - copyeditor |
| 58 | + cy.login('svogt'); |
| 59 | + cy.visit( |
| 60 | + 'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' |
| 61 | + ); |
| 62 | + cy.contains('button', 'View').first().click(); |
| 63 | + cy.contains('a', 'Copyediting').click(); |
| 64 | + cy.contains('a', 'Add discussion').click(); |
| 65 | + |
| 66 | + cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('to.exist'); |
| 67 | + }); |
| 68 | + |
| 69 | + it('Checks that user can access template assigned to their group', () => { |
| 70 | + cy.login('admin', 'admin', 'publicknowledge'); |
| 71 | + cy.visit('/index.php/publicknowledge/management/settings/manageEmails'); |
| 72 | + |
| 73 | + cy.openEmailTemplate('Discussion (Copyediting)', 'Discussion (Copyediting)'); |
| 74 | + cy.setEmailTemplateUnrestrictedTo(false); |
| 75 | + cy.contains('label', 'Copyeditor').find('input[type="checkbox"]').check({force: true}); |
| 76 | + cy.contains('button', 'Save').click(); |
| 77 | + cy.logout(); |
| 78 | + |
| 79 | + // Login as user with access - copyeditor |
| 80 | + cy.login('svogt'); |
| 81 | + cy.visit( |
| 82 | + 'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me' |
| 83 | + ); |
| 84 | + cy.contains('button', 'View').first().click(); |
| 85 | + cy.contains('a', 'Copyediting').click(); |
| 86 | + cy.contains('a', 'Add discussion').click(); |
| 87 | + |
| 88 | + cy.get('select#template').find('option').contains('Discussion (Copyediting)').should('to.exist'); |
| 89 | + }); |
| 90 | +}); |
0 commit comments