test: Add user type of admin to E2E tests (#7935)

## Summary
Extend existing user types in the E2E database. Currently, we have only
owner and member but we need also admin

---------

Co-authored-by: Val <68596159+valya@users.noreply.github.com>
This commit is contained in:
Csaba Tuncsik
2023-12-06 14:31:06 +01:00
committed by GitHub
parent 92bab72cff
commit c461025f70
5 changed files with 51 additions and 10 deletions

View File

@@ -12,6 +12,13 @@ export const INSTANCE_OWNER = {
lastName: randLastName(),
};
export const INSTANCE_ADMIN = {
email: 'admin@n8n.io',
password: DEFAULT_USER_PASSWORD,
firstName: randFirstName(),
lastName: randLastName(),
};
export const INSTANCE_MEMBERS = [
{
email: 'rebecca@n8n.io',

View File

@@ -1,4 +1,4 @@
import { INSTANCE_MEMBERS, INSTANCE_OWNER } from '../constants';
import { INSTANCE_MEMBERS, INSTANCE_OWNER, INSTANCE_ADMIN } from '../constants';
import { MainSidebar, SettingsSidebar, SettingsUsersPage, WorkflowPage } from '../pages';
import { PersonalSettingsPage } from '../pages/settings-personal';
@@ -46,7 +46,7 @@ describe('User Management', { disableAutoLogin: true }, () => {
it('should properly render UM settings page for instance owners', () => {
usersSettingsPage.actions.loginAndVisit(INSTANCE_OWNER.email, INSTANCE_OWNER.password, true);
// All items in user list should be there
usersSettingsPage.getters.userListItems().should('have.length', 3);
usersSettingsPage.getters.userListItems().should('have.length', 4);
// List item for current user should have the `Owner` badge
usersSettingsPage.getters
.userItem(INSTANCE_OWNER.email)
@@ -55,6 +55,7 @@ describe('User Management', { disableAutoLogin: true }, () => {
// Other users list items should contain action pop-up list
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[0].email).should('exist');
usersSettingsPage.getters.userActionsToggle(INSTANCE_MEMBERS[1].email).should('exist');
usersSettingsPage.getters.userActionsToggle(INSTANCE_ADMIN.email).should('exist');
});
it('should be able to change theme', () => {

View File

@@ -1,5 +1,5 @@
import { MainSidebar } from './../pages/sidebar/main-sidebar';
import { INSTANCE_OWNER, BACKEND_BASE_URL } from '../constants';
import { INSTANCE_OWNER, INSTANCE_ADMIN, BACKEND_BASE_URL } from '../constants';
import { SigninPage } from '../pages';
import { PersonalSettingsPage } from '../pages/settings-personal';
import { MfaLoginPage } from '../pages/mfa-login';
@@ -19,6 +19,16 @@ const user = {
mfaRecoveryCodes: [RECOVERY_CODE],
};
const admin = {
email: INSTANCE_ADMIN.email,
password: INSTANCE_ADMIN.password,
firstName: 'Admin',
lastName: 'B',
mfaEnabled: false,
mfaSecret: MFA_SECRET,
mfaRecoveryCodes: [RECOVERY_CODE],
};
const mfaLoginPage = new MfaLoginPage();
const signinPage = new SigninPage();
const personalSettingsPage = new PersonalSettingsPage();
@@ -30,6 +40,7 @@ describe('Two-factor authentication', () => {
cy.request('POST', `${BACKEND_BASE_URL}/rest/e2e/reset`, {
owner: user,
members: [],
admin,
});
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not logged in');

View File

@@ -1,10 +1,11 @@
import { BACKEND_BASE_URL, INSTANCE_MEMBERS, INSTANCE_OWNER } from '../constants';
import { BACKEND_BASE_URL, INSTANCE_ADMIN, INSTANCE_MEMBERS, INSTANCE_OWNER } from '../constants';
import './commands';
before(() => {
cy.request('POST', `${BACKEND_BASE_URL}/rest/e2e/reset`, {
owner: INSTANCE_OWNER,
members: INSTANCE_MEMBERS,
admin: INSTANCE_ADMIN,
});
Cypress.on('uncaught:exception', (err) => {