Этот коммит содержится в:
Mario Vitale
2023-03-27 16:28:42 +02:00
родитель da7a6825ce
Коммит ba6b97fb62
1142 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@@ -0,0 +1,88 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap_group
describe('LDAP Group Sync - Test channel public/private toggle', () => {
let testTeam;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// Enable LDAP and LDAP group sync
cy.apiUpdateConfig({LdapSettings: {Enable: true}});
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
// # Init test setup
cy.apiInitSetup().then(({team}) => {
testTeam = team;
});
});
it('MM-T4003_1 Verify that System Admin can change channel privacy using toggle', () => {
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then(({channel}) => {
assert(channel.type === 'O');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).click();
cy.get('#saveSetting').click();
cy.get('#confirmModalButton').click();
return cy.apiGetChannel(channel.id);
}).then(({channel}) => {
assert(channel.type === 'P');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).click();
cy.get('#saveSetting').click();
cy.get('#confirmModalButton').click();
return cy.apiGetChannel(channel.id);
}).then(({channel}) => {
assert(channel.type === 'O');
});
});
it('MM-T4003_2 Verify that resetting sync toggle doesn\'t alter channel privacy toggle', () => {
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then(({channel}) => {
assert(channel.type === 'O');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(0).click();
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(0).click();
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).contains('Public');
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).click();
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(0).click();
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(0).click();
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).contains('Private');
});
});
it('MM-T4003_3 Verify that toggles are disabled for default channel', () => {
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.getCurrentChannelId().then((id) => {
cy.visit(`/admin_console/user_management/channels/${id}`);
cy.get('#channel_profile').contains('Town Square');
cy.get('#channel_manage').scrollIntoView().should('be.visible').within(() => {
cy.get('.line-switch').first().within(() => {
cy.findByText('Sync Group Members').should('be.visible');
cy.findByTestId('syncGroupSwitch-button').should('be.disabled');
});
cy.get('.line-switch').last().within(() => {
cy.findByText('Public channel or private channel').should('be.visible');
cy.findByTestId('allow-all-toggle-button').should('be.disabled');
});
});
});
});
});

Просмотреть файл

