Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests for email access restriction feature #2

Draft
wants to merge 2 commits into
base: feature/i10403-email-access-restrictions
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions cypress/tests/integration/emailTemplates/emailTemplates.cy.js
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 (Production)', 'Editor Assigned');
// 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 - Moderator
cy.login('dbuskins')
cy.visit(
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me'
);
cy.contains('button', 'View').first().click();
cy.contains('a', 'Production').click();
cy.contains('a', 'Add discussion').click();

cy.get('select#template').find('option').contains('Editor Assigned').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 (Production)', 'Editor Assigned');
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 - Moderator
cy.login('dbuskins')
cy.visit(
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me'
);
cy.contains('button', 'View').first().click();
cy.contains('a', 'Production').click();
cy.contains('a', 'Add discussion').click();

cy.get('select#template').find('option').contains('Editor Assigned').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 (Production)', 'Editor Assigned');
cy.setEmailTemplateUnrestrictedTo(false)
cy.contains('label', 'Moderator').find('input[type="checkbox"]').check({ force: true });
cy.contains('button', 'Save').click();
cy.logout();

// Login as user with access - Moderator
cy.login('dbuskins')
cy.visit(
'index.php/publicknowledge/en/dashboard/editorial?currentViewId=assigned-to-me'
);
cy.contains('button', 'View').first().click();
cy.contains('a', 'Production').click();
cy.contains('a', 'Add discussion').click();

cy.get('select#template').find('option').contains('Editor Assigned').should('to.exist');
})
});
Loading