Files
8c588d76f0 [MM-61647][MM-61651]: Upgraded react-select to v5 (#30070)
* [MM-61647]: Upgraded react-select to v5
- Updated old type definitions with new v5 packaged type definitions.
- Removed some unused props
- Updated onBlur, onFocus and handleInputChange methods in user_input_email component

* Fix incorrect usage of handleInputChange in ChannelsInput

* Remove type assertions from dropdown_input_hybrid.tsx

* Simplify typing of users_emails_input.tsx

* [MM-61647][MM-61651]: Fixed some type definitions and e2e failing test case

* [MM-61647][MM-61651]: Fixed type error in dropdown_input_hybrid

* [MM-61647][MM-61651]: Fixed failing CI type error and e2e test cases

* [MM-61647][MM-61651]: Fixed failing e2e test case

* [MM-61647][MM-61651]: Updated the styles and reverted the test case changes
- Fixed the theme not getting correctly inherited
- Fixed the timezone and language settings getting saved on enter

---------

Co-authored-by: Harrison Healey <[email protected]>
Co-authored-by: Mattermost Build <[email protected]>
2025-02-25 17:13:51 -05:00

95 lines
3.3 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import accessRules from '../../../../fixtures/system-roles-console-access';
import disabledTests from '../../../../fixtures/console-example-inputs';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
function noAccessFunc(section) {
// * If it's a no-access permission, we just need to check that the section doesn't exist in the side bar
cy.findByTestId(section).should('not.exist');
}
function readOnlyFunc(section) {
// * If it's a read only permission, we need to make sure that the section does exist in the sidebar however the inputs in that section is disabled (read only)
cy.findByTestId(section).should('exist');
checkInputsShould('be.disabled', section);
}
function readWriteFunc(section) {
// * If we have read + write (can edit) permissions, we need to make the section exists and also that the inputs are all enabled
cy.findByTestId(section).should('exist');
checkInputsShould('be.enabled', section);
}
function checkInputsShould(shouldString, section) {
const {disabledInputs} = disabledTests.find((item) => item.section === section);
Cypress._.forEach(disabledInputs, ({path, selector}) => {
if (path.length && selector.length) {
cy.visit(path, {timeout: TIMEOUTS.HALF_MIN});
cy.findByTestId(selector, {timeout: TIMEOUTS.ONE_MIN}).should(shouldString);
}
});
}
export function makeUserASystemRole(testUsers, role) {
// # Login as each new role.
cy.apiAdminLogin();
// # Go the system console.
cy.visit('/admin_console/user_management/system_roles');
cy.get('.admin-console__header').within(() => {
cy.findByText('Delegated Granular Administration', {timeout: TIMEOUTS.ONE_MIN}).should('exist').and('be.visible');
});
// # Click on edit for the role
cy.findByTestId(`${role}_edit`).click();
// # Click Add People button
cy.findByRole('button', {name: 'Add People'}).click().wait(TIMEOUTS.HALF_SEC);
// # Type in user name
cy.findByRole('combobox', {name: 'Search for people'}).typeWithForce(`${testUsers[role].email}`);
// # Find the user and click on him
cy.get('#multiSelectList').should('be.visible').children().first().click({force: true});
// # Click add button
cy.findByRole('button', {name: 'Add'}).click().wait(TIMEOUTS.HALF_SEC);
// # Click save button
cy.findByRole('button', {name: 'Save'}).click().wait(TIMEOUTS.HALF_SEC);
}
export function forEachConsoleSection(testUsers, roleName) {
const ACCESS_NONE = 'none';
const ACCESS_READ_ONLY = 'read';
const ACCESS_READ_WRITE = 'read+write';
const user = testUsers[roleName];
// # Login as each new role.
cy.apiLogin(user);
// # Go the system console.
cy.visit('/admin_console');
cy.get('.admin-sidebar', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
accessRules.forEach((rule) => {
const {section} = rule;
const access = rule[roleName];
switch (access) {
case ACCESS_NONE:
noAccessFunc(section);
break;
case ACCESS_READ_ONLY:
readOnlyFunc(section);
break;
case ACCESS_READ_WRITE:
readWriteFunc(section);
break;
}
});
}