@@ -0,0 +1,272 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @enterprise @ldap_group
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import users from '../../../../fixtures/ldap_users.json';
let groupID;
let boardUser;
let regularUser;
let testTeam;
// Goes to the groups page for the group specified by id as sysadmin
const navigateToGroup = (id) => {
// # Login as sysadmin and visit board group page, and wait until board user is visible
cy.apiAdminLogin();
cy.visit(`/admin_console/user_management/groups/${id}`);
// # Scroll users list into view and then make sure it has loaded before scrolling back to the top
cy.get('#group_users').scrollIntoView();
cy.findByText(boardUser.email).should('be.visible');
cy.get('#group_profile').scrollIntoView();
};
// Goes to the off-topic and attempts to display suggestions for the given group name
// Attempts to @mention the given group
// Checks to see that the group is not highlighted as a link when viewed by a user without permission to mention
// Checks to see that the group is not highlighted as a mention when viewed by user inside the group
const assertGroupMentionDisabled = (groupName) => {
const suggestion = groupName.substring(0, groupName.length - 1);
// # Visit off-topic
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Type suggestion in channel post text box
cy.uiGetPostTextBox().clear().type(`@${suggestion}`).wait(TIMEOUTS.HALF_SEC);
// * Should not open up suggestion list for groups
cy.get('#suggestionList').should('not.exist');
// # Type @groupName and post it to the channel
cy.uiGetPostTextBox().clear().type(`@${groupName}{enter}{enter}`);
// # Get last post message text
cy.getLastPostId().then((postId) => {
// * Assert that the last message posted contains the group name and is not highlighted with the class group-mention-link
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('not.exist');
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
});
// # Login as board user
cy.apiLogin(boardUser);
// # Visit off-topic
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Get last post message text
cy.getLastPostId().then((postId) => {
// * Assert that the last message posted contains the group name and is not highlighted with the class mention--highlight
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
});
};
// Goes to the off-topic and attempts to display suggestions for the given group name
// Attempts to @mention the given group
// Checks to see that the group is highlighted as a link when viewed by a user outside of the group
// Checks to see that the group is highlighted as a mention when viewed by user inside the group
const assertGroupMentionEnabled = (groupName) => {
const suggestion = groupName.substring(0, groupName.length - 1);
// # Visit off-topic
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Type suggestion in channel post text box
cy.uiGetPostTextBox().clear().type(`@${suggestion}`).wait(TIMEOUTS.HALF_SEC);
// * Should open up suggestion list for groups
// * Should match group item and group label
cy.get('#suggestionList', {timeout: TIMEOUTS.FIVE_SEC}).should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', `@${groupName}`);
});
// # Type @groupName and post it to the channel
cy.uiGetPostTextBox().clear().type(`@${groupName}{enter}{enter}`).wait(TIMEOUTS.HALF_SEC);
// # Get last post message text
cy.getLastPostId().then((postId) => {
// * Assert that the last message posted contains the group name and is highlighted with the class group-mention-link
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('be.visible').should('include.text', `@${groupName}`);
});
// # Login as board user
cy.apiLogin(boardUser);
// # Visit off-topic
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Get last post message text
cy.getLastPostId().then((postId) => {
// * Assert that the last message posted contains the group name and is highlighted with the class mention--highlight
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('be.visible').should('include.text', `@${groupName}`);
});
};
// Clicks the save button in the system console page.
const saveConfig = () => {
// # Save if possible (if previous test ended abruptly all permissions may already be enabled)
cy.get('#saveSetting').then((btn) => {
if (btn.is(':enabled')) {
btn.click();
cy.waitUntil(() => cy.get('#saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
}
});
};
describe('System Console', () => {
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// # Enable LDAP
cy.apiUpdateConfig({LdapSettings: {Enable: true}});
cy.apiInitSetup().then(({team, user}) => {
regularUser = user;
testTeam = team;
});
// # Link board group
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group').then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Get board group id
cy.apiGetGroups().then((res) => {
res.body.forEach((group) => {
if (group.display_name === 'board') {
// # Set groupID to navigate to group page directly
groupID = group.id;
// # Set allow reference false to ensure correct data for test cases
cy.apiPatchGroup(groupID, {allow_reference: false});
}
});
});
// # Login once as board user to ensure the user is created in the system
boardUser = users['board-1'];
cy.apiLogin(boardUser);
// # Login as sysadmin and add board-one to test team
cy.apiAdminLogin();
// # Add board user to test team to ensure that it exists in the team and set its preferences to skip tutorial step
cy.apiGetUserByEmail(boardUser.email).then(({user}) => {
cy.apiGetChannelByName(testTeam.name, 'off-topic').then(({channel}) => {
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
cy.apiSaveTutorialStep(user.id, '999');
});
});
it('MM-23937 - Can enable and disable group mentions with a custom name for a group ', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and navigate to board group page
navigateToGroup(groupID);
// # Click the allow reference button
cy.findByTestId('allowReferenceSwitch').then((el) => {
el.find('button').click();
// # Give the group a custom name different from its DisplayName attribute
cy.get('#groupMention').find('input').clear().type(groupName);
// # Click save button
saveConfig();
// * Assert that the group mention works as expected since the group is enabled and sysadmin always has permission to mention
assertGroupMentionEnabled(groupName);
// # Login as sysadmin and navigate to board group page
navigateToGroup(groupID);
// # Click the allow reference button
cy.findByTestId('allowReferenceSwitch').then((elSwitch) => {
elSwitch.find('button').click();
// # Click save button
saveConfig();
// * Assert that the group mention does not do anything since the group is disabled even though sysadmin has permission to mention
assertGroupMentionDisabled(groupName);
});
});
});
it('MM-23937 - Can restrict users from mentioning a group through the use_group_mentions permission', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin
cy.apiAdminLogin();
// # Set group as allow reference = true with name groupName
cy.apiPatchGroup(groupID, {allow_reference: true, name: groupName});
// # Navigate to system scheme page
cy.visit('/admin_console/user_management/permissions/system_scheme');
// # Click reset to defaults, confirm and save
cy.findByTestId('resetPermissionsToDefault').click({force: true});
cy.get('#confirmModalButton').click({force: true});
saveConfig();
// # Login as a normal user
cy.apiLogin(regularUser);
// * Assert that the group mention works as expected since the group is enabled and user has permission to mention
assertGroupMentionEnabled(groupName);
// # Login as sysadmin and navigate to system scheme
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
// # Disable group mentions for users if enabled and save
cy.findByTestId('all_users-posts-use_group_mentions-checkbox').then((btn) => {
if (btn.hasClass('checked')) {
btn.click();
}
saveConfig();
// # Login as a regular member
cy.apiLogin(regularUser);
// * Assert that the group mention does not do anything since the user does not have the permission to mention the group
assertGroupMentionDisabled(groupName);
});
});
after(() => {
// # Login as sysadmin and navigate to system scheme page
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
// # Click reset to defaults confirm and save
cy.findByTestId('resetPermissionsToDefault').click();
cy.get('#confirmModalButton').click();
saveConfig();
});
});

Просмотреть файл

@@ -0,0 +1,127 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap_group
import * as TIMEOUTS from '../../../../fixtures/timeouts';
// # Function to get all the teams associated to group and unlink them
const getTeamsAssociatedToGroupAndUnlink = (groupId) => {
cy.request({
headers: {'X-Requested-With': 'XMLHttpRequest'},
url: `/api/v4/groups/${groupId}/teams`,
method: 'GET',
}).then((response) => {
expect(response.status).to.equal(200);
response.body.forEach((element) => {
cy.request({
headers: {'X-Requested-With': 'XMLHttpRequest'},
url: `/api/v4/groups/${element.group_id}/teams/${element.team_id}/link`,
method: 'DELETE',
});
});
});
};
// # Function to get all the channels associated to group and unlink them
const getChannelsAssociatedToGroupAndUnlink = (groupId) => {
cy.request({
headers: {'X-Requested-With': 'XMLHttpRequest'},
url: `/api/v4/groups/${groupId}/channels`,
method: 'GET',
}).then((response) => {
expect(response.status).to.equal(200);
response.body.forEach((element) => {
cy.request({
headers: {'X-Requested-With': 'XMLHttpRequest'},
url: `/api/v4/groups/${element.group_id}/channels/${element.channel_id}/link`,
method: 'DELETE',
});
});
});
};
describe('LDAP Group Sync', () => {
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// Enable LDAP
cy.apiUpdateConfig({LdapSettings: {Enable: true}});
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
});
it('MM-T2668 Team admin role can be set and saved', () => {
// # Go to system admin page and to team configuration page
cy.visit('/admin_console/user_management/groups');
cy.get('#developers_group').then((el) => {
if (el.text().includes('Edit')) {
cy.get('#developers_edit').then((buttonEl) => {
// # Get the Group ID and remove all the teams and channels currently attached to it then click the button
const anchorElement = buttonEl[0] as HTMLAnchorElement;
const groupId = anchorElement.href.match(/\/(?:.(?!\/))+$/)[0].substring(1);
getTeamsAssociatedToGroupAndUnlink(groupId);
getChannelsAssociatedToGroupAndUnlink(groupId);
cy.get('#developers_edit').click();
});
} else {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
// # Get the Group ID and remove all the teams and channels currently attached to it then click the button
cy.get('#developers_configure').then((buttonEl) => {
const anchorElement = buttonEl[0] as HTMLAnchorElement;
const groupId = anchorElement.href.match(/\/(?:.(?!\/))+$/)[0].substring(1);
getTeamsAssociatedToGroupAndUnlink(groupId);
getChannelsAssociatedToGroupAndUnlink(groupId);
cy.get('#developers_configure').click();
});
}
});
// # Wait until the groups retrieved and show up
cy.wait(TIMEOUTS.HALF_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
// # Add the first team in the group list then save
cy.get('#add_team_or_channel').click();
cy.get('#add_team').click();
cy.get('#multiSelectList').should('be.visible').children().first().click({force: true});
cy.uiGetButton('Add').click();
// # Add the first channel in the group list then save
cy.get('#add_team_or_channel').click();
cy.get('#add_channel').click();
cy.get('#multiSelectList').children().first().click();
cy.uiGetButton('Add').click();
// # Wait until the groups retrieved and show up
cy.wait(TIMEOUTS.HALF_SEC); //eslint-disable-line cypress/no-unnecessary-waiting
cy.get('#team_and_channel_membership_table').then((el) => {
// * Ensure that the text in the roles column is Member as default text for each row
const table = el[0] as HTMLTableElement;
const name = table.rows[1].cells[0].innerText;
cy.findByTestId(`${name}_current_role`).scrollIntoView().should('contain.text', 'Member');
// # Change the option to the admin roles (Channel Admin/Team Admin) for each row
cy.findByTestId(`${name}_current_role`).scrollIntoView().click();
cy.get(`#${name}_change_role_options button`).scrollIntoView().click();
// * Ensure that each row roles have changed successfully (by making sure that the Member text is not existent anymore)
cy.findByTestId(`${name}_current_role`).scrollIntoView().should('not.contain.text', 'Member');
});
});
});

Просмотреть файл

@@ -0,0 +1,94 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap_group
describe('Group Synced Team - Bot invitation flow', () => {
let groupConstrainedTeam;
let bot;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// # Enable LDAP
cy.apiUpdateConfig({LdapSettings: {Enable: true}});
// # Get the first group constrained team available on the server
cy.apiGetAllTeams().then(({teams}) => {
teams.forEach((team) => {
if (team.group_constrained && !groupConstrainedTeam) {
groupConstrainedTeam = team;
}
});
});
// # Get the first bot on the server
cy.apiGetBots().then(({bots}) => {
bot = bots[0];
});
});
it('MM-21793 Invite and remove a bot within a group synced team', () => {
if (!groupConstrainedTeam || !bot) {
return;
}
// # Logout sysadmin and login as an LDAP Group synced user
cy.apiLogout();
const user = {
username: 'test.one',
password: 'Password1',
} as Cypress.UserProfile;
cy.apiLogin(user);
// # Visit the group constrained team
cy.visit(`/${groupConstrainedTeam.name}`);
// # Click 'Invite People' at team menu
cy.uiOpenTeamMenu('Invite People');
// # Type the first letters of a bot
cy.get('.users-emails-input__control input').typeWithForce(bot.username);
// * Verify user is on the list, then select by clicking on it
cy.get('.users-emails-input__menu').
children().should('have.length', 1).
eq(0).should('contain', `@${bot.username}`).
click();
// # Invite the bot
cy.get('#inviteMembersButton').click();
// * Ensure that the response message was not an error
cy.get('.InviteResultRow').find('.reason').should('not.contain', 'Error');
// # Visit the group constrained team
cy.visit(`/${groupConstrainedTeam.name}`);
// # Click 'Manage Members' at team menu
cy.uiOpenTeamMenu('Manage Members');
// # Search for the bot that we want to remove
cy.get('#searchUsersInput').should('be.visible').type(bot.username);
cy.get(`#teamMembersDropdown_${bot.username}`).should('be.visible').then((el) => {
// # Have to use a jquery click here instead of a cypress click due to in order for the dropdown menu to stay open
el.click();
// * Ensure that we have the ability to remove the bot and click the dropdown option
cy.get('#removeFromTeam').should('be.visible').click();
});
// * Ensure that the bot is no longer there
cy.findByTestId('noUsersFound').should('be.visible');
});
});

Просмотреть файл

@@ -0,0 +1,122 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @ldap_group
import {getRandomId} from '../../../../utils';
describe('Search channels', () => {
const PAGE_SIZE = 10;
let testTeamId;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// Enable LDAP
cy.apiUpdateConfig({LdapSettings: {Enable: true}});
cy.apiInitSetup().then(({team}) => {
testTeamId = team.id;
});
});
beforeEach(() => {
cy.visit('/admin_console/user_management/channels');
});
it('loads with no search text', () => {
// * Check that text input loads empty.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').and('have.text', '');
});
});
it('returns results', () => {
// # Create a channel.
const displayName = getRandomId();
cy.apiCreateChannel(testTeamId, 'channel-search', displayName);
// # Search for the channel.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').type(displayName + '{enter}');
});
// * Check that channel is in search results.
cy.findAllByTestId('channel-display-name').contains(displayName);
});
it('results are paginated', () => {
// # Create enough new channels with common name prefixes to get multiple pages of search results.
const displayName = getRandomId();
for (let i = 0; i < PAGE_SIZE + 2; i++) {
cy.apiCreateChannel(testTeamId, 'channel-search-paged-' + i, displayName + ' ' + i);
}
// # Search using the common channel name prefix.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').type(displayName + '{enter}');
});
// * Check that the first page of results is full.
cy.findAllByTestId('channel-display-name').should('have.length', PAGE_SIZE);
// # Click the next pagination arrow.
cy.get('.DataGrid_footer').should('have.text', '1 - 10 of 12').within(() => {
cy.get('.next').should('be.enabled').click();
});
// * Check that the 2nd page of results has the expected amount.
cy.findAllByTestId('channel-display-name').should('have.length', 2);
});
it('clears the results when "x" is clicked', () => {
// # Create a new channel.
const displayName = getRandomId();
cy.apiCreateChannel(testTeamId, 'channel-search', displayName);
// # Search for the channel.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').as('searchInput').type(displayName + '{enter}');
});
// * Check that the list of channels is in search results mode.
cy.findAllByTestId('channel-display-name').should('have.length', 1);
// # Click the x in the search input.
cy.findByTestId('clear-search').click();
// * Check that the search input text is cleared.
cy.get('@searchInput').should('be.visible').and('have.text', '');
// * Check that the search results are reset to the default page-load list.
cy.findAllByTestId('channel-display-name').should('have.length', PAGE_SIZE);
});
it('clears the results when the search term is deleted with backspace', () => {
// # Create a channel.
const displayName = getRandomId();
cy.apiCreateChannel(testTeamId, 'channel-search', displayName);
// # Search for the channel.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').as('searchInput').type(displayName + '{enter}');
});
// * Check that the list of teams is in search results mode.
cy.findAllByTestId('channel-display-name').should('have.length', 1);
// # Clear the search input by deleting the search text.
cy.get('@searchInput').type('{selectall}{del}');
// * Check that the search results are reset to the default page-load list.
cy.findAllByTestId('channel-display-name').should('have.length', PAGE_SIZE);
});
});

Просмотреть файл

@@ -0,0 +1,225 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @enterprise @ldap_group
import * as TIMEOUTS from '../../../../fixtures/timeouts';
// # Save setting and get back to the resource page
const saveAndNavigateBackTo = (name, displayName, page) => {
cy.get('#saveSetting').should('be.enabled').click().wait(TIMEOUTS.HALF_SEC);
// * Verify that it redirects to page and wait for a while to load
cy.url().should('include', `/admin_console/user_management/${page}`).wait(TIMEOUTS.TWO_SEC);
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${displayName}{enter}`).wait(TIMEOUTS.HALF_SEC);
});
cy.findByTestId(`${name}edit`).should('be.visible').click();
};
const changeRole = (type, fromRole, toRole) => {
// # Wait for data grid to load
cy.get(`#${type}Members`).scrollIntoView().within(() => {
cy.get('.UserGrid_nameRow').should('be.visible');
});
// * Ensure current role is fromRole then click
cy.get(`#${type}_groups`).scrollIntoView().findByTestId('current-role').should('have.text', fromRole).click();
// # Change role
cy.get('#role-to-be-menu').then((el) => {
// * Assert that only one option exists in the dropdown for changing roles
expect(el[0].firstElementChild.children.length).equal(1);
// # Click on toRole
cy.wrap(el).findByText(toRole).click().wait(TIMEOUTS.HALF_SEC);
});
};
describe('System Console', () => {
const groupDisplayName = 'board';
let testTeam;
let teamName;
let teamDisplayName;
let channelName;
let channelDisplayName;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
cy.apiInitSetup({
teamPrefix: {name: 'a-team', displayName: 'A Team'},
channelPrefix: {name: 'a-channel', displayName: 'A Channel'},
}).then(({team, channel}) => {
testTeam = team;
teamName = team.display_name;
teamDisplayName = team.display_name;
channelName = channel.name;
channelDisplayName = channel.display_name;
cy.apiGetLDAPGroups().then((res) => {
res.body.groups.forEach((group) => {
if (group.name === groupDisplayName) {
cy.apiAddLDAPGroupLink(group.primary_key);
}
});
});
});
});
beforeEach(() => {
cy.apiGetTeamGroups(testTeam.id).then((resGroups) => {
resGroups.body.groups.forEach((group) => {
if (group.display_name === groupDisplayName) {
cy.apiDeleteLinkFromTeamToGroup(group.id, testTeam.id);
}
});
});
});
it('MM-20059 - System Admin can map roles to groups from Team Configuration screen', () => {
// # Go to system admin page and to team configuration page
cy.visit('/admin_console/user_management/teams');
// # Search for the team.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${teamDisplayName}{enter}`);
});
cy.findByTestId(`${teamName}edit`).click();
// # Add the first group in the group list then save
cy.findByTestId('addGroupsToTeamToggle').scrollIntoView().click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.get('#saveItems').click();
// # Change role from Member to Team Admin
changeRole('team', 'Member', 'Team Admin');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(teamName, teamDisplayName, 'teams');
// # Change role from Team Admin to Member
changeRole('team', 'Team Admin', 'Member');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(teamName, teamDisplayName, 'teams');
// * Check to make the the current role text is displayed as Member
cy.get('#team_groups').scrollIntoView().findByTestId('current-role').should('have.text', 'Member');
// # Wait for the board group to show up before continuing to next steps
cy.waitUntil(() => cy.get('.group-row').eq(0).scrollIntoView().find('.group-name').then((el) => {
return el[0].innerText === groupDisplayName;
}), {
errorMsg: `${groupDisplayName} group didn't show up in time`,
timeout: TIMEOUTS.TEN_SEC,
});
// # Remove "board" group
cy.get('.group-row').eq(0).scrollIntoView().should('be.visible').within(() => {
cy.get('.group-name').should('have.text', groupDisplayName);
cy.get('.group-actions > a').should('have.text', 'Remove').click();
});
// * Assert that the group was removed successfully
cy.get('#groups-list--body').should('be.visible').contains('No groups specified yet');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(teamName, teamDisplayName, 'teams');
// * Assert that the group was removed successfully
cy.get('#groups-list--body').scrollIntoView().should('be.visible').contains('No groups specified yet');
});
it('MM-21789 - Add a group and change the role and then save and ensure the role was updated on team configuration page', () => {
// # Go to system admin page and to team configuration page
cy.visit('/admin_console/user_management/teams');
// # Search for the team.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${teamDisplayName}{enter}`);
});
cy.findByTestId(`${teamName}edit`).click();
// # Add the first group in the group list then save
cy.findByTestId('addGroupsToTeamToggle').click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.get('#saveItems').click();
// # Change role from Member to Team Admin
changeRole('team', 'Member', 'Team Admin');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(teamName, teamDisplayName, 'teams');
// * Check to make the the current role text is displayed as Team Admin
cy.get('#team_groups').scrollIntoView().findByTestId('current-role').should('have.text', 'Team Admin');
});
it('MM-20646 - System Admin can map roles to groups from Channel Configuration screen', () => {
// # Go to system admin page and to channel configuration page of channel "autem"
cy.visit('/admin_console/user_management/channels');
// # Search for the channel.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${channelDisplayName}{enter}`);
});
cy.findByTestId(`${channelName}edit`).click();
// # Add the first group in the group list then save
cy.get('#addGroupsToChannelToggle').click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.get('#saveItems').click();
// # Change role from Member to Channel Admin
changeRole('channel', 'Member', 'Channel Admin');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(channelName, channelDisplayName, 'channels');
// # Change role from Channel Admin to Member
changeRole('channel', 'Channel Admin', 'Member');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(channelName, channelDisplayName, 'channels');
// * Check to make the the current role text is displayed as Member
cy.get('#channel_groups').scrollIntoView().findByTestId('current-role').should('have.text', 'Member');
});
it('MM-21789 - Add a group and change the role and then save and ensure the role was updated on channel configuration page', () => {
// # Go to system admin page and to channel configuration page of channel "autem"
cy.visit('/admin_console/user_management/channels');
// # Search for the channel.
cy.get('.DataGrid_searchBar').within(() => {
cy.findByPlaceholderText('Search').should('be.visible').type(`${channelDisplayName}{enter}`);
});
cy.findByTestId(`${channelName}edit`).click();
// # Add the first group in the group list then save
cy.get('#addGroupsToChannelToggle').click();
cy.get('#multiSelectList').should('be.visible');
cy.get('#multiSelectList>div').children().eq(0).click();
cy.get('#saveItems').click();
// # Change role from Member to Channel Admin
changeRole('channel', 'Member', 'Channel Admin');
// # Save the setting and navigate back to page
saveAndNavigateBackTo(channelName, channelDisplayName, 'channels');
// * Check to make the the current role text is displayed as Channel Admin
cy.get('#channel_groups').scrollIntoView().findByTestId('current-role').should('have.text', 'Channel Admin');
});
